Error with microphone component on PsychoPy 2020

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2020.1.3
Standard Standalone? (y/n) If not then what?: yes
What are you trying to achieve?: audio record participants’ free recall

What did you try to make it work?: I’m fairly new to PsychoPy, now building my second experiment on it. I’m building a memory experiment, in which participants will see a short story, followed by a spoken free-recall about details in the story. I added a microphone component, but the program raised the following error message (seen in the next section). I tried the default microphone component setting, but the same error persisted. I then tried to change the experiment and hardware settings but saw nothing that could be changed. If I remove the microphone component, everything worked fine.

What specifically went wrong when you tried that?:
After entering the participant number, the screen became black and displayed the following error message:

Traceback (most recent call last):
File “C:\Users\czm19\OneDrive\Research\GouDan\Moscovitch\story_experiment\story_experiment_lastrun.py”, line 78, in
microphone.switchOn()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\microphone.py”, line 1191, in switchOn
backend_pyo.init(rate=sampleRate)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 207, in init
devNames, devIDs = get_output_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 109, in get_output_devices
devices = _query_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 86, in _query_devices
info[v.strip().split(": “)[0]] = v.strip().split(”: ")[1]
IndexError: list index out of range

Experiment ended.

Thank you so much for your help!
Ziming Cheng

Hi Ziming,

It looks like there’s a problem with pyo, this is a back-end process that handles audio in PsychoPy. If you go to File, then Preferences, then Hardware, what is in the box audio library?

Thanks,

Todd

Hi Todd,

Thank you for your reply! The audio libraries are [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’, ]

I downloaded a previous version of psychopy (v3.2.4 released last year), and somehow the problem is fixed without any further steps. Maybe there’s a bug in the most recent release?

Cheers,
Ziming

It’s most likely a conflict between your machine’s audio drivers and that particular command from pyo in the newer version of PsychoPy, I’ll take note in case we see this error pop up again so we can look for similarities and I’ll use your error logs to try and trace the problem. Are you happy using an older version for now?

Yes I am! Do you happen to know if there’s any ways for participants to test their microphones before starting the experiment? Because we are only doing online experiments nowadays, participants need to use their own computers and we hope to check that the hardwares are fine before proceeding.

You could try using playback() function from a microphone component: https://www.psychopy.org/api/microphone.html#psychopy.microphone.AdvAudioCapture.playback
This will play the audio just recorded, so you could record them with a mic component (let’s call it testMic) and then add a code component with this in the End Routine tab:

testMic.playback()

Then, on the next routine, have an input of some sort in which participants indicate whether they heard the playback or not.

Would that work?

Yes that worked. Thank you so much!
Now that you are here, can I ask you another question about Pavlovia? The experiment now works as intended on my computer, but encounters an error after the starting page (TypeError: Cannot assign to read only property ‘undefined’ of object ‘#’). Plus, the starting page is not what I have on my computer. The local version has a bunch of instructions, but the online version simply says “say something”. I’ve double checked that the files were synced and the root folder is correct. Do you happen to have any ideas on what may cause this issue?

I mostly deal with the local Python side of things, but I’ll try to help as best I can!

What line of the code was the error on? Can you look at the compiled script and copy the offending line for me to see?

Thanks! For some reason the error did not specify the line of code, and only says the above type error. I read that the code components written in python may crash the online experiment when transcribed to javascript, so I moved that part to local. It only randomizes my input csv without creating any variables to be used later. The experiment now crashes after testing the microphone, with the same error message. No sound played during the microphone playback (although it works in the local version). Now the only manual code was mic.playback(), with everything else written with the builder.
story_experiment.psyexp (72.7 KB)

I have the same problem.
I installed last 2020.2.4 version standallone on windows 10 and when I try to execute the builder demo vor voiceCapture, the program ends with this messages: 1) having take out pyo library from hardware libraries 2)having added pyo at the end 3) having added pyo at the begining of the list. Allways ends with the same out of index problem.
I hope there is an easy workaround.
Thanks for your help.

