python-sounddevice: sounddevice.PortAudioError: Error opening InputStream: Device unavailable [PaErrorCode -9985]
When trying to record, I use the line
myrecording = sd.rec(duration * fs, samplerate=fs, channels=2,dtype='float64')
This leads to
> Traceback (most recent call last):
File "sd_test.py", line 7, in <module>
myrecording = sd.rec(duration * fs, samplerate=fs, channels=2,dtype='float64')
File "C:\Users\gwerner004\AppData\Local\Programs\Python\Python36\lib\site-packages\sounddevice.py", line 224, in rec
ctx.input_dtype, callback, blocking, **kwargs)
File "C:\Users\gwerner004\AppData\Local\Programs\Python\Python36\lib\site-packages\sounddevice.py", line 2417, in start_stream
**kwargs)
File "C:\Users\gwerner004\AppData\Local\Programs\Python\Python36\lib\site-packages\sounddevice.py", line 1301, in __init__
**_remove_self(locals()))
File "C:\Users\gwerner004\AppData\Local\Programs\Python\Python36\lib\site-packages\sounddevice.py", line 780, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "C:\Users\gwerner004\AppData\Local\Programs\Python\Python36\lib\site-packages\sounddevice.py", line 2572, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening InputStream: Device unavailable [PaErrorCode -9985]
When I do python -m sounddevice I get this line:
> 1 Microphone (Plantronics C320), MME (2 in, 0 out)
Why would this device not be available for recording?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 17 (5 by maintainers)
I resolved this by enabling
"Let apps access your microphone"in Windows 10/11. a setting inPrivacy & Security > MicrophoneThank you, @warrenarea I tried it and now the problem is solved.
I have this problem too