Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named SpeechRecognition

My code is

import SpeechRecognition as sr

# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)

# recognize speech using Microsoft Bing Voice Recognition
BING_KEY = "Somevalue"  # Microsoft Bing Voice Recognition API keys 32-character lowercase hexadecimal strings
try:
    print("Microsoft Bing Voice Recognition thinks you said " + r.recognize_bing(audio, key=BING_KEY))
except sr.UnknownValueError:
    print("Microsoft Bing Voice Recognition could not understand audio")
except sr.RequestError as e:
    print("Could not request results from Microsoft Bing Voice Recognition service; {0}".format(e))

When I run it, I got

ImportError: No module named SpeechRecognition

I think I did install this module:

>pip list
SpeechRecognition (3.6.5)

the code given by the git repository is like this

import speech_recognition as sr

but it isn't working either

like image 902
Shukai Ni Avatar asked Mar 09 '23 04:03

Shukai Ni


1 Answers

I think the problem is

import SpeechRecognition as sr

where you should use

import speech_recognition as sr
like image 52
Sebastian Avatar answered Mar 17 '23 00:03

Sebastian