vocal response s button press
I already asked how to use a voice key, but I still have trouble with this because I was recommended not to use just a normal microphone but a cedrus VP-1 device. I found python library which I think kind of records the vocal response like a button press. But it should be adopted to OpenSesame I think and I have trouble with this. The code goes like this:
import pyxid2 import time # get a list of all attached XID devices devices = pyxid2.get_xid_devices() dev = devices # get the first device to use print(dev) dev.reset_base_timer() dev.reset_rt_timer() if dev.is_response_device(): print ("Press a key!") while not dev.has_response(): dev.poll_for_response() response = dev.get_next_response() print(response) dev.clear_response_queue() dev.set_pulse_duration(300) sleep_flash = .3 for bm in range(0, 16): mask = 2 ** bm print("activate_line bitmask: ", mask) #dev.activate_line(lines=[1,3,5,7,9,11,13,15]) dev.activate_line(bitmask=mask) time.sleep(sleep_flash)
The response is a python dict with the following keys:
port: Device port the response was from (typically 0) key: Response pad key pressed by the subject pressed: True if the key was pressed, False if it was released time: value of the Response Time timer when the key was pressed/released
Sending a TTL pulse signal via the library can be done via the following methods:
set_pulse_duration() activate_line() clear_line()
Can you help me to simplify the code for OpenSesame (backend with Expyrement)? Thousand thanks!