Created
March 18, 2021 00:43
-
-
Save ameisehaufen/601306473ee88d674e1f21506b542a0e to your computer and use it in GitHub Desktop.
Speech to Text script, only for small videos, using google speech recognition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import speech_recognition as sr | |
import moviepy.editor as mp | |
import sys | |
clip = mp.VideoFileClip(sys.argv[1]) | |
clip.audio.write_audiofile(r"/tmp/converted.wav") | |
audio = sr.AudioFile("/tmp/converted.wav") | |
r = sr.Recognizer() | |
with audio as source: | |
audio_file = r.record(source) | |
# result = r.recognize_google(audio_file) | |
result = r.recognize_google(audio_file, language = "pt-BR") | |
# exporting the result | |
with open('recognized.txt',mode ='w') as file: | |
file.write("Recognized Speech:") | |
file.write("\n") | |
file.write(result) | |
print("ready!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment