Skip to content Skip to sidebar Skip to footer

Speech Recognition Python Stopped In Listen

I am running the following code in Python 2.7 with pyAudio installed. I use this tutorial. import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source:

Solution 1:

I am not 100% sure but I think I had this problem a while back and it could be something to do with the microphone source. You can fix it by...

change all instances of Microphone() to Microphone(device_index=MICROPHONE_INDEX), where MICROPHONE_INDEX is the hardware-specific index of the microphone

To figure out what the value of MICROPHONE_INDEX should be, run the following code:

import speech_recognition as sr
for index, name inenumerate(sr.Microphone.list_microphone_names()):
    print("Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name))

This will print out something like the following:

Microphonewith name "HDA Intel HDMI: 0 (hw:0,3)" found for`Microphone(device_index=0)`Microphonewith name "HDA Intel HDMI: 1 (hw:0,7)" found for`Microphone(device_index=1)`Microphonewith name "HDA Intel HDMI: 2 (hw:0,8)" found for`Microphone(device_index=2)`Microphonewith name "Blue Snowball: USB Audio (hw:1,0)" found for`Microphone(device_index=3)`Microphonewith name "hdmi" found for`Microphone(device_index=4)`Microphonewith name "pulse" found for`Microphone(device_index=5)`Microphonewith name "default" found for`Microphone(device_index=6)`

Now, for example, to use the Snowball microphone, you would change Microphone() to Microphone(device_index=3).

I hope this helped :)

Post a Comment for "Speech Recognition Python Stopped In Listen"