cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.14k stars 80 forks source link

Error generated by cursorless-talon when switching to Vosk dictation #2629

Closed falzonv closed 3 months ago

falzonv commented 3 months ago

Hello,

Thank you for making Cursorless!

I recently noticed that every time I switch from command mode to dictation with Vosk, the huge error message at the end of this post is generated in Talon logs by the update() method of the file spoken_forms.py in cursorless-talon.

This seems to be only cosmetic and doesn't affect the use of Vosk (or the use of Cursorless after coming back to command mode later), but since the message is huge and kind of polluting the logs I wanted to inform you about it.

In my copy of cursorless-talon I added a simple test at the beginning of update() as a workaround, but there is probably a clever and more generic way than explicitly checking for Vosk:

def update():

    if settings.get("speech.engine") == "vosk":
        print("cursorless.src.spoken_forms.py/update(): Vosk detected, skip update")
        return

    global disposables
    ...

Best regards.


Copy of the error message:

2024-08-04 16:04:18.858  INFO (SpeechSystem) Activating speech engine: VoskEngine(vosk-model-small-fr-0.22, fr_FR)
2024-08-04 16:04:19.000 DEBUG [NOTE: deferred error from]:
   40:         lib/python3.11/threading.py:1002* # cron thread
   39:         lib/python3.11/threading.py:1045* 
   38:         lib/python3.11/threading.py:982 * 
   37:                       talon/cron.py:132 | 
   36:                        talon/vad.py:23  | # 'cron' user.cursorless.src.spoken_forms:update_captures()
   35:                        talon/vad.py:129 | 
   34:    talon/scripting/speech_system.py:394 | 
   33:                talon/engines/w2l.py:739 | 
   32:         talon/scripting/dispatch.py:141 | 
   31:    talon/scripting/speech_system.py:69  | 
   30:         talon/scripting/dispatch.py:141 | 
   29:    talon/scripting/speech_system.py:517 | 
   28:         talon/scripting/executor.py:130 | 
   27:     talon/scripting/talon_script.py:823 | 
   26:     talon/scripting/talon_script.py:726 | 
   25:     talon/scripting/talon_script.py:314 | 
   24:          talon/scripting/actions.py:90  | 
   23:          talon/plugins/core/mode.py:15  | 
   22:         talon/scripting/registry.py:63  | 
   21:         talon/scripting/dispatch.py:141 | 
   20:            talon/scripting/scope.py:28  | 
   19:         talon/scripting/dispatch.py:141 | 
   18:            talon/scripting/scope.py:100 | 
   17:         talon/scripting/dispatch.py:141 | 
   16:            talon/scripting/scope.py:62  | 
   15:         talon/scripting/registry.py:392 | 
   14:         talon/scripting/dispatch.py:141 | 
   13:         talon/scripting/settings.py:15  | 
   12:         talon/scripting/dispatch.py:141 | 
   11:    talon/scripting/speech_system.py:199 | 
   10:    talon/scripting/speech_system.py:389 | 
    9:         talon/scripting/dispatch.py:141 | 
    8:            talon/scripting/scope.py:28  | 
    7:         talon/scripting/dispatch.py:141 | 
    6:            talon/scripting/scope.py:100 | 
    5:         talon/scripting/dispatch.py:141 | 
    4:            talon/scripting/scope.py:62  | 
    3:         talon/scripting/registry.py:392 | 
    2:         talon/scripting/dispatch.py:141 | 
    1: user/cursorless/src/spoken_forms.py:215 | update_captures_cron = cron.after("100ms", update_captures)
2024-08-04 16:04:19.001 ERROR cb error topic="cron" cb=update_captures
   18:                             lib/python3.11/threading.py:1002* # cron thread
   17:                             lib/python3.11/threading.py:1045* 
   16:                             lib/python3.11/threading.py:982 * 
   15:                                           talon/cron.py:153 | 
   14: ------------------------------------------------------------# [stack splice]
   13:                                 talon/scripting/rctx.py:235 | # 'cron' user.cursorless.src.spoken_forms:update_captures()
   12:                     user/cursorless/src/spoken_forms.py:222 | update()
   11:                                                               ^^^^^^^^
   10:                     user/cursorless/src/spoken_forms.py:197 | update_spoken_forms_output()
    9:                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    8:                     user/cursorless/src/spoken_forms.py:117 | *get_grapheme_spoken_form_entries(),
    7:                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    6: user/cursorless/src/get_grapheme_spoken_form_entries.py:15  | return [
    5:                                                                      
    4: user/cursorless/src/get_grapheme_spoken_form_entries.py:15  | return [
    3:                                                                      
    2: user/cursorless/src/get_grapheme_spoken_form_entries.py:35  | rule = registry.captures[capture_name][0].rule.rule
    1:                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'user.any_alphanumeric_key'
falzonv commented 3 months ago

Wow that was quick, thank you for the fix! I confirm the error has now disappeared when switching to Vosk :-)

AndreasArvidsson commented 3 months ago

Nice :)