# Sound component not working

**URL:** <https://discourse.psychopy.org/t/sound-component-not-working/38666>\
**Category:** Builder\
**Tags:** sound\
**Created:** [February 15, 2024, 3:48pm UTC](https://discourse.psychopy.org/t/sound-component-not-working/38666 "2024-02-15T15:48:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shruthi](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shruthi](https://discourse.psychopy.org/u/Shruthi)\
**Post date:** [February 15, 2024, 3:48pm UTC](https://discourse.psychopy.org/t/sound-component-not-working/38666/1 "2024-02-15T15:48:37Z")

</div>

If this template helps then use it. If not then just delete and start from scratch.

Win10  
PsychoPy version 2023.2.3  
Standard Standalone? (yes)

I wanted to set up an experiment to play a bunch of tones, audio files etc.  
I am attaching my PsychoPy project, it has a start message, a sound component and an end message.  
[test.psyexp](https://discourse.psychopy.org/uploads/short-url/ijziRfXZ4KK8YgHZGDifIuh1t7q.psyexp) (13.7 KB)

The same experiment is working on MAC OS. Changing different Audio Library and Input on Properties did not help.

The experiment screen pops up saying “Attempting to measure frame rate of screen, please wait..” and then it either disappear or becomes unresponsive with below error message.

#### Running: C:\Users\SRaghavendra\Downloads\Psychopy\test\test\_lastrun.py

639.3613 INFO Loaded monitor calibration from [‘2024\_02\_13 10:50’]  
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)  
Hello from the pygame community. [Contribute - pygame wiki](https://www.pygame.org/contribute.html)  
PTB-ERROR: Failed to open audio device -1. PortAudio reports this error: Invalid device  
Traceback (most recent call last):  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 227, in **init**  
audio.Stream. **init** (self, device\_id=deviceID, mode=mode+8,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 97, in **init**  
self.handle = PsychPortAudio(‘Open’, device\_id, mode,  
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “C:\Users\SRaghavendra\Downloads\Psychopy\test\test\_lastrun.py”, line 720, in   
run(  
File “C:\Users\SRaghavendra\Downloads\Psychopy\test\test\_lastrun.py”, line 327, in run  
sound\_1 = sound.Sound(‘C:/Users/SRaghavendra/Downloads/Psychopy/test/A.wav’, secs=0.5, stereo=True, hamming=True,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 332, in **init**  
self.setSound(value, secs=self.secs, octave=self.octave,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 440, in setSound  
\_SoundBase.setSound(self, value, secs, octave, hamming, log)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\_base.py”, line 185, in setSound  
self.\_setSndFromFile(p)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 476, in \_setSndFromFile  
self.\_setSndFromArray(sndArr)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 515, in \_setSndFromArray  
self.track = audio.Slave(self.stream.handle, data=self.sndArr,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 618, in stream  
label, s = streams.getStream(sampleRate=self.sampleRate,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 140, in getStream  
return self.\_getStream(sampleRate,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 187, in \_getStream  
self[label] = \_MasterStream(sampleRate, channels, blockSize,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 248, in **init**  
audio.Stream. **init** (self, mode=mode+8,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 97, in **init**  
self.handle = PsychPortAudio(‘Open’, device\_id, mode,  
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.  
Exception ignored in: \<function Stream. **del** at 0x000002A92351C5E0\>  
Traceback (most recent call last):  
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 236, in **del**  
self.close()  
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 146, in close  
raise err  
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 139, in close  
PsychPortAudio(‘Close’, self.handle)  
AttributeError: ‘\_MasterStream’ object has no attribute ‘handle’  
################ Experiment ended with exit code 1 [pid:26724] #################  
657.3399 INFO Loaded monitor calibration from [‘2024\_02\_13 10:50’]

Please help !

**What are you trying to achieve?:**

**What did you try to make it work?:**

**What specifically went wrong when you tried that?:**  
Include pasted full error message if possible. “That didn’t work” is not enough information.

---

<div class="post-metadata">

**Author:** ![Shruthi](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shruthi](https://discourse.psychopy.org/u/Shruthi)\
**Post date:** [February 15, 2024, 8:27pm UTC](https://discourse.psychopy.org/t/sound-component-not-working/38666/2 "2024-02-15T20:27:01Z")

</div>

> [@Shruthi](#):
>
> self.handle = PsychPortAudio(‘Open’, device\_id, mode,  
> Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.

and I do not have any microphone component

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 15, 2024, 8:37pm UTC](https://discourse.psychopy.org/t/sound-component-not-working/38666/3 "2024-02-15T20:37:38Z")

</div>

Check the bit rate of your audio files.

> [@Playing audio files works on mac, but not on windows 10](https://discourse.psychopy.org/t/playing-audio-files-works-on-mac-but-not-on-windows-10/34490/6):
>
> Right, where can I change the freq value? I’m using builder; I’ve checked in the experiment preferences and in psychopy’s preferences and can’t find anything immediately looking like it will help. The latency and driver are both working for another psychopy experiment running on the same computer, so it seems like it’s an issue with this experiment specifically (and I’d rather not “fix” global settings for psychopy that would cause problems for the other people in my lab whose experiments a…

> [@Audio sample rate 16000.000000 Hz is not supported by hardware and sound driver](https://discourse.psychopy.org/t/audio-sample-rate-16000-000000-hz-is-not-supported-by-hardware-and-sound-driver/25997):
>
> OS (e.g. Win10): Windows 10 PsychoPy version (e.g. 1.84.x): 2021.2.3 \*\*Standard Standalone? : yes What are you trying to achieve?: I am trying to run an experiment that records participants’s voices as they say sentences corresponding to the images they see. The experiment was running fine locally when I was using the version 2020.2.10. I downloaded the new version 2021.2.3 and now I am stuck on an error that appears as soon as I start the experiment: PTB-ERROR: Desired audio parameters for…

---

<div class="post-metadata">

**Author:** ![Shruthi](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shruthi](https://discourse.psychopy.org/u/Shruthi)\
**Post date:** [February 15, 2024, 9:05pm UTC](https://discourse.psychopy.org/t/sound-component-not-working/38666/4 "2024-02-15T21:05:51Z")

</div>

> > file\_path= ‘A.wav’;  
> > audio\_info = audioinfo(file\_path);  
> > bit\_rate = audio\_info.TotalSamples_audio\_info.BitsPerSample_audio\_info.NumChannels  
> > disp(['Bit rate: ’ num2str(bit\_rate) ‘bits per second’]);  
> > Bit rate: 384000bits per second

Fs = 48000 Hz

---

<div class="post-metadata">

**Author:** ![Shruthi](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shruthi](https://discourse.psychopy.org/u/Shruthi)\
**Post date:** [February 16, 2024, 4:36pm UTC](https://discourse.psychopy.org/t/sound-component-not-working/38666/5 "2024-02-16T16:36:22Z")

</div>

I was able to play audio by doing some changes mentioned below using built-in Realtek speakers:

- I added coreaudio and portaudio to the audio drivers in the global psychopy settings (not deleting anything) and ordered them at the top of the list
- In the experiment settings, I changed the latency from “3: aggressive low-latency” to “2: exclusive low-latency”
- Also in the experiment settings, I changed the Input from IOHUB to Pyglet.

However, I want to play audio through Emotiv headset (EAR EEG earbuds), For this I am getting the below error and I am unable to play the audio through these earbuds:

#### Running: C:\Users\SRaghavendra\Downloads\Psychopy\test\test\_lastrun.py

536.5029 INFO Loaded monitor calibration from [‘2024\_02\_13 10:50’]  
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)  
Hello from the pygame community. [Contribute - pygame wiki](https://www.pygame.org/contribute.html)  
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Invalid sample rate  
Traceback (most recent call last):  
PTB-ERROR: Seems the requested audio sample rate 48000.000000 Hz is not supported by this combo of hardware and sound driver.  
Error in function Open: Usage error  
Failed to open PortAudio audio device due to unsupported combination of audio parameters.  
PsychPortAudio:Open: Usage:

pahandle = PsychPortAudio(‘Open’ [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);  
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Invalid sample rate  
PTB-ERROR: Seems the requested audio sample rate 48000.000000 Hz is not supported by this combo of hardware and sound driver.  
Error in function Open: Usage error  
Failed to open PortAudio audio device due to unsupported combination of audio parameters.  
PsychPortAudio:Open: Usage:

pahandle = PsychPortAudio(‘Open’ [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 227, in **init**  
audio.Stream. **init** (self, device\_id=deviceID, mode=mode+8,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 97, in **init**  
self.handle = PsychPortAudio(‘Open’, device\_id, mode,  
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “C:\Users\SRaghavendra\Downloads\Psychopy\test\test\_lastrun.py”, line 826, in   
run(  
File “C:\Users\SRaghavendra\Downloads\Psychopy\test\test\_lastrun.py”, line 322, in run  
sound\_1 = sound.Sound(‘A’, secs=0.5, stereo=True, hamming=True,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 332, in **init**  
self.setSound(value, secs=self.secs, octave=self.octave,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 440, in setSound  
\_SoundBase.setSound(self, value, secs, octave, hamming, log)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\_base.py”, line 168, in setSound  
self.\_setSndFromNote(value.capitalize(), secs, octave,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\_base.py”, line 207, in \_setSndFromNote  
self.\_setSndFromFreq(thisFreq, secs, hamming=hamming)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\_base.py”, line 223, in \_setSndFromFreq  
self.\_setSndFromArray(outArr)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 515, in \_setSndFromArray  
self.track = audio.Slave(self.stream.handle, data=self.sndArr,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 618, in stream  
label, s = streams.getStream(sampleRate=self.sampleRate,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 140, in getStream  
return self.\_getStream(sampleRate,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 187, in \_getStream  
self[label] = \_MasterStream(sampleRate, channels, blockSize,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend\_ptb.py”, line 248, in **init**  
audio.Stream. **init** (self, mode=mode+8,  
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 97, in **init**  
self.handle = PsychPortAudio(‘Open’, device\_id, mode,  
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.  
############ Experiment ended with exit code 3489660927 [pid:30252] ############  
597.8866 INFO Loaded monitor calibration from [‘2024\_02\_13 10:50’]  
Generating PsychoPy script…

Please help !

---

<div class="post-metadata">

**Author:** ![ali\_alsheikh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/ali_alsheikh/32/37578_2.png) [@ali\_alsheikh](https://discourse.psychopy.org/u/ali_alsheikh)\
**Post date:** [January 12, 2025, 1:08pm UTC](https://discourse.psychopy.org/t/sound-component-not-working/38666/6 "2025-01-12T13:08:07Z")

</div>

hello @Shruthi @wakecarter  
I’m reviving this discussion because I’m encountering a similar error and trying to find a solution. Here’s the error message I’m receiving:

vbnet

Copy code

```auto
Running: C:\Users\remy1\Desktop\tasks\task1\Task1_A-SSS-F_lastrun.py 
PTB-ERROR: Desired audio parameters for device 9 seem to be unsupported by audio device: Invalid sample rate

Traceback (most recent call last):
PTB-ERROR: Seems the requested audio sample rate 48000.000000 Hz is not supported by this combo of hardware and sound driver. Error in function Open: Usage error Failed to open PortAudio audio device due to unsupported combination of audio parameters. Prevalidation failure. 

PsychPortAudio:Open: Usage: 
pahandle = PsychPortAudio('Open' [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);

Traceback (most recent call last):
  File "C:\Users\remy1\Desktop\tasks\task1\Task1_A-SSS-F_lastrun.py", line 3405, in <module>
    setupDevices(expInfo=expInfo, thisExp=thisExp, win=win)
  File "C:\Users\remy1\Desktop\tasks\task1\Task1_A-SSS-F_lastrun.py", line 303, in setupDevices
    deviceManager.addDevice(
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\hardware\manager.py", line 253, in addDevice
    raise ManagedDeviceError(
psychopy.hardware.manager.ManagedDeviceError: Failed to open PortAudio audio device due to unsupported combination of audio parameters. Prevalidation failure. 

Exception ignored in: <function Stream. __del__ at 0x00000253915BC160>
Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 236, in __del__
    self.close()
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 146, in close
    raise err
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: 'Stream' object has no attribute 'handle'

```

The error seems to indicate an issue with the requested audio sample rate (`48000 Hz`) not being supported by the combination of my hardware and sound driver. I’m using a Creative Live! A3 sound card, and my experiment includes two microphone components, with all audio files set to 48 kHz.

Does anyone have insights into how to resolve this? Is it possible to force PsychoPy to use a different configuration, or is this a compatibility issue with PortAudio?

Thanks in advance for your help!
