psychopy.org | Reference | Downloads | Github

PsychoPy crashes when finding sound files

OS Win10
PsychoPy version 1.84.x
Standard Standalone? Yes
What are you trying to achieve?:

I am trying play sentence-length recordings (.wav files) from an Excel file that also has information about correct answer (binary choice), word order, language, etc.

What did you try to make it work?:

I have the recorded stimuli in my “Experiment” folder (where everything is being pulled from). I have tried placing these items on the desktop, unsorted in the “Experiment” folder, and in an “AudioFiles” subfolder within “Experiments”. Depending on where the sound files were located, I updated an Excel spreadsheet with their location (e.g. Experiment\AudioFiles\luxWOi1.wav ) under the column heading “LuxStim”.

I then inserted a routine into the Builder labeled LuxAud with a sound component and a keyboard component. To get the sound I want, I have the “sound” set to “$LuxStim” and chose “set every repeat”. I then added a loop around this routine with loopType = random, nReps $ = 1, and conditions = LuxAudSentences.xlsx (my Excel spreadsheet with my 4 parameters, including the “LuxStim” condition).

What specifically went wrong?

When I run the experiment, the text/keyboard components leading up to the sound portion work fine (and a made-up experiment with only these also works (even when the text is pulled from an Excel spreadsheet)). When it gets to the part that should play audio, the experiment crashes and yields the following:

Running: C:\Users\Hoffman…\ExperimentOutline_lastrun.py
pyo version 0.8.0 (uses single precision)
Traceback (most recent call last):
File “C:\Users\Hoffman…_lastrun.py”, line 504, in
sound_1.setSound(LuxStim, secs=-1)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\sound.py”, line 166, in setSound
raise ValueError, msg = value
ValueError: setSound: could not find a sound file named Experiment\luxWOp2.wav

Sorry if this is a noob-ish question. Any insights would be greatly appreciated.

Hi. Windows uses \ as a path separator, but in the rest of the known universe, the \ character indicates the start of an escape sequence. This can sometimes cause a problem, depending on what character follows the \ .

Try using forward slashes (i.e. /) in your paths instead.

But I suspect the problem may actually be (or also be) the relative path you are using. The paths to files are relative to the location of your .psyexp file. It seems unlikely that you have a sub-folder called Experiment in that folder?

Hi there,

This might sound silly but it looks as though your sound files are saved in the following path:

“Experiment\AudioFiles\luxWOi1.wav”

But based on the error message your script is searching for the file in

“Experiment\luxWOi1.wav”

Try double checking your paths match ?(although based upon your description it looks as though your paths are ok! - try using the full path to check?)

The golden rule with these kind of things is to let python handle system-specific properties, like path separator! Beside double-cheking your paths, you should use os.path.join() to locate your sounds. It will look like:

luxStim = os.path.join(os.getcwd(), “Experiment”, “AudioFiles”, “luxWOi1.wav”)

This assumes os.getcwd() returns the path where your .psyexp file is located!

Also, you should really update pyo to 0.8.5, lot of bugs are fixed, especially on Windows! If you can’t, be sure to select the right audio devices, (WASAPI in almost every cases). Version 0.8.5 chooses it for you.

Regards,