Cannot have microphones in several routines

Hi everybody,

I’m working on WIN11 with the standalone 2021.2.3 psychopy version.
I’m actually trying to build an experiment in which I would like (among other things) to record participants’ voices during 210 sec before and after they take some medicines.
So my script is made of several routines including :

  • A routine in which voice is recorded while the participant is reading a text on the screen (3:30 minutes)
  • A routine in which I ask him/her to take the pils
  • Another routine in which I would like to record again the participant’s voice while reading another text (3:30 minutes)

Here are my problems:

  1. When the microphone is enabled in the first routine only, the experiment works fine but I get a warning saying Audio recording buffer filled! This means that no samples are saved beyond 125.0 seconds. Specify a larger recording buffer next time to avoid data loss. and my *.wav files are indeed no longer than 125 sec (I need 210).

  2. As soon as I enable the microphone component of the second routine, the experiment fail to run and I got error messages saying:

PTB-ERROR: Failed to open audio device 5. PortAudio reports this error: Invalid device 
PTB-ERROR: Desired audio parameters likely unsupported by audio device.
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
Error in function Open:     Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.
PsychPortAudio:Open: Usage:

pahandle = PsychPortAudio('Open' [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);
Traceback (most recent call last):
  File "C:\Users\ambre\Documents\CoCo_Projets\PronutriVoice_AliceGuyon\SCRIPTS_pronutri\", line 850, in <module>
    sampleRateHz=48000, maxRecordingSize=48000.0
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\", line 483, in __init__
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\", line 101, in __init__
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Exception ignored in: <bound method Stream.__del__ of < object at 0x0000014D74D159B0>>
Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\", line 236, in __del__
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\", line 146, in close
    raise err
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: 'Stream' object has no attribute 'handle'
##### Experiment ended. #####

The microphone components of the two routines have exactly the same parameters, namely:

  • duration of 210 sec
  • device setted at default
  • no transcription required
  • nothing to save except the audio file
  • sample rate + max recording size setted at 48kHz (because I also have some videos with this sample rate)
  • I disabled the “Force stereo” option

The required audio library is PTB but I’ve the same problem no matter the audio library I use (in addition with other few warnings and error messages when I don’t require PTB).

Does anyone know how to fix these two problems?
Any help would be greatly appreciated!!!

Cheers :beers: !

1 Like

Hey, I got the exact same issue. Have you solved the problem?

And for buffer error, simply increase the Max Recording size option of the microphone component.