cat s2t.py
Python 2.x program to transcribe an Audio file
import speech_recognition as sr
AUDIO_FILE = ("/home/rakeshpatil993/OSR_us_000_0010_8k.wav")
use the audio file as the audio source
r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
#reads the audio file. Here we use record instead of
#listen
audio = r.record(source)
try:
print("The audio file contains: " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
===========================================================
python s2t.py
Traceback (most recent call last):
File "s2t.py", line 10, in
with sr.AudioFile(AUDIO_FILE) as source:
AttributeError: 'module' object has no attribute 'AudioFile'
getting above error while converting speech to text using speech_recognition . i have installed beloa packages, then also facing the issues.
pip install SpeechRecognition
pip install pyaudio