OSError: No Default Input Device Available

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).

Leave a Comment