Sound component not working

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 (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
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.

and I do not have any microphone component

Check the bit rate of your audio files.

file_path= ‘A.wav’;
audio_info = audioinfo(file_path);
bit_rate = audio_info.TotalSamplesaudio_info.BitsPerSampleaudio_info.NumChannels
disp(['Bit rate: ’ num2str(bit_rate) ‘bits per second’]);
Bit rate: 384000bits per second

Fs = 48000 Hz

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. 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 !