简体   繁体   English

pyaudio OSError: [Errno - 9999] 意外的主机错误

[英]pyaudio OSError: [Errno - 9999] Unanticipated host error

I'm trying to use the microphone of my webcam logitech to listen我正在尝试使用我的网络摄像头罗技的麦克风收听

with sr.Microphone(sample_rate=32000) as source:
...

This error occurs :发生此错误:

File "/home/pi/project2/interface.py", line 226, in listen with sr.Microphone(sample_rate = 32000) as source: File "/usr/local/lib/python3.4/dist-packages/speech_recognition/ init .py", line 140, in enter input=True, # stream is an input stream File "/usr/local/lib/python3.4/dist-packages/PyAudio-0.2.10-py3.4-linux-armv7l.egg/pyaudio.py", line 750, in open stream = Stream(self, *args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/PyAudio-0.2.10-py3.4-linux-armv7l.egg/pyaudio.py", line 441, in init self._stream = pa.open(**arguments) OSError: [Errno -9999] Unanticipated host error文件“/home/pi/project2/interface.py”,第 226 行,以 sr.Microphone(sample_rate = 32000) 作为源:文件“/usr/local/lib/python3.4/dist-packages/speech_recognition/ init .py", line 140, in enter input=True, # stream is a input stream File "/usr/local/lib/python3.4/dist-packages/PyAudio-0.2.10-py3.4-linux-armv7l .egg/pyaudio.py", line 750, in open stream = Stream(self, *args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/PyAudio-0.2.10-py3 .4-linux-armv7l.egg/pyaudio.py", line 441, in init self._stream = pa.open(**arguments) OSError: [Errno -9999] 意外的主机错误

I didn't find any fitting information on the web我在网上没有找到任何合适的信息

You may check your anti-virus SW.您可以检查您的防病毒软件。 I got the same problem "OSError: [Errno - 9999] Unanticipated host error" every time I tried to record the wave file by pyAudio.每次我尝试通过 pyAudio 录制波形文件时,我都会遇到同样的问题“OSError: [Errno - 9999] Unexpected host error”。 I check and confirm all the parameters OK.我检查并确认所有参数OK。 I was stuck for several days before I noticed the anti-virus on my PC block my python script call to the hardware level.在我注意到 PC 上的防病毒软件阻止了我对硬件级别的 python 脚本调用之前,我被困了好几天。

All the thing I need to do is disable or exit the anti-virus SW and everything work well again.我需要做的就是禁用或退出防病毒软件,然后一切正常。

I got this error while working with python threads.我在使用 python 线程时遇到了这个错误。

I was creating 2 pyaudio objects for different purposes and hadn't closed one of them later.我为不同的目的创建了 2 个pyaudio对象,后来没有关闭其中一个。 This gave me the error:这给了我错误:

[Errno - 9999] Unanticipated host error [Errno - 9999] 意外的主机错误

Closing that thread fixed my issue.关闭该线程解决了我的问题。

It may be a problem with microphone permission for your app make sure you have enabled the microphone permission for all apps in settings.您的应用程序的麦克风权限可能有问题,请确保您已在设置中为所有应用程序启用麦克风权限。 because have developed one Tkinter project in which I am using pyaudio for recording purpose.因为开发了一个 Tkinter 项目,我在其中使用 pyaudio 进行录音。 On my pc the recorder working fine but not on the client machine.在我的电脑上,录音机工作正常,但在客户端机器上却没有。 after investigation and running the same script on client machin it gives the same error as you mention.经过调查并在客户端机器上运行相同的脚本后,它给出了与您提到的相同的错误。 but after giving permission of a microphone for my project it working fine.但是在为我的项目授予麦克风许可后,它工作正常。 pyaudio throws this error because the python script not able to use the mic hardware. pyaudio 抛出此错误是因为 python 脚本无法使用麦克风硬件。 I hope you will get some clarity with this and my answer may help you.我希望你能对此有所了解,我的回答可能会对你有所帮助。

Windows user here. Windows 用户在这里。 For me, I just had to change the default microphone which was being changed every time I connected my headphones.对我来说,我只需要更改每次连接耳机时都会更改的默认麦克风。

This might also happen if there is no microphone access to the program or the microphone is not working properly.如果没有麦克风访问程序或麦克风工作不正常,也可能发生这种情况。 To check if the microphone is working properly, try recording some audio in voice recorder, and see if the selected microphone is the default audio recording device.要检查麦克风是否正常工作,请尝试在录音机中录制一些音频,然后查看所选麦克风是否为默认录音设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM