Import audio samples

OS (Win10)
PsychoPy version (v2023.2.3)

Hello I am a Master’s student currently developing my thesis on Cognitive/Musical Neuroscience. In my experiment I need to present different auditive stimuli to the participants and then perform some self-reports about emotional assessment. I have tried to import the audio files in different formats such as wav mp3 and aiff and I still get an error message about some combination of audio parameters.
Part of the error message appears as:
PsychPortAudio:Open: Usage:

pahandle = PsychPortAudio(‘Open’ [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);
PTB-ERROR: Failed to open audio device -1. 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.

Anyone as any solutions? (Please not that I’m a coding newbie and I am currently using the non coding part of the PsychoPy)


Your audio files may have been recorded at a sampling rate that is not supported by the device you are addressing.

Best wishes Jens

Try the mp3 format. It should work. I edited all my audio files using the Audition program and it runs perfectly online.

Hi! Thanks for your answer. How can I see/change the sampling rate? I can listen to the audio files outside of PsychoPy.

I tried the mp3 format already. It says the file is in an unknown format:

RuntimeError: Error opening ‘C:/Users/Guilherme Borges/Downloads/sad-emotional-and-dramatic-piano-136898.mp3’: File contains data in an unknown format.

Audacity is free software you can use to edit sound files.