def check_context(): global in_command_context if speech_system.engine and speech_system.engine.name == "dragon": if "user.command_mode" in registry.tags: if in_command_context: return speech_system.engine_mimic("switch to command mode") in_command_context = True else: if not in_command_context: return speech_system.engine_mimic("switch to normal mode") in_command_context = False
def dragon_mimic(phrase: str): """mimic""" print(phrase) speech_system.engine_mimic(phrase)
from talon import Context, speech_system, actions from talon_plugins import speech ctx = Context() def set_enabled(value): ctx.exclusive = not value actions.speech.toggle(value) ctx.commands = { 'talon sleep': lambda m: set_enabled(False), 'talon wake': lambda m: set_enabled(True), 'dragon mode': [lambda m: set_enabled(False), lambda m: speech_system.engine_mimic('wake up'.split())], 'talon mode': [lambda m: set_enabled(True), lambda m: speech_system.engine_mimic('go to sleep'.split())], }
def engine_mimic(cmd: str): """Sends phrase to engine""" speech_system.engine_mimic(cmd)
def engine_wake(): """Wake the engine""" speech_system.engine_mimic("wake up"),
def engine_sleep(): """Sleep the engine""" speech_system.engine_mimic("go to sleep"),
from talon import Context, speech_system, actions from talon_plugins import speech ctx = Context() def set_enabled(value): ctx.exclusive = not value actions.speech.toggle(value) ctx.commands = { 'talon sleep': lambda m: set_enabled(False), 'talon wake': lambda m: set_enabled(True), 'dragon mode': [ lambda m: set_enabled(False), lambda m: speech_system.engine_mimic('wake up'.split()) ], 'talon mode': [ lambda m: set_enabled(True), lambda m: speech_system.engine_mimic('go to sleep'.split()) ], }
def sleep(): speech_system.engine_mimic("go to sleep")
def engine_mimic(phrase: str): """Force the engine to mimic a phrase""" speech_system.engine_mimic(phrase)