Search code examples
pythonaudiopygamespyderpsychopy

Playing sound in Python using Psychopy and or PyGame


I have installed all dependencies (such as pyo) for PsychoPy sound and get no errors when attempting to play a sound file (.wav).

On my Windows 10 PC at work Spyder plays the file without issue. On my Windows 7 Pro PC at home this happens:

enter image description here

No information about what is going wrong is given. It simply sits there doing nothing. Any ideas what is happening?

Thanks for your time.

EDIT:

Something similar happens when trying to play a sound file using pygame. However, it simply runs the code and starts a new kernel without the file being played or an error report. Could this be a problem with Pyo or a driver issue?


Solution

  • I eventually gave up on the pyo library and successfully managed to play sound in PsychoPy using PyGame by doing the following BEFORE calling sound from psychopy:

    from psychopy import prefs
    prefs.general['audioLib'] = ['pygame']
    

    ...

    sound.Sound(value = soundfile)
    

    I've found Pyo to be a nightmare when using Windows 7 Pro. Hopefully this work around with PyGame will come in useful.