Advertisement
metalx1000

Upload Flac file to Google for Speech to Text API - English

Mar 17th, 2012
1,195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import urllib
  4. import urllib2
  5.  
  6.  
  7. Recording = 'recording.flac'
  8.  
  9.  
  10. url = "https://www.google.com/speech-api/v1/recognize?client=chromium&lang=en-us"
  11. flac=open(Recording,"rb").read()
  12. header = {'Content-Type' : 'audio/x-flac; rate=16000'}
  13. req = urllib2.Request(url, flac, header)
  14. data = urllib2.urlopen(req)
  15. print data.read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement