OS (e.g. Win10): Ubuntu 22.04.4 LTS
PsychoPy version : 2024.2.1 and 2024.2.0 (have not tested older versions yet)
Standard Standalone? (y/n) na
What are you trying to achieve?: Trying to play audio files for participants who will then repeat them back (phonetic shadowing task)
What did you try to make it work?: I have tried installing in a python3.10 venv (following current instructions on psychopy.org and using the installer from github) and building a miniconda environment using python 3.8.19
What specifically went wrong when you tried that?:
A grad student in our lab is trying to run a shadowing task using psychopy. He’s created a stripped-down experiment with 2 routines: the first uses a Sound component to play a 400 Hz tone (the real experiment uses wav files, but the demonstration breaks even with just a tone). The second routine uses a Microphone component to record the participant’s response (ideally this should be mono, 44.1 kHz or 48 kHz). If both components are active, the experiment crashes at launch. If either component is disabled for testing, the experiment runs and either plays sound or records sound as expected. The Microphone demo with whisper transcription enabled works on these machines. We have tried this with two usb audio interfaces: a Steinberg UR-22 and a MOTU M6 and both crash. We’re using the ptb audio library. Results are the same regardless of latency level in psychopy settings. He has also tested this experiment on Windows and it works there, but we don’t have Windows on the lab machines.
Here is what I believe to be the relevant part of the error message when both components are enabled:
self.handle = PsychPortAudio('Open', device_id, mode,
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Exception ignored in: <function Stream.__del__ at 0x7fcb4841b5e0>
PTB-ERROR: Seems the requested audio sample rate 48000.000000 Hz is not supported by this combo of hardware and sound driver.
PTB-ERROR: On Linux you may be able to use ALSA audio converter plugins to make this work.
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]);
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Invalid sample rate
PTB-ERROR: Seems the requested audio sample rate 48000.000000 Hz is not supported by this combo of hardware and sound driver.
PTB-ERROR: On Linux you may be able to use ALSA audio converter plugins to make this work.
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]);
5.8595 WARNING Could not find exact match for specified parameters (index=0, sampleRateHz=44100, channels=None), falling back to best approximation (index=0, sampleRateHz=44100, channels=2)
The Microphone component is configured to capture at 44.1 kHz mono (changing to auto or stereo results in the same error). Changing it to 48 kHz (on the suspicion that the Sound component is opening a portaudio connection at 48 kHz) still crashes. I can’t find anywhere at all in this experiment or in the psychopy preferences or Ubuntu settings where 48 kHz is being requested or configured, but I can verify that on this machine, with these hardware interfaces, the program Audacity can record 44.1 kHz and 48 kHz either mono or stereo (signal only on the left channel because it’s a mono mic) when configured to the same portaudio device we’re specifying in PsychoPy preferences.
Does anyone have any suggestions for getting sound playback and recording (non-simultaneous) working in a single Psychopy experiment running on Ubuntu? Perhaps the problem is that we’re using the ptb driver? Any advice greatly appreciated!
I’m attaching the demonstration experiment that crashes on our Ubuntu 22.04 lab machines.
sound_mic.psyexp (18.9 KB)