0

Can anyone guide me on how to get the speech from a video into a text file in text? I tried but I am getting this error- "raise RequestError("recognition request failed: {}".format(e.reason)) speech_recognition.RequestError: recognition request failed: Bad Request" and below is the code sample which I am trying.

import moviepy.editor as mp
import speech_recognition as sr 


clip = mp.VideoFileClip(r"sample1.mp4")
clip.audio.write_audiofile(r"Converted_audio.wav")
print("Finished the convertion into audio...")

audio = sr.AudioFile("Converted_audio.wav")
print("Audio file readed...")

r = sr.Recognizer()
with audio as source:
    audio_file = r.record(source)
    
result = r.recognize_google(audio_file)
with open('recognized.txt',mode ='w') as file:
    file.write(result)

print("Wooh.. I did it...")
Laxmi
  • 21
  • 8

1 Answers1

0

try speech-to-text model from hugging face transformers.

Agog
  • 69
  • 5