Last active
July 9, 2020 19:29
-
-
Save jrg94/60c6fba1687587ee18fd580bb053d68b to your computer and use it in GitHub Desktop.
A copy of a speech recognition script used to transcribe an interview
This file contains hidden or 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
import speech_recognition as sr | |
from pydub import AudioSegment | |
import os | |
AudioSegment.converter = r"C:\Users\Jeremy Grifski\AppData\Roaming\JetBrains\PyCharmCE2020.1\scratches\ffmpeg.exe" | |
r = sr.Recognizer() | |
for i, filename in enumerate(os.listdir('audio')): | |
sound = AudioSegment.from_mp3(f'audio/{filename}') | |
sound.export(f"dump/{filename[:-4]}.wav", format="wav") | |
with sr.AudioFile(f"dump/{filename[:-4]}.wav") as source, open("transcript.txt", 'a') as transcript: | |
audio = r.record(source) | |
print(f"{i * 30} seconds: {r.recognize_google(audio)}", file=transcript) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment