| Reference | Downloads | Github

Playing sound files in Windows 7 Pro

Hi folks,

I use the Psychopy sound function in Spyder without issue on my Windows 10 PC at work.

However, I’ve yet to succeed using it on my Windows 7 Pro PC at home.

I’ve installed all dependencies (such as Pyo) and don’t receive any errors when attempting to run the following code:

from psychopy import sound

play_audio1 = sound.SoundPyo(value = ‘LRsound’, stereo = True)

The problem is that nothing happens. The kernel in Spyder just sits there as though it is running the script like this:

and I eventually have to manually kill it.

I’ve tried playing the same sound file using PyGame and it also doesn’t play but Spyder behaves as though the script has been run successfully and exits the process and opens a new kernel.

The sound does play successfully using pyglet and pyaudio.

I’m at a complete loss as what to try next. I do a lot of work from home so you can image how frustrating this is.

Any help or insight on this issue would be great and very much appreciated.

Thanks for your time.

Could you install PsychoPy Standalone and try form there instead of Spyder?
I don’t know if this is a problem on your machine or a problem with anaconda install of pyo (which I don’t personally support) or a problem with running from spyder (which I don’t personally support).

Hi Jon,

Thanks for your response.

I finally got around to trying out what you suggested: PsychoPy Standalone also does not play the sound file either.

It returns the following screen:

Sorry, I still don’t have any idea. If Pyo fails it usually provides an error message. One thing that’s strange is that your sound “LRsound” appears not to have an extension (like .wav). Are you sure that the file is being found at all? It looks like you’ve also got no .py extension on your script which is not a good idea either, but I don’t think that’s your problem with the sound not playing.

You could increase the amount of info you get about what’s happening by stting psychopy’s logging to debug level and make sure you have a pause so that the sound can play.

from psychopy import sound, logging, core

play_audio1 = sound.SoundPyo(value = 'LRsound', stereo = True)
core.wait(5) # wait so the sound can play

Hi Jon,

When running your script from above I get the following errors:

Server not booted.
The Server must be booted!
portaudio error in Pa_OpenStream: Illegal combination of I/O devices
Portaudio error: Illegal combination of I/O devicesportaudio error in Pa_AbortStream: PortAudio not initialized
portaudio error in Pa_CloseStream: PortAudio not initialized
portaudio error in Pa_Terminate: PortAudio not initialized

I am using stereo speakers for my sound output, in case that is useful information.

Thanks again.

According to google this is something to do with duplex audio streams, but it's all in the pyo library the portaudio lib that sits behinds that (not my expertise). It's going to be something along the lines of trying to create an input (mic) and an output (speakers) that have incompatible drivers and so don't work together.

I think the pyo library has commands to find out what the available input and output devices are and to tell you what the default devices are too. That might help work out what's wrong.

I’ve tried everything suggested that I could find on Google to fix the Pyo issue without success.

In the end I did the following:

from psychopy import prefs
prefs.general[‘audioLib’] = [‘pygame’]

sound.Sound(value = soundfile)

The equivalent for Pyo doesn’t work but I’m happy enough to use pygame to play the sound. I’ll just avoid pyo in future.

Thanks for your time Jon and thanks for developing PsychoPy, it’s wonderful.

NOTE: I also reverted back to Python 2.7.8 from Python 2.7.12 but I doubt that had any influence on the outcome since pyo still isn’t playing ball.