How to code voicekey code in speech EEG programe

I want to programe a speech EEG task with psychopy.voicekey().
OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2022.02.04
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?:
Hi all, I want to record voice, the measure reaction time and psychopy send voice EEG trigger with speech voicekey (i.e., number, picture, word naming) when subject talk first voice.
What did you try to make it work?:
I try to

First, I was able to record subject voice by microphone component and send eeg trigger when microphone can record. But subject talking is not real time (i.e., subject speech RT was 3 s, microphone RT was 3.5 s).

Second, psychopy record microphone onset (i.e., mic.started), no offset time of microphone.
I want to record the measure reaction time. The measure reaction time was defined as the time from the first voice recorded speech segment and the final word recorded speech segment.

What specifically went wrong when you tried that?:
Final, I was able to record voice by microphone with psychopy.voiceket().
But error messenage show:
Traceback (most recent call last):
0.9941 WARNING Monitor specification not found. Creating a temporary one…
File “C:\Users\user\Desktop\speak\speak_lastrun.py”, line 357, in
vpvk = vk.OnsetVoiceKey(
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\voicekey_init_.py”, line 104, in init
raise VoiceKeyException(msg)
psychopy.voicekey.VoiceKeyException: Need a running pyo server: call voicekey.pyo_init()
########## Experiment ended with exit code 1 [pid:8208] ##########

Create a voice-key code:
The inst routine, there is a code:
In Begin experiment tab:

The import and pyo_init should always come early on:

from psychopy import voicekey
voicekey.pyo_init()
import psychopy.voicekey as vk
vk.pyo_init(rate=44100, buffersize=32)

What signaler class to use? Here just the demo signaler:

from psychopy.voicekey.demo_vks import DemoVoiceKeySignal as Signaler

To use a LabJack as a signaling device:

#from voicekey.signal.labjack_vks import LabJackU3VoiceKeySignal as Signaler

The trial_1 routine, there is a code_2:

In Begin routine tab:

Create a voice-key to be used. Change “trials” to reflect name of loop.

vpvk = vk.OnsetVoiceKey(

sec=2,

file_out=‘data/trial_’+str(trials.thisN).zfill(3)+‘_’+‘.wav’)

Start it recording (and detecting). Change targetScreen to reflect name of routine:

vpvk.start() # non-blocking; don’t block when using Builder

vpvk.tStart=targetScreenClock.getTime()

In End routine tab:

The recorded sound is saved upon .stop() by default. But

its a good idea to call .stop() explicitly, eg, if there’s much slippage:

vpvk.stop()

Add the detected time into the PsychoPy data file:

#vocal RT

thisexp.addData(‘vocal_RT’, round(vpvk.event_onset, 3))

#not sure what this is for

thisexp.addData(‘bad_baseline’, vpvk.bad_baseline)

#name of .wav file that will be outputted (sound recording)

thisexp.addData(‘filename’, vpvk.filename)

#time when the recording began

thisexp.addData(‘recordOnset’, vpvk.tStart)

Is the programe can run?

Hi, hyb123456hyb

If I add the psychopy.voicekey code in the code and code_2, which show the error message after show the inst rountine.
Traceback (most recent call last):
File “C:\Users\user\Desktop\speak\speak_lastrun.py”, line 363, in
vpvk = vk.OnsetVoiceKey(
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\voicekey_init_.py”, line 104, in init
raise VoiceKeyException(msg)
psychopy.voicekey.VoiceKeyException: Need a running pyo server: call voicekey.pyo_init()

If I select the disable of code and code_2, it can run eeg-psychopy programe successfully.

`

this is my eeg-speech programe
speak.psyexp (27.3 KB)
the condition .xlsx file below
try.xlsx (11.0 KB)

The code come from a deom of word-name paradigm. see upload file
temp.zip (3.7 KB)

The programe maybe not run in EEG. Becasuse not defiine the port of EEG

Hi, hyb123456hyb
I run the word-naming demo, the program can show the instructions routine.
I press any key to start and it close the program.
the error messenger show:
File “C:\Users\user\Downloads\temp\temp_lastrun.py”, line 271, in
vpvk = vk.OnsetVoiceKey(
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\voicekey_init_.py”, line 104, in init
raise VoiceKeyException(msg)
psychopy.voicekey.VoiceKeyException: Need a running pyo server: call voicekey.pyo_init()

So I edit experiment seeting properties and select the pyo of Audio library in Audio tab.
I run the program again and psychopy show the same error messenger.

Thank you for helping.