파이썬에서 Google Speech API를 사용하려고합니다. 나는이 같은 인 .flac 파일을로드 :Python의 Google Speech API 응답 디코딩
이url = "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US"
audio = open('temp_voice.flac','rb').read()
headers = {'Content-Type': 'audio/x-flac; rate=44100', 'User-Agent':'Mozilla/5.0'}
req = urllib2.Request(url, data=audio, headers=headers)
resp = urllib2.urlopen(req)
system("rm temp_voice.wav; rm temp_voice.flac")
print resp.read()
출력 :
이{ "상태": 0, "ID": "", "가설": [{ "말은": "오늘은 수요일입니다 ","자신감 ": 0.75135982}]}
내가 추출하고 텍스트를 절약 할 수있는 방법 누군가가 가르쳐 주시겠습니까"변수로 오늘은 수요일이다 "을하고 인쇄? 응답이 문자열로 오는 경우
['json' 모듈] (http://docs.python.org/2/library/json.html) 사용은 어떻습니까? – falsetru