summaryrefslogtreecommitdiff
path: root/client/stt.py
diff options
context:
space:
mode:
Diffstat (limited to 'client/stt.py')
-rw-r--r--client/stt.py20
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()