psychopy.org | Reference | Downloads | Github

Error running mic response in Windows

OS : Win 10 Pro
PsychoPy version : 2021 2.3
Standard Standalone? (y/n) : y 64
What are you trying to achieve?: I want to add a double response: a button press that will be done by the experimenter (either pressing ‘c’ or ‘v’) and a verbal response recorded by microphone and given by the participant. I was wondering whether you could help me figure out the issue I have with the mic component.

What did you try to make it work?: So far I was able to make the experiment work without the microphone component but when I add it I run into errors. I have been reading some older topics in the forum but I have not been able to solve the issue. I have changed my preferences to PTB, pygame, pyo and sound device but it still does not work. I had problems before getting to run experiments with the PTB library. For me latency is important.

What specifically went wrong when you tried that?:

Running: C:\Users\Utilisateur\Desktop\task_lastrun.py

1424.1988 INFO Loaded monitor calibration from [‘2020_01_06 17:28’]
pygame 1.9.6
Hello from the pygame community. Contribute - pygame wiki
PTB-INFO: Using modified PortAudio V19.6.0-devel, revision unknown
PTB-ERROR: Desired audio parameters for device 11 unsupported by audio device: Invalid sample rate
PTB-ERROR: Seems the requested audio sample rate 16000.000000 Hz is not supported by this combo of hardware and sound driver.
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]);
1.7966 WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘pygame’] (in that order).
6.4242 WARNING User requested fullscreen with size [1536 864], but screen is actually [1920, 1080]. Using actual size
11.1635 WARNING Hamming was requested using the ‘pygame’ sound library but hamming is not supported there.
Traceback (most recent call last):
File “C:\Users\Utilisateur\Desktop\task_lastrun.py”, line 130, in
sampleRateHz=16000, maxRecordingSize=24000.0
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\microphone.py”, line 483, in init
channels=self._channels)
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 101, in init
flags)
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Exception ignored in: <bound method Stream.del of <psychtoolbox.audio.Stream object at 0x000001C48FD21940>>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 236, in del
self.close()
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 146, in close
raise err
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 139, in close
PsychPortAudio(‘Close’, self.handle)
AttributeError: ‘Stream’ object has no attribute ‘handle’

error_psychopy_mic
error_psychopy_preferences

Hello,

you requested a sampling frequency that is not supported by your hard- and software. Try a sampling rate that your hardware is capable of.

Best wishes Jens

Thank you @JensBoelte , do you know where can I find such information? Because I did not change or choose the sample rate.

Hello Marc_CR

well, the microphone-component has a tab called hardware. There you can set the sampling rate.

grafik

Best wishes Jens

Thank you @JensBoelte, I have checked and I have the same options than you.
error_psychopy_samplingrate
error_psychopy_samplingrate_options
I have no choice for Hz if I need to record the voice.

Best,

Hello Mar_CR,

your screenshots are too small to read. You can record with any sampling rate you want. When recording voice you don’t need a sampling rate of over 16 kHz because the human voice spectrum goes from around 80 Hz to 12 kHz. So, voice is just a label here.

Simply choose a sampling frequency that matches your hardware.

Best wishes Jens

Hi @JensBoelte ,
Sorry for the quality of the screenshots and thank you for the rapid answers! I tried to change it to 8Hz and even change the audio library but I still have the same error.

382.6931 INFO Loaded monitor calibration from [‘2020_01_06 17:28’]
pygame 1.9.6
Hello from the pygame community. Contribute - pygame wiki
PTB-INFO: Using modified PortAudio V19.6.0-devel, revision unknown
PTB-ERROR: Desired audio parameters for device 9 unsupported by audio device: Invalid sample rate
PTB-ERROR: Seems the requested audio sample rate 8000.000000 Hz is not supported by this combo of hardware and sound driver.
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]);
1.8235 WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘pygame’] (in that order).
6.2512 WARNING User requested fullscreen with size [1536 864], but screen is actually [1920, 1080]. Using actual size
10.7256 WARNING Hamming was requested using the ‘pygame’ sound library but hamming is not supported there.
Traceback (most recent call last):
File “C:\Users\Utilisateur\Desktop\task_lastrun.py”, line 130, in
sampleRateHz=8000, maxRecordingSize=24000.0
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\microphone.py”, line 483, in init
channels=self._channels)
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 101, in init
flags)
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Exception ignored in: <bound method Stream.del of <psychtoolbox.audio.Stream object at 0x000001BEA178F940>>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 236, in del
self.close()
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 146, in close
raise err
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 139, in close
PsychPortAudio(‘Close’, self.handle)
AttributeError: ‘Stream’ object has no attribute ‘handle’

Hello

read the error-message. You again selected a frequency that is not supported by our hardware and sound driver.
My reply was probably misleading you. I simply wanted to explain that the frequency range of 80 Hz to 12 kHz is the frequency range of the human voice. With a recording sampling frequency of 16 kHz you can record the whole spectrum of the human voice (well, not quite but that is another story).

You need to select a frequency that matches your hard- and software. So simply try out the higher frequency ranges.

Best wishes Jens

Hi,

Sorry for all the messages and thank you for your explanations. I chose the lowest sampling rate possible from the options (8Hz) and it still says that it is not supported by my hardware and sound driver. How can I solve this problem if no Hz options seem to match my system?

Thank you in advance for you help and time

Hello,

simply select a higher one.

Best wishes Jens

@JensBoelte Thank you for your suggestion and sorry for the late reply. I have been trying several things, now with 48Hz it seems to work but the folder for the microphone files is empty.

Best