Fix cli bugs
- Add keycode 127 as backspace
- Run tts in another thread to suppress output
@@ -248,20 +248,20 @@ def rebuild_filtered_log():
##############################################################################
# Capturing output from Mycroft
-def handle_speak(event):
- global chat
+tts_threads = []
+
+
+def start_tts(utterance):
+ """
+ Begin speaking in another thread to redirect output
+ Otherwise, the CLI get's polluted with text to speech debug
+ """
global tts
mutex.acquire()
+
if not bQuiet:
ws.emit(Message("recognizer_loop:audio_output_start"))
try:
- utterance = event.data.get('utterance')
- if bSimple:
- print(">> " + utterance)
- else:
- chat.append(">> " + utterance)
- draw_screen()
- if not bQuiet:
if not tts:
tts = TTSFactory.create()
tts.init(ws)
@@ -272,6 +272,21 @@ def handle_speak(event):
ws.emit(Message("recognizer_loop:audio_output_end"))
+def handle_speak(event):
+ global chat
+ global tts_threads
+ utterance = event.data.get('utterance')
+ if bSimple:
+ print(">> " + utterance)
+ else:
+ chat.append(">> " + utterance)
+ draw_screen()
+ if not bQuiet:
+ t = Thread(start_tts, utterance)
+ t.start()
+ tts_threads.append(t)
+
+
def connect():
# Once the websocket has connected, just watch it for speak events
ws.run_forever()
@@ -749,7 +764,7 @@ def main(stdscr):
# resizeterm() causes another curses.KEY_RESIZE, so
# we need to capture that to prevent a loop of resizes
c = scr.getch()
- elif c == curses.KEY_BACKSPACE:
+ elif c == curses.KEY_BACKSPACE or c == 127:
# Backspace to erase a character in the utterance
line = line[:-1]
elif curses.ascii.isascii(c):
