spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
980 stars 145 forks source link

Error opening InputStream: Unanticipated host error #456

Closed v-yunbin closed 1 year ago

v-yunbin commented 1 year ago

There was no problem with it before, but now there is a sudden problem with it.

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    recording = sd.rec(frames=fs * length, samplerate=fs, blocking=True, channels=1)
  File "D:\ProgramData\Miniconda3\lib\site-packages\sounddevice.py", line 223, in rec
    ctx.start_stream(InputStream, samplerate, ctx.input_channels,
  File "D:\ProgramData\Miniconda3\lib\site-packages\sounddevice.py", line 2412, in start_stream
    self.stream = StreamClass(samplerate=samplerate,
  File "D:\ProgramData\Miniconda3\lib\site-packages\sounddevice.py", line 1300, in __init__
    _StreamBase.__init__(self, kind='input', wrap_callback='array',
  File "D:\ProgramData\Miniconda3\lib\site-packages\sounddevice.py", line 777, in __init__
    _check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
  File "D:\ProgramData\Miniconda3\lib\site-packages\sounddevice.py", line 2570, in _check
    raise PortAudioError(errormsg, err, hosterror_info)
sounddevice.PortAudioError: Error opening InputStream: Unanticipated host error [PaErrorCode -9999]: '无效的参数被传递给一个系统功能。' [MME error 11]
v-yunbin commented 1 year ago

All microphone permissions are turned on image

mgeier commented 1 year ago

The error comes from the underlying PortAudio library, which in turn gets it from the MME backend, I guess.

According to Google Translate, the error message means: "An invalid argument was passed to a system function".

I don't know what that could mean ... what's the value of fs?

v-yunbin commented 1 year ago

@mgeier fs means samlerate.

v-yunbin commented 1 year ago

that is because antivirus software stopped it , I close it.