Welcome to PsychoPy3!
v2020.2.4
89.5317 INFO Loaded monitor calibration from [‘2018_09_19 09:02’]
102.6955 INFO Loaded monitor calibration from [‘2018_09_19 09:02’]
Generating PsychoPy script…

Running: C:\Users\dejsl\DAMIAN\PsychoPy3 Demos\voiceCapture\voiceCapture_lastrun.py

pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
1: IN, name: Micrófono (Realtek High Definit, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
6: IN, name: Micrófono (Realtek High Definition Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
15.6917 WARNING Starting Microphone but sound lib preference is set to be [‘PTB’, ‘pygame’, ‘soundevice’]. Clashes might occur since ‘pyo’ is not preferred lib but is needed for Microphone
Traceback (most recent call last):
File “C:\Users\dejsl\DAMIAN\PsychoPy3 Demos\voiceCapture\voiceCapture_lastrun.py”, line 77, in
microphone.switchOn()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\microphone.py”, line 1191, in switchOn
backend_pyo.init(rate=sampleRate)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 208, in init
devNames, devIDs = get_output_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 109, in get_output_devices
devices = _query_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 86, in _query_devices
** info[v.strip().split(": “)[0]] = v.strip().split(”: ")[1]**
IndexError: list index out of range

Experiment ended.

1025.9100 INFO Loaded monitor calibration from [‘2018_09_19 09:02’]
Generating PsychoPy script…

Running: C:\Users\dejsl\DAMIAN\PsychoPy3 Demos\voiceCapture\voiceCapture_lastrun.py

pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
1: IN, name: Micrófono (Realtek High Definit, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
6: IN, name: Micrófono (Realtek High Definition Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
13.6251 WARNING Starting Microphone but sound lib preference is set to be [‘PTB’, ‘pygame’, ‘soundevice’, ‘pyo’]. Clashes might occur since ‘pyo’ is not preferred lib but is needed for Microphone
Traceback (most recent call last):
File “C:\Users\dejsl\DAMIAN\PsychoPy3 Demos\voiceCapture\voiceCapture_lastrun.py”, line 77, in
microphone.switchOn()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\microphone.py”, line 1191, in switchOn
backend_pyo.init(rate=sampleRate)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 208, in init
devNames, devIDs = get_output_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 109, in get_output_devices
devices = _query_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 86, in _query_devices
** info[v.strip().split(": “)[0]] = v.strip().split(”: ")[1]**
IndexError: list index out of range

Experiment ended.

1093.6800 INFO Loaded monitor calibration from [‘2018_09_19 09:02’]
Generating PsychoPy script…

Running: C:\Users\dejsl\DAMIAN\PsychoPy3 Demos\voiceCapture\voiceCapture_lastrun.py

pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
1: IN, name: Micrófono (Realtek High Definit, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
6: IN, name: Micrófono (Realtek High Definition Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
3.9551 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 [‘pyo’, ‘PTB’, ‘pygame’, ‘soundevice’] (in that order).
Traceback (most recent call last):
File “C:\Users\dejsl\DAMIAN\PsychoPy3 Demos\voiceCapture\voiceCapture_lastrun.py”, line 77, in
microphone.switchOn()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\microphone.py”, line 1191, in switchOn
backend_pyo.init(rate=sampleRate)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 208, in init
devNames, devIDs = get_output_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 109, in get_output_devices
devices = _query_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 86, in _query_devices
** info[v.strip().split(": “)[0]] = v.strip().split(”: ")[1]**
IndexError: list index out of range

Experiment ended.

Regards

Damian

Hello,

I run in the same problem.

Hello from the pygame community. https://www.pygame.org/contribute.html
5: OUT, name: Lautsprecher / Kopfhörer (Conex, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
6: IN, name: Primärer Soundaufnahmetreiber, host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
9: OUT, name: Primärer Soundtreiber, host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
11: OUT, name: Lautsprecher / Kopfhörer (Conexant SmartAudio HD), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
1.8751 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 [‘pyo’] (in that order).
Traceback (most recent call last):
File “D:\Boelte\Eigene Dokumente\Downloads\Naming\PictureWord_lastrun.py”, line 80, in
microphone.switchOn()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\microphone.py”, line 1191, in switchOn
backend_pyo.init(rate=sampleRate)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 208, in init
devNames, devIDs = get_output_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 109, in get_output_devices
devices = _query_devices()
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py”, line 86, in _query_devices
info[v.strip().split(": “)[0]] = v.strip().split(”: ")[1]
IndexError: list index out of range

Experiment ended.

Any suggestions how to solve this? Could this be related to the fact that there are several microphones available in my computer (bluetooth speaker, build-in microphon, camera-microphon)?

Best wishes Jens

Hello Jens,

In my case I solved the issue downgrading to an older Psychopy version, I can’t say which cause I did it at the university computer and I am travelling till the end of jannuary. Good luck!

Regards, Damian

Hello Damian,

thank a lot for your reply. This is, however, not an option for me because of other experiments I am running which need the current version.

Best wishes Jens

Hi,
I got the same problem with psychopy 2020.2.5 and 2020.2.10.
When pyo is not set as the preferred library, I have an error message saying that it should be as it is required for microphone use. But setting pyo as the preferred sound library does not solve anything. I get the same error messages without the one I just mentionned.

Without pyo as preferred:

Generating PsychoPy script...

## Running: C:\Users\ambre\Documents\CoCo_Projets\PronutriVoice_AliceGuyon\SCRIPTS_pronutri\PronutriVoice_lastrun.py ##
20.2693     EXP     Imported questions.csv as conditions, 8 conditions, 4 params
20.2770     INFO     Loaded monitor calibration from ['2020_11_20 11:20']
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
1: IN, name: Réseau de microphones (Realtek(, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
5: IN, name: Réseau de microphones (Realtek(R) Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
6: OUT, name: Périphérique audio principal, host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
0.9955     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 ['sounddevice', 'PTB', 'pyo', 'pygame'] (in that order).
9.3712     WARNING     Starting Microphone but sound lib preference is set to be ['sounddevice', 'PTB', 'pyo', 'pygame']. Clashes might occur since 'pyo' is not preferred lib but is needed for Microphone
Traceback (most recent call last):
  File "C:\Users\ambre\Documents\CoCo_Projets\PronutriVoice_AliceGuyon\SCRIPTS_pronutri\PronutriVoice_lastrun.py", line 78, in <module>
    microphone.switchOn()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\microphone.py", line 1191, in switchOn
    backend_pyo.init(rate=sampleRate)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py", line 208, in init
    devNames, devIDs = get_output_devices()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py", line 109, in get_output_devices
    devices = _query_devices()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py", line 86, in _query_devices
    info[v.strip().split(": ")[0]] = v.strip().split(": ")[1]
IndexError: list index out of range
##### Experiment ended. #####

When selecting pyo as the preferred sound library :

 Generating PsychoPy script...

## Running: C:\Users\ambre\Documents\CoCo_Projets\PronutriVoice_AliceGuyon\SCRIPTS_pronutri\PronutriVoice_lastrun.py ##
36.4566     EXP     Imported questions.csv as conditions, 8 conditions, 4 params
36.4654     INFO     Loaded monitor calibration from ['2020_11_20 11:20']
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
1: IN, name: Réseau de microphones (Realtek(, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
5: IN, name: Réseau de microphones (Realtek(R) Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
6: OUT, name: Périphérique audio principal, host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
1.0981     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 ['pyo'] (in that order).
Traceback (most recent call last):
  File "C:\Users\ambre\Documents\CoCo_Projets\PronutriVoice_AliceGuyon\SCRIPTS_pronutri\PronutriVoice_lastrun.py", line 79, in <module>
    microphone.switchOn()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\microphone.py", line 1191, in switchOn
    backend_pyo.init(rate=sampleRate)
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py", line 208, in init
    devNames, devIDs = get_output_devices()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py", line 109, in get_output_devices
    devices = _query_devices()
  File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\sound\backend_pyo.py", line 86, in _query_devices
    info[v.strip().split(": ")[0]] = v.strip().split(": ")[1]
IndexError: list index out of range
##### Experiment ended. #####
1 Like