OS (e.g. Win10): macOS Monterey 12.3.1
PsychoPy version (e.g. 1.84.x): 2021.2.3
Standard Standalone? (y/n) y If not then what?:
What are you trying to achieve?:
Currently, I have created a word naming experiment that voice records for a 2-second duration. I want to both be able to record audio and get voice onset time. When uploading the experiment on Pavlovia, it is able to record audio but I am unable to get voice onset time. I tried using the code from a word naming demo, but this gives me an error.
What did you try to make it work?:
In the instructions I added the following code:
Begin Experiment
The import and pyo_init should always come early on:
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
For the word naming routine, I added in the following code:
Begin routine
Create a voice-key to be used:
vpvk = vk.OnsetVoiceKey(
sec=2,
file_out=‘data/trial_’+str(trials.thisN).zfill(3)+’_’+word+’.wav’)
Start it recording (and detecting):
vpvk.start() # non-blocking; don’t block when using Builder
End Routine
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:
thisExp.addData(‘vocal_RT’, round(vpvk.event_onset, 3))
thisExp.addData(‘bad_baseline’, vpvk.bad_baseline)
thisExp.addData(‘filename’, vpvk.filename)
thisExp.nextEntry()
What specifically went wrong when you tried that?:
The error looks like:
Alert 4210: JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab.
For more info see https://docs.psychopy.org/alerts/4210.htmlAlert 4210: JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab. EXP Imported /Users/…/test trials.xlsx as conditions, 11 conditions, 1 params
158.7302 ERROR Line 102: Unexpected token in expt1-wordnaming.js
158.7471 EXP Imported /Users/…/test trials.xlsx as conditions, 11 conditions, 1 params
158.8688 ERROR Line 94: Unexpected token in expt1-wordnaming-legacy-browsers.js
I expect that this error has to do with conversion between Python → Javascript but I’m not sure how to fix it.
Another issue that I’m anticipating is that “vocal_RT” will not be accurate.
expt1-wordnaming.psyexp (20.9 KB)