dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

delayed_speech_off.py (936B)


      1 from talon import Context, Module, actions, app, speech_system
      2 
      3 delay_mod = Module()
      4 
      5 delayed_enabled = False
      6 
      7 
      8 def do_disable(e):
      9     speech_system.unregister("post:phrase", do_disable)
     10     actions.speech.disable()
     11 
     12 
     13 @delay_mod.action_class
     14 class DelayedSpeechOffActions:
     15     def delayed_speech_on():
     16         """Activates a "temporary speech" mode that can be disabled lazily,
     17         so that the actual disable command happens after whatever phrase
     18         finishes next."""
     19         global delayed_enabled
     20         if not actions.speech.enabled():
     21             delayed_enabled = True
     22             actions.speech.enable()
     23 
     24     def delayed_speech_off():
     25         """Disables "temporary speech" mode lazily, meaning that the next
     26         phrase that finishes will turn speech off."""
     27         global delayed_enabled
     28         if delayed_enabled:
     29             delayed_enabled = False
     30             speech_system.register("post:phrase", do_disable)