Skip to content

Instantly share code, notes, and snippets.

@kakenn
Created August 19, 2016 07:56
Show Gist options
  • Save kakenn/45ee965119f71e243d99a2873212164a to your computer and use it in GitHub Desktop.
Save kakenn/45ee965119f71e243d99a2873212164a to your computer and use it in GitHub Desktop.
import requests
import base64
file = open('./20_F1.wav', 'rt').read()
enc_file = base64.b64encode( file )
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ya29.Ci9EA9Dzi1sA0CKpcAS-I_14NvBgOMCE4qswqp584BNbQD0vmksQffsYcnHKwxXwUg',
}
data = '{"config": {"encoding": "LINEAR16","sampleRate": 16000,"languageCode": "en-US",},"audio": {"content":"%s"}}' % enc_file
res = requests.post('https://speech.googleapis.com/v1beta1/speech:syncrecognize', headers=headers, data=data)
print(res.text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment