# Experiment freezes (unresponsive) when using sound.Sound

**URL:** https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286
**Category:** Coding
**Created:** [October 14, 2016, 2:41pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286 "2016-10-14T14:41:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Steve1](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Steve1](https://discourse.psychopy.org/u/Steve1)
#### Post date: [October 14, 2016, 2:41pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/1 "2016-10-14T14:41:16Z")

</div>

Hello

For some very strange reason, my experiment won’t start (instantly freezes on black screen and goes to ‘not responding’) when I include the following bit of code. The line merely loads in a .wav file and assigns it to a variable. As soon as I comment it out, the script works perfectly fine.

> `warning_beep = sound.Sound("C:\Users\Eyelink User\Desktop\ocarina.wav")`

I’m stumped by this, I’ve never had this problem before and I have no idea how to fix it since it’s a very simple statement. I’m importing sound like this:

> from psychopy import visual, core, gui, event, sound

Does anyone have any ideas as to why this line causes my script to go unresponsive? I’m using the latest psychopy.

Update: I tried the same code at home on Psychopy version 1.83.01, and it worked with without any issues. I then installed the newest Psychopy version, and the code does run but I also get a console audio error message (below).

> portaudio error in Pa\_AbortStream: Unanticipated host error  
> Exception TypeError: “‘NoneType’ object is not callable” in \<bound method Server. **del** of \<pyolib.server.Server object at 0x149EA1B0\>\> ignored

When I remove the line ‘`warning\_beep = sound.Sound(“C:\Users\Eyelink User\Desktop\ocarina.,wav”)’, I no longer get the error message. Does the newest version have some audio issues?

Cheers,  
Steve

---

<div class="post-metadata">

### Author: ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)
#### Post date: [October 16, 2016, 4:35pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/2 "2016-10-16T16:35:05Z")

</div>

What settings do you have for your sound libraryin PsychoPy preferences?  
Does that portaudio error have more lines that you aren’t showing us here?

---

<div class="post-metadata">

### Author: ![Steve1](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Steve1](https://discourse.psychopy.org/u/Steve1)
#### Post date: [October 16, 2016, 6:12pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/3 "2016-10-16T18:12:55Z")

</div>

There are no other error messages other than the ones in my original post. At home, my settings are:

> Audio library: [‘pygame’,‘pyo’]  
> Audio driver: [‘Primary Sound’,‘ASIO’,‘Audigy’]  
> flac audio compression: empty

On the lab pc the code won’t run at all due to the inclusion of ‘warning\_beep = sound.Sound(“C:\Users\Eyelink User\Desktop\ocarina.wav”)’. I will go down and investigate tomorrow.

Happy to roll-back my psychopy of course, but just thought I would mention so you knew.

Update: Apologies, I ran it again and noticed this:

> WARNING pygame audio lib was requested but not loaded: No module named pygame

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/richard/32/6389_2.png) [@richard](https://discourse.psychopy.org/u/richard)
#### Post date: [October 18, 2016, 8:49pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/4 "2016-10-18T20:49:31Z")

</div>

> [@Steve1](#):
>
> `WARNING pygame audio lib was requested but not loaded: No module named pygame`

Is this the standalone version of PsychoPy? It should ship with a working copy of PyGame…

---

<div class="post-metadata">

### Author: ![rebeccajsharman](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/rebeccajsharman/32/1583_2.png) [@rebeccajsharman](https://discourse.psychopy.org/u/rebeccajsharman)
#### Post date: [January 11, 2017, 3:10pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/5 "2017-01-11T15:10:08Z")

</div>

For some reason PyGame isn’t being installed with the standalone. However, it can be downloaded here: [http://www.pygame.org/download.shtml](http://www.pygame.org/download.shtml) for the windows installer just change the installation folder to where you have PsychoPy installed and it will do the rest of the work for you.

I can confirm that changing from pyo to pygame resolves these weird problems of experiments crashing, freezing, sound not playing, etc. No idea what’s made pyo unhappy.

---

<div class="post-metadata">

### Author: ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)
#### Post date: [January 18, 2017, 5:31pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/6 "2017-01-18T17:31:57Z")

</div>

On OSX pygame is no longer included because the mac standalone versoin is now 64bit and I can’t find a 64bit version of pygame. It should still be included in windows though (maybe it was missed out at one point?)

With pyo it’s also hard to know but we’ve had lots of problems with that library and I’m keen to ditch it (pyo is the new pygame - a pain in my side). Hopefully the new `sounddevice` backend will fix the woes the way that `moviepy` did for movies

---

<div class="post-metadata">

### Author: ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)
#### Post date: [November 5, 2017, 10:02pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/7 "2017-11-05T22:02:06Z")

</div>

Hi All,

I have been having this same problem. However I need to use Pyo because Pygame doesn’t seem to let me play my sound below a certain level (think this is something I should report in another thread but any feedback would be great!). the error I get is:

“portaudio error in Pa\_AbortStream: Unanticipated host error”

any ideas how to fix this would be great - my settings are the same as those reported by Steve

---

<div class="post-metadata">

### Author: ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)
#### Post date: [November 9, 2017, 8:17pm UTC](https://discourse.psychopy.org/t/experiment-freezes-unresponsive-when-using-sound-sound/1286/8 "2017-11-09T20:17:33Z")

</div>

What version of PsychoPy do you have installed?  
Could you try sounddevice instead of either pyo or pygame? i.e. set your sound lib to be:

`['sounddevice','pygame','pyo']`

If that raises other probs then let us know but that’s the sound lib I’m most interested in fixing for the future
