Reputation: 690
I have programmed this code to convert audio to text. It is not converting entire text. The total duration of the audio is 1.21 minutes. But the program outputs just 4 words from the audio, rest of the conversation from the audio is missing. Can some one please help me to fix this issue. Below is the code.
import speech_recognition as sr
from gtts import gTTS
import os
import playsound
r = sr.Recognizer()
with sr.AudioFile('Track1.wav') as source:
r.adjust_for_ambient_noise(source, duration=0.5)
audio = r.listen(source)
try:
text = (r.recognize_google(audio, language="en-US"))
print('working on...')
print(text)
except:
print('Sorry.. run again..')
Upvotes: 0
Views: 81
Reputation: 1882
Try a different audio file. If you are getting only a few words for other audio files also, it could be limit of the "free" default Google API key that is used by the recognize_google function in the speech_recognition library. In that case, you will need your own API key to transcribe longer audio files.
Upvotes: 1