12666727b9
12666727b9

Reputation: 1127

How to make sound read by PsychoPy

I'm trying to figuring the problem out I'm facing with PsychoPy. When I try to upload this file

enter image description here

that actually is a .svp file I get this error:

RuntimeError: Error opening 'audio_track.svp': File contains data in an unknown format.
##### Experiment ended. #####

while when I try uploading this `file `.wav

psychopy.exceptions.SoundFormatError: Tried to create audio stream 32000_2_128 but 44100_2_128 already exists and win32 doesn't support multiple portaudio streams
##### Experiment ended. #####

Can anyone could know a possible solution to fix this out. Thanks in advance

Upvotes: 1

Views: 605

Answers (2)

Ehsan88
Ehsan88

Reputation: 3781

In my experience when you run PsychoPy in Windows (I have tested this with the version 3.0.0b), the most compatible sampling rate of a sound file is 44100.

The first solution I tried was a code that set the sound file in the first frame of the trial and it worked so it seemed like a bug. But it was a dirty workaround.

The second solution was converting all the files to 44100 sampling rate and the bug went away completely and I was able to use the sound element in the Builder with a variable sound file defined in the Excel conditions file.

One way of changing sampling of sound files in batch is ffmpeg:

for %a in (*.wav) do (ffmpeg -i "%a" -ar 44100 "44100\%~na.wav")

For the above script to work you have to create a 44100 subfolder in your sounds folder and run te above script in that directory.

Upvotes: 1

Jon
Jon

Reputation: 1223

From the error message I believe the sound file you've used here has a sampling rate of 32000 Hz, but you have another sound in your project sampled at 48000 Hz. Switching between sample rates is called resampling but resampling takes time. PsychoPy is designed to provide low-latency playback of sounds but to do this it will not perform any resampling for you. As a result, you should convert all your sounds to use the same sampling rate before the study runs using some audio software

Upvotes: 1

Related Questions