Error sound -portaudio

I am using windows 11, in psychopy 2023.2.3 with python 3.8.10.

When I play my experimento, the follow error appear:

running subject: ki
on condition: 3R6E-A
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):
PTB-ERROR: Desired audio parameters likely unsupported by audio device.
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
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: Failed to open audio device -1. PortAudio reports this error: Invalid device
PTB-ERROR: Desired audio parameters likely unsupported by audio device.
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
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]);
11.1589 WARNING Attempting to import psychopy.microphone. Note that this library is deprecated for the purpose of audio capture, but may still provide other useful functionality. Use psychopy.sound.microphone for audio capture instead.
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\susan\OneDrive\Área de Trabalho\experiment2\run-exp.py”, line 366, in
exp = InconInputExperiment()
File “C:\Users\susan\OneDrive\Área de Trabalho\experiment2\run-exp.py”, line 127, in init
self.word = sound.Sound(value = ‘sounds/gentif.wav’, sampleRate = 44100)
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 0x00000202D654A280>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 236, in del
self.close()
11.1593 WARNING Monitor specification not found. Creating a temporary one…
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:24476] #################

How can I solve this error?
Thank you so much for your help

Hello,

I hope you can help me,

I am trying to runnig a experiment in my windows computador and psychopy show the next issue:

Running: C:\Users\susan\OneDrive\Área de Trabalho\experiment2\run-exp.py

running subject: ki
on condition: 3R6E-A
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):
PTB-ERROR: Desired audio parameters likely unsupported by audio device.
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
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: Failed to open audio device -1. PortAudio reports this error: Invalid device
PTB-ERROR: Desired audio parameters likely unsupported by audio device.
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
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]);
11.1589 WARNING Attempting to import psychopy.microphone. Note that this library is deprecated for the purpose of audio capture, but may still provide other useful functionality. Use psychopy.sound.microphone for audio capture instead.
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\susan\OneDrive\Área de Trabalho\experiment2\run-exp.py”, line 366, in
exp = InconInputExperiment()
File “C:\Users\susan\OneDrive\Área de Trabalho\experiment2\run-exp.py”, line 127, in init
self.word = sound.Sound(value = ‘sounds/gentif.wav’, sampleRate = 44100)
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 0x00000202D654A280>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 236, in del
self.close()
11.1593 WARNING Monitor specification not found. Creating a temporary one…
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:24476] #################

What can I do to solve it?

Thank you so much for your help

If you have a microphone component, try increasing the bit rate to DVD.

Thanks for your help.
But Can I do that in the coder mode? or only in builder?

I’m sure it can be done in coder, but I only know how to do it in Builder. What code are you using to create your microphone component?