pythonaudioerror-handlingpsychopy

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


Solution

  • 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.