Created
August 19, 2016 07:56
-
-
Save kakenn/45ee965119f71e243d99a2873212164a to your computer and use it in GitHub Desktop.
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
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