I am running a python script for speech-recognition:
def readAudioFile(audio_file):
r = sr.Recognizer()
file = sr.AudioFile(audio_file)
with file as source:
audio = r.record(source)
type(audio)
try:
message = r.recognize_google(audio)
print(message)
print("Data extracted from phone conversation:\n" + message)
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
But when I run this, I get NameError: name 'sr' is not defined error. How to solve this?