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

后端 未结 4 1574
执笔经年
执笔经年 2020-12-19 10:39

I just want to run a simple python audio code:

import pyaudio
import wave
import sys

CHUNK = 1024
wf = wave.open(\"4.wav\", \'rb\')
# instantiate PyAudio (1         


        
相关标签:
4条回答
  • 2020-12-19 10:45

    You need to collect additional information to understand the problem. From Portaudio docs:

    PortAudio usually tries to translate error conditions into portable PaError error codes. However if an unexpected error is encountered the paUnanticipatedHostError code may be returned. In this case a further mechanism is provided to query for Host API-specific error information. If PortAudio returns paUnanticipatedHostError you can call Pa_GetLastHostErrorInfo() to retrieve a pointer to a PaHostErrorInfo structure that provides more information, including the Host API that encountered the error, a native API error code and error text.

    If you have this error on Linux, most likely it is caused by incompatible sample rate you are trying to request from the driver. This value

                rate=wf.getframerate()
    

    can be changed to 16000, 44100 and 48000 to test which rate is actually supported.

    0 讨论(0)
  • 2020-12-19 10:46

    I had same problem so i just give allow permission to microphone from setting and its work just go to setting --> Privacy --> Microphone then give the persmission to mic means on the microphone

    0 讨论(0)
  • 2020-12-19 11:04

    If you are using windows 10 search for microphone privacy settings

    0 讨论(0)
  • 2020-12-19 11:09

    I had the same problem, and I fix it just by enable/disable the access to the microphone in Setting>Confidentiality>Microphone (on Windows 10)

    0 讨论(0)
提交回复
热议问题