| Reference | Downloads | Github

Unable to play sounds


Hello everyone,
I am unable to use sounds in psychopy. I tried different types of soundfiles (.wav .ogg) and always get the same error:

Running: C:\Users\csaq9291\Desktop\test_experiment\

pyo version 0.8.0 (uses single precision)
103.5131 WARNING psychopy.sound.initPyo could not find microphone hardware; recording not available
Traceback (most recent call last):
File “C:\Users\csaq9291\Desktop\test_experiment\”, line 69, in
phonealarmogg = sound.Sound(u’C:\Users\csaq9291\Desktop\test_experiment\phonealarm.ogg’, secs=-1)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\”, line 701, in init
self.setSound(value=value, secs=secs, octave=octave, hamming=hamming)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\”, line 166, in setSound
raise ValueError, msg + value
ValueError: setSound: could not find a sound file named C:\Users\csaq9291\Desktop\test_experiment\phonealarm.ogg

I made sure the experiment is saved in the same folder as the sound. I tried giving the full path and the closest path from the folder the experiment is saved in.

thankful for any piece of advice


Either you don’t actually have a sound file at C:\Users\csaq9291\Desktop\test_experiment\phonealarm.ogg or the backslashes are causing a problem.

Windows is unusual in using backslashes as path separators. In most programming languages (including Python), since time immemorial, backslashes indicate the start of an escape sequence. The simplest solution is to use forward slashes instead, which also has the advantage of allowing cross-platform paths to be specified.

Lastly, avoid using absolute paths (those starting at the root of your drive, C: in this case). Instead, just use paths that are relative to your Builder .psyxep file. PsychoPy will start looking for files in the folder where that file resides, so in this case, you could likely just use the name of the sound file itself, or if you want to tidy them away in a sub-folder, use something like sounds/phonealarm.wav (note the forward slash).


Thank you for your quick answer. i found the problem. windows hid the data specification at the end of the file so i had to add that manually and it worked thanks again!!!