Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "improve mode speaking on context switch" #35

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions core/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,21 @@ def on_update_contexts():
COMMAND = "command" in modes and "dictation" not in modes
DICTATION = "dictation" in modes and "command" not in modes
SLEEP = "sleep" in modes


speak = actions.user.echo_dictation_enabled() and settings.get("user.announce_mode_updates")
message_to_speak: str = ""
ANNOUNCE = settings.get("user.announce_mode_updates")

if last_mode == "sleep" and not SLEEP:
# Always announce wake up
# Cancel any current speaker, weird edge case where it will speak twice otherwise
actions.user.cancel_current_speaker()
message_to_speak = "Talon listening"
actions.user.tts("Talon now listening")

elif last_mode != "sleep" and SLEEP:
# Always announce sleep
message_to_speak = "Talon asleep"
actions.user.tts("Talon asleep")

elif last_mode != "sleep" and MIXED and last_mode != "mixed":
message_to_speak = "Talon mixed mode"
if ANNOUNCE:
actions.user.tts("Talon mixed mode")

elif (
last_mode != "sleep"
Expand All @@ -88,7 +87,8 @@ def on_update_contexts():
and not SLEEP
and last_mode != "command"
):
message_to_speak = "Talon command mode"
if ANNOUNCE:
actions.user.tts("Talon command mode")

elif (
last_mode != "sleep"
Expand All @@ -98,7 +98,8 @@ def on_update_contexts():
and last_mode != "dictation"
and last_mode != "mixed"
):
message_to_speak = "Talon dictation mode"
if ANNOUNCE:
actions.user.tts("Talon dictation mode")

if SLEEP:
CallbackState.last_mode = "sleep"
Expand All @@ -109,9 +110,6 @@ def on_update_contexts():
elif DICTATION:
CallbackState.last_mode = "dictation"

if speak and message_to_speak != "":
actions.user.tts(message_to_speak)


def on_ready():
# Only register these callbacks once all user settings and Talon
Expand All @@ -123,11 +121,7 @@ def on_ready():

if settings.get("user.start_screenreader_on_startup"):
actions.user.toggle_reader()

# We don't have a setting specifically for echoing at startup
# but we can still use the same setting since it is semantically relevant
if actions.user.echo_dictation_enabled():
actions.user.tts("Talon user scripts loaded")
actions.user.tts("Talon user scripts loaded")


app.register("ready", on_ready)
Loading