Created
August 19, 2016 07:55
-
-
Save kakenn/f1b107d1f780824b3dcd3f8fd4ab0a8c 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