diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-08-30 17:44:47 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-25 07:12:55 +0100 |
| commit | dd133d3738162e184f206d112ea4a39ba43f0781 (patch) | |
| tree | e1ac1e02cd601c1908d93bea974e19433297c958 /client/stt.py | |
| parent | ea3026c133755bf3e35ad78fa253786bc9ff7c36 (diff) | |
| download | jasper-client-dd133d3738162e184f206d112ea4a39ba43f0781.tar.gz jasper-client-dd133d3738162e184f206d112ea4a39ba43f0781.zip | |
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 bcfdfba..9191bf5 100644 --- a/client/stt.py +++ b/client/stt.py @@ -79,7 +79,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. @@ -138,14 +138,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() |
