diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-26 16:58:07 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-26 16:58:07 +0200 |
| commit | cb0eb4742347c7d8c692342bc4c0e37a95ffaa51 (patch) | |
| tree | aef2f60d1f446f4ebd296f7c6597a2dca06747fb /client/stt.py | |
| parent | ba7df0c17b633e28502db384743856f050d934c0 (diff) | |
| parent | dd133d3738162e184f206d112ea4a39ba43f0781 (diff) | |
| download | jasper-client-cb0eb4742347c7d8c692342bc4c0e37a95ffaa51.tar.gz jasper-client-cb0eb4742347c7d8c692342bc4c0e37a95ffaa51.zip | |
Merge pull request #148 from alexsiri7/multiple_queries
Handle all Google Speech options
Diffstat (limited to 'client/stt.py')
| -rw-r--r-- | client/stt.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/client/stt.py b/client/stt.py index a937658..fc1bd1f 100644 --- a/client/stt.py +++ b/client/stt.py @@ -107,7 +107,7 @@ class PocketSphinxSTT(object): print "JASPER: " + result[0] print "===================" - return result[0] + return [result[0]] """ Speech-To-Text implementation which relies on the Google Speech API. @@ -166,14 +166,18 @@ class GoogleSTT(object): response = self.http.post(url, data=data, headers=headers) response.encoding = 'utf-8' response_read = response.text - decoded = json.loads(response_read.split("\n")[1]) - text = decoded['result'][0]['alternative'][0]['transcript'] - if text: - print "===================" - print "JASPER: " + text - print "===================" - return text + response_parts = response_read.strip().split("\n") + decoded = json.loads(response_parts[-1]) + if decoded['result']: + texts = [alt['transcript'] for alt in decoded['result'][0]['alternative']] + if texts: + print "===================" + print "JASPER: " + ', '.join(texts) + print "===================" + return texts + else: + return [] except Exception: traceback.print_exc() |
