Hi all, I can’t seem to solve an issue with PsychoPy being unable to locate .wav files despite my best effort.
I have a complex design and I need to set up my audio component using code. I used this:
if speaker_cond == 'cond1':
sounds.setSound('s/' + str(custom_variable1) + '_' + str(custom_variable2) + '.wav')
elif speaker_cond == 'cond2':
sounds.setSound('s/' + str(custom_variable3) + '_' + str(custom_variable4) + '.wav')
else:
sounds.setSound('s/' + str(custom_variable5) + '_' + str(custom_variable6) + '.wav')
I use the same coding to set up custom pictures and it works perfect. The sound, however, does not. It give me this error:
Traceback (most recent call last):
Hello from the pygame community. https://www.pygame.org/contribute.html
2.2848 WARNING C:\Users\User\AppData\Roaming\psychopy3\fonts\Helvetica.truetype doesn't have valid font family name
File "C:\Users\User\OneDrive\Desktop\TEST\WK_test_lastrun.py", line 3073, in <module>
sounds.setSound('', secs=3, hamming=True)
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 426, in setSound
_SoundBase.setSound(self, value, secs, octave, hamming, log)
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\_base.py", line 198, in setSound
raise ValueError(msg + value)
ValueError: setSound: could not find a sound file named
################ Experiment ended with exit code 1 [pid:10684] #################
I know the code is complex and I tried doing this to check if it works:
if speaker_cond == 'cond1':
sounds.setSound('s/native1_1.wav')
elif speaker_cond == 'cond2':
sounds.setSound('s/native2_1.wav')
else:
sounds.setSound('s/foreign1_1.wav')
Same error.
I tried even this:
sounds.setSound('s/native2_1.wav')
Same error again. All my files have the same sample rate (48000) as does my audio equipment. The only way it works is when I put the same file name in the sound component like this
or through a column is my datafile with file pathes. I tried leaving the component like this in hope that my code will override it but nope. It would be the same sound playing over and over in that case.
I am really at my wit’s ends and I can’t, unfortunately, do it just through GUI – I have to use code.
Does anyone have any ideas why it happens?