4

Unable to use the SpeechRecognition lib in CoLAB.

Code:

import speech_recognition as sr
r = sr.Recognizer()

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

    try:
        text = r.recognize_google(audio)
        print("You said: {}".format(text))
    except:
        print('Wrong')

I pip installed the following:

!apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg
!pip install pyaudio
!pip install ConfigParser
!apt-get install python-gnuradio-audio-portaudio
!python -m pip install pyaudio
!pip install SpeechRecognition

ERROR Showing:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-34-65e65421018d> in <module>()
      4 r = sr.Recognizer()
      5 
----> 6 with sr.Microphone() as source:
      7     print("Speak Anything: ")
      8     audio = r.listen(source)

1 frames
/usr/local/lib/python3.6/dist-packages/pyaudio.py in get_default_input_device_info(self)
    947         """
    948 
--> 949         device_index = pa.get_default_input_device()
    950         return self.get_device_info_by_index(device_index)
    951 

OSError: No Default Input Device Available
-------------------------------------------------------------------------

FYI, I am using Google CoLAB for this. --Thanks in advance!

  • Does this answer your question? [“OSError: No Default Input Device Available” on Google Colab](https://stackoverflow.com/q/59013743/2745495) – Gino Mempin Feb 17 '21 at 12:21

0 Answers0