OS (e.g. Win10): Win11
PsychoPy version (e.g. 1.84.x): 2022.1.2
Standard Standalone? (y/n) If not then what?: Y
What are you trying to achieve?:
I’m trying to have stimuli presented, and as soon as the participant starts speaking, the stimulus goes away while PsychoPy records the audio of the participant. In other words, use psychopy’s voicekey to detect speech from the participant and record it while being able to access the property if the participant has started speaking.
What did you try to make it work?:
I’ve tried using voicekey to make it work
What specifically went wrong when you tried that?:
Voicekey won’t detect the onset of speech and record it. Voicekey is not picking up any form of speech.
In my routine disp_seg_4, I have the following code:
[Before Experiment]
import random
import time
import psychopy.voicekey as vk
[Begin Routine]
init_time = time.time()
'''
sec_5 is a boolean that checks if 5 seconds has passed for the onset of the stimuli.
If so, the stimuli should disappear.
If the user starts speaking before the 5 seconds, the stimuli should disappear.
Otherwise, the stimuli should disappear only after the 5 seconds
'''
sec_5 = False
vk.pyo_init()
vpvk = vk.OnsetVoiceKey(sec=3, file_out=(Group +"vk" + "{:02d}".format(trial_index) + ".wav"))
vpvk.detect()
trial_clock.reset()
vpvk.tStart=trial_clock.getTime()
[Each Frame]
if time.time() - init_time > SentTime:
sec_5 = True
vpvk.detect()
[End Routine]
thisExp.addData('vocal_RT', round(vpvk.event_onset, 3))
thisExp.addData('bad_baseline', vpvk.bad_baseline)
thisExp.addData('filename', vpvk.filename)
thisExp.addData('recordOnset', vpvk.tStart)
trial_index +=1
I have this as my stimuli, with the condition portion checking for the voicekey or the 5 seconds.
Here are my files if that helps:
Sentence Completion.psyexp (55.6 KB)
media.zip (59.9 KB)