diff 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 cf32a74..899775b 100644 --- a/client/stt.py +++ b/client/stt.py @@ -144,7 +144,7 @@ class PocketSphinxSTT(AbstractSTTEngine): print "JASPER: " + result[0] print "===================" - return result[0] + return [result[0]] @classmethod def is_available(cls): @@ -225,14 +225,18 @@ class GoogleSTT(AbstractSTTEngine): 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() |
