Skip to content

Instantly share code, notes, and snippets.

@0atman
Created December 16, 2014 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0atman/ec2acea90f6c0b56c1b6 to your computer and use it in GitHub Desktop.
Save 0atman/ec2acea90f6c0b56c1b6 to your computer and use it in GitHub Desktop.
A python script to do google speech API transcription
"""
Requires the pip package `SpeechRecognition`
The google api seems to only like 15s chuncks
"""
import speech_recognition as sr
import sys
r = sr.Recognizer()
with sr.WavFile(sys.argv[1]) as source:
audio = r.record(source)
try:
print(r.recognize(audio, True)[0]['text'])
except LookupError as lookup_error:
print(lookup_error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment