psychopy.org | Reference | Downloads | Github

Problem playing sounds: it doesn't play my variable, but rather the default sound? ('A')

sound

#1

OS: Windows 10
PsychoPy version: 1.90.3

I’m trying to display words and corresponding sounds (sounds are in .wav format). These words and sounds are picked from a conditions file (.xlsx). The conditions file has two columns: worditem_listen and wordsound_listen.

In the text component, under ‘Text’ I input the item variable: $worditem_listen
In the sound component, under ‘Sound’ I input the sound variable: $wordsound_listen
I put a loop around the trial, wherein I specify the conditions file.
In both components (text and sound) I put the variable to ‘set every repeat’.

When I run the experiment, it displays my words correctly (i.e. it displays the words that are in my conditions file). However, it does not play the audio: it plays a continuous beep (it is continuous because I have set the duration field to blank, as I want it to just play the length of the audio file).
Note: there is no error message.

I’ve tried changing the file extension of the sound, I’ve quadruple checked the spelling, I’ve tried putting in the full path instead of a relative path, I’ve tried changing the direction of the slash, I’ve tried… many things.
However, finally I just went into the code to see what was happening. When I compile my code, this is what I find (relevant bit only):

# update component parameters for each repeat
listen_text.setText(worditem_listen)
listen_sound.setSound('A')

As you can see, it’s correctly identified my variable $worditem_listen as the variable to call upon when displaying text. However, my variable for sound ($wordsound_listen) has somehow disappeared/not made it to the compile stage, and instead is replaced by the default ‘A’.

Indeed, when I change ‘A’ to wordsound_listen and then run from the code, it plays a sound from my variable list, but then I have the problem that the trial doesn’t end (this is fixed by putting in a fixed time for this variable, e.g. sec=1 - not ideal either).

Any idea why this is happening? I realise that I’ve technically fixed it, but I’d prefer it to just work from the builder if possible!

Many thanks in advance for your help!


#2

@annekoopman, sorry about your issue, however this has been fixed in the new version of PsychoPy. See

Rather than amending your code, I think you would be better off downloading the most recent release of PsychoPy found here.


#3

@dvbridges ah, I see! Thanks for letting me know, I will download the latest release then.


#4

Just a quick update for anyone who stumbles upon this thread and wonders whether it worked:

I updated to version 3.0.0b10, after which it did play my sounds but one of the sounds was cut off halfway through. Then I changed my audio library to pyo (file --> preferences --> audio library --> [‘pyo’,], and it has since worked fine.