Recording audio responses and voice onset times

Hi there,

I’m trying to decide whether to use PsychoPy for an experiment. We need to record verbal responses and calculate voice onset times, I’ve looked at the latencyFromTone.py demo so this seems to be possible, but I have some questions that hopefully someone can help with:

  1. I’ve been advised that sometimes measuring voice onset time when simultaneously recording audio causes accuracy problems with the timings - are there any known issues with this in PsychoPy?

  2. Is it possible to save each audio file/response with a particular name linked to the stimulus item? I’ve seen a similar post asking this question but it was unresolved.

  3. Is it possible to start an audio recording following a voice trigger (i.e. when the person starts speaking)?

Thanks for your help!

Briony

1 Like

Hello, I am in the same situation and have the same questions. Did you ever figure these things out?
thanku
-miguel

Hi Miguel, yes and no:

  1. Never found out - but in the end we recorded the audio in PsychoPy using the voicekey and manually calculated voice onset times using Praat. We did get automatic timings from PsychoPy, but they weren’t very accurate - partly because our verbal responses were too unpredictable - e.g. starting with different phonemes, different volume, and participants were sometimes sighing or saying ‘umm’ before responding.
  2. Yes this is possible - happy to share my code if it helps
  3. Sorry I can’t remember if this was possible (might be worth asking it in a separate post), but due to the issues above we started the recording at the onset of our visual stimulus before the participant responded.
    Also, the questions I had were relating to an older version of PsychoPy so things might have changed since. Good luck! Briony

thank you for your reply!

I have also found a workaround for obtaining the voice onset times. A colleague pointed out the existence of a really easy to use web page that will provide voice onset times for all the .wav files you upload (https://www.bcbl.eu/databases/chronset). It is really easy to use and seems to work well and saves you from doing it manually for each file. I’m posting it here in case other people find it useful.

I still have the problem of not being able to save each audio file/response with a particular name linked to the stimulus item. I would very much appreciate if you could share your code.

thank u!

I have modified the word_naming demo available in the demo tab of the Builder which uses voicekey. The problem is that the audio responses that are saved as .wav files only include the trial number. They do not include the participant ID or the stimulus name so they are overwritten everytime a new participant performs the task.

I assume that this could be done modifying the code in the begin routine tab.

Now the code in the begin routine reads:

Create a voice-key to be used:

vpvk = vk.OnsetVoiceKey(
sec=3,
file_out=‘data/trial_’+str(trials.thisN).zfill(3)+’_’+’.wav’)

Start it recording (and detecting):

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

The code in the End routine tab reads:

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()

This is interesting.

I think you can create a file_name_generate function

def file_name_generations():

1 get your working directory

cwd=os.getcwd()

2 scan files in cwd
file_list= os.listdir(cwd)

code = 0
filename=filename_{}.format(len(file_list)+1)

using the file name by calling the function

Would you mind if you could share your voiceKey code? I have some questions regarding the audio response and onset time too.