OSError: No Default Input Device Available

后端 未结 2 1369
Happy的楠姐
Happy的楠姐 2020-12-20 20:51

I am trying speech recognition with SpeechRecognition package in python and facing problem when trying to work with microphone.

I tested Microphone of my earphones ,

相关标签:
2条回答
  • 2020-12-20 21:35

    At first(as for Linux users), check the following link and update your Pyaudio & Portaudio with the given repository, since there is a bug in Anaconda's Pyaudio and Portaudio library.

    Now if it worked, but the terminal is stuck on "Speak anything..", then it means that the library is detecting too many noises, and you can filter them out by adding the following line after the with statement.

    r.adjust_for_ambient_noise(source)
    

    For example:

    with sr.Microphone(device_index=2) as source:
        r.adjust_for_ambient_noise(source)
        print("Speak Anything :")
        audio = r.listen(source)
    

    Please note the r here is the instance of speech_recognition.Microphone().

    Also, I recommend you start passing the index of the the device you want to use like I did in the above example (like this device_index=2), and you could try using an index with range of 0 to 4 (could be more or less, depends on how many inputs you have).

    0 讨论(0)
  • 2020-12-20 21:38

    Use the below command. I solved this issue following this

    conda install nwani::portaudio nwani::pyaudio

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