Have I used the psychopy.sound.Microphone.start() function appropriately in my cued recall task?

Hi there,

I am using Psychopy v2022.1.1 coder to build a cued recall task, and I have a couple of questions about the latency of the psychopy.sound.Microphone.start() function. Below, I have provided a brief description of my task and then a snippet of the relevant code (which I have simplified to only include the relevant lines). I have then asked my questions at the end.

Task description
Participants are presented with a cue word on the screen, and they have unlimited time to verbally respond with the correct response word (learned in a previous task). I want to audio record their verbal responses and determine their response time for each word (i.e., the time between presentation of the cue word on the screen and their verbal response).

Description of my approach
After opening the microphone at the beginning of the script, I loop over a list of cue words and present them on the screen. In each loop:

  • the cue word is displayed
  • the microphone begins recording
  • the script waits for a mouse click (clicked by the researcher, after the participant has given their verbal response)
  • when a mouse click is recorded, the microphone stops recording and saves the recording in a .wav file (note that the file name is unique for each trial, but I haven’t shown this below).
    The loop then continues looping until all the cue words have been presented and all responses audio recorded. I’ll end up with a .wav file for each trial, and I plan to use Audacity (or similar) to determine the start time of the verbal response in each trial.

Relevant code

from psychopy import visual, event, core, gui, sound
from psychopy import prefs

prefs.hardware['audioLib'] = 'PTB'
prefs.hardware['audioLatencyMode'] = 3

expClock = core.Clock()
mic=sound.Microphone(channels=1, streamBufferSecs=15)

for i in range(num_items): 
	if event.getKeys(['end']): 
	buttons = myMouse.getPressed(getTime=False) # check for mouse clicks
	while buttons == [0,0,0]: 
		buttons = myMouse.getPressed(getTime=False) # keep checking for mouse clicks
		if buttons != [0,0,0]: # when a mouse click is registered
			audioclip = mic.getRecording()
		if event.getKeys(['end']):  

My questions
Will the latencies involved in my approach above impact my ability to accurately calculate response times? I can see two possible issues:

  1. The latency between win.flip() and mic.start() - is there likely to be a long delay between the presentation of the cue word and the call to mic.start()?
  2. The latency between mic.start() and the actual start of the audio recording - will the start of my audio recordings be cropped by this latency, and if so, is there any way I can determine this latency?

If the approach I have used above is not appropriate for my application, I would appreciate any advice you have regarding a more appropriate method. Thank you for your help!