From 39ac02a502ba8326b634bb7c28cee9d374028fa5 Mon Sep 17 00:00:00 2001 From: Colton <70598503+C-Loftus@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:13:15 -0500 Subject: [PATCH] fix double speak bug --- core/callbacks.py | 6 ++++-- core/core-agnostic.py | 15 +++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core/callbacks.py b/core/callbacks.py index af1f3ac..2df7e7b 100644 --- a/core/callbacks.py +++ b/core/callbacks.py @@ -59,8 +59,10 @@ def on_update_contexts(): ANNOUNCE = settings.get("user.announce_mode_updates") if last_mode == "sleep" and not SLEEP: - # ALways announce wake up - actions.user.tts(f"Talon now listening") + # Always announce wake up + # Cancel any current speaker, weird edge case where it will speak twice otherwise + actions.user.cancel_current_speaker() + actions.user.tts(f"Talon now listening") elif last_mode != "sleep" and SLEEP: # Always announce sleep diff --git a/core/core-agnostic.py b/core/core-agnostic.py index 42a694b..2ecbb65 100644 --- a/core/core-agnostic.py +++ b/core/core-agnostic.py @@ -45,17 +45,24 @@ def cancel_current_speaker(): speaker_cancel_callback = None - def braille(text: str): """Output braille with the screenreader""" def echo_dictation_enabled() -> bool: """Returns true if echo dictation is enabled""" - return ctx.settings["user.echo_dictation"] + # Catch potential race condition where settings haven't been loaded yet + try: + return ctx.settings["user.echo_dictation"] + except: + return False def echo_context_enabled() -> bool: """Returns true if echo context is enabled""" - return ctx.settings["user.echo_context"] + # Catch potential race condition where settings haven't been loaded yet + try: + return ctx.settings["user.echo_context"] + except: + return False def toggle_echo(): """Toggles echo dictation on and off""" @@ -94,7 +101,7 @@ def toggle_echo_all(): def tts(text: str): '''text to speech with robot voice''' - print("Sight-Free-Talon Error: TTS not implemented in this context") + raise NotImplementedError("Sight-Free-Talon Error: TTS not implemented in this context") def espeak(text: str): '''text to speech with espeak'''