talonvoice / talon

Issue Tracker for the main Talon app
85 stars 0 forks source link

Talon on Windows can't recover when there are no audio devices available at startup #407

Open nriley opened 3 years ago

nriley commented 3 years ago

Even if I turn on my USB microphone I have to restart Talon to get it to recognize it.

Example:

2021-10-04 12:54:08 ERROR cb error topic="ready" cb=<bound method SpeechSystem._on_ready of <talon.scripting.speech_system.SpeechSystem object at 0x000000000815E9F0>>
   18:                     threading.py:912* # loader thread
   17:                     threading.py:954* 
   16:                     threading.py:892* 
   15:          app\resources\loader.py:787| 
   14:          app\resources\loader.py:737| 
   13:      talon\scripting\dispatch.py:105| 
   12:      talon\scripting\dispatch.py:144| 
   11:      talon\scripting\dispatch.py:135| 
   10: ------------------------------------# loader thread
    9:          talon\scripting\rctx.py:233| # 'ready' main:_on_ready()
    8: talon\scripting\speech_system.py:169| 
    7: talon\scripting\speech_system.py:328| 
    6:                     talon\vad.py:90 | 
    5:                     talon\vad.py:122| 
    4:                     talon\vad.py:47 | 
    3:               talon\lib\cubeb.py:333| 
    2:               talon\lib\cubeb.py:320| 
    1:               talon\lib\cubeb.py:150| 
talon.lib.cubeb.CubebError: audio error: Result.ERROR
2021-10-04 12:53:55 ERROR user.knausj_talon.code.mouse (C:\Users\nriley\AppData\Roaming\talon\user\knausj_talon\code\mouse.py) import failed
   19:                    threading.py:912* # loader thread
   18:                    threading.py:954* 
   17:                    threading.py:892* 
   16:         app\resources\loader.py:787| 
   15:         app\resources\loader.py:723| 
   14:         app\resources\loader.py:551| 
   13:         app\resources\loader.py:587| 
   12:         app\resources\loader.py:639| 
   11:         app\resources\loader.py:413| # [stack splice]
   10:           importlib\__init__.py:127| 
    9:         app\resources\loader.py:243| 
    8:         app\resources\loader.py:238| 
    7: user\knausj_talon\code\mouse.py:284| noise.register("pop", on_pop)
    6:     talon\scripting\dispatch.py:61 | 
    5:                  talon\noise.py:62 | 
    4:                  talon\noise.py:30 | 
    3:              talon\lib\cubeb.py:333| 
    2:              talon\lib\cubeb.py:320| 
    1:              talon\lib\cubeb.py:150| 
talon.lib.cubeb.CubebError: audio error: Result.ERROR
codecat555 commented 3 years ago

FWIW, I don't see this behavior on my system even though the same conditions apply - Windows with mic set to None upon startup. There must some other factor involved.

Currently running Talon v0.2.0-143-gb178 (143).

I do see eye tracker errors upon resume (restart after hibernation), but I don't want to muddy the waters here with those details.

nriley commented 3 years ago

I'm not referring to the mic being set to None, I'm talking about there being no available audio input devices on the system.

codecat555 commented 3 years ago

Sorry, I misunderstood.

lunixbochs commented 3 years ago

@nriley which talon version are these tracebacks from?

Does the Talon log also have an Activating Microphone line? If so, what does it say?

nriley commented 3 years ago

Here's an updated log:

2021-10-26 17:59:59  INFO Activating Microphone: "Microphone (Jabra Evolve 75)"
2021-10-26 18:00:00  INFO Falling back to polling for USB hotplug: failed to register hotplug callback
2021-10-26 18:00:00 DEBUG Talon Version: 0.2.0-150-gc908
[...]
2021-10-26 18:00:02 ERROR user.knausj_talon.code.mouse (C:\Users\nriley\AppData\Roaming\talon\user\knausj_talon\code\mouse.py) import failed
   19:                    threading.py:930* # loader thread
   18:                    threading.py:973*
   17:                    threading.py:910*
   16:         app\resources\loader.py:787|
   15:         app\resources\loader.py:723|
   14:         app\resources\loader.py:551|
   13:         app\resources\loader.py:587|
   12:         app\resources\loader.py:639|
   11:         app\resources\loader.py:413| # [stack splice]
   10:           importlib\__init__.py:127|
    9:         app\resources\loader.py:243|
    8:         app\resources\loader.py:238|
    7: user\knausj_talon\code\mouse.py:284| noise.register("pop", on_pop)
    6:     talon\scripting\dispatch.py:61 |
    5:                  talon\noise.py:62 |
    4:                  talon\noise.py:30 |
    3:              talon\lib\cubeb.py:333|
    2:              talon\lib\cubeb.py:320|
    1:              talon\lib\cubeb.py:150|
talon.lib.cubeb.CubebError: audio error: Result.ERROR
lunixbochs commented 3 years ago

How are we getting Jabra Evolve 75 if there are no microphones in the system? Is that a disabled mic on Windows or something?

nriley commented 3 years ago

That was my microphone as selected prior to exiting Talon, but at the time I launched Talon, it was not plugged in at all. Windows does not show any input devices:

image

If I set Talon's microphone to None prior to quitting it, I don't get the "Activating Microphone" line when I relaunch it with no input devices plugged in, and I don't get any cubeb tracebacks.

If I then plug the microphone in and turn it on, it does show up in the menu, but I don't see any "Activating Microphone" lines in the log, and speech recognition does not work.

nriley commented 3 years ago

Not sure if this is related (can file a different issue if so) but I'm also seeing something similar on Mac now when I launch and the mic is turned off (despite there being other audio input devices available on the system, though I don't use any of them for speech/noise recognition).

2021-11-04 07:50:30  INFO Activating Microphone: "Jabra Evolve 75"
2021-11-04 07:50:31 DEBUG Talon Version: 0.2.0-150-gc908
2021-11-04 07:50:31 DEBUG UI responsive at 2.1823s
[...]
2021-11-04 07:50:34 DEBUG User modules loaded at 5.4395s
2021-11-04 07:50:37 WARNING [watchdog] "talon.scripting.speech_system._on_ready" @2.0s
   15:       lib/python3.9/threading.py:930* # loader thread
   14:       lib/python3.9/threading.py:973* 
   13:       lib/python3.9/threading.py:910* 
   12:          app/resources/loader.py:787| 
   11:          app/resources/loader.py:737| 
   10:      talon/scripting/dispatch.py:105| 
    9:      talon/scripting/dispatch.py:144| 
    8:      talon/scripting/dispatch.py:135| 
    7:          talon/scripting/rctx.py:233| # 'ready' main:_on_ready()
    6: talon/scripting/speech_system.py:176| 
    5: talon/scripting/speech_system.py:320| 
    4: talon/scripting/speech_system.py:93 | 
    3:             talon/engines/w2l.py:795| 
    2:             talon/engines/w2l.py:979| 
    1:             talon/engines/w2l.py:456| 
2021-11-04 07:50:37  INFO (SpeechSystem) Activating speech engine: W2lEngine(fast Conformer b108 (2021-09-15))
2021-11-04 07:50:38 ERROR cb error topic="ready" cb=<bound method SpeechSystem._on_ready of <talon.scripting.speech_system.SpeechSystem object at 0x107be9ef0>>
   19:       lib/python3.9/threading.py:930* # loader thread
   18:       lib/python3.9/threading.py:973* 
   17:       lib/python3.9/threading.py:910* 
   16:          app/resources/loader.py:787| 
   15:          app/resources/loader.py:737| 
   14:      talon/scripting/dispatch.py:105| 
   13:      talon/scripting/dispatch.py:144| 
   12:      talon/scripting/dispatch.py:135| 
   11: ------------------------------------# loader thread
   10:          talon/scripting/rctx.py:233| # 'ready' main:_on_ready()
    9: talon/scripting/speech_system.py:176| 
    8: talon/scripting/speech_system.py:337| 
    7:                     talon/vad.py:90 | 
    6:                     talon/vad.py:122| 
    5:                     talon/vad.py:47 | 
    4:               talon/lib/cubeb.py:333| 
    3:               talon/lib/cubeb.py:315| 
    2:               talon/lib/cubeb.py:282| 
    1:               talon/lib/cubeb.py:150| 
talon.lib.cubeb.CubebError: audio error: Result.ERROR
2021-11-04 07:50:38  INFO Deactivating Microphone
2021-11-04 07:50:38 DEBUG Dispatched launch events at 5.9435s, done at 9.8533s
2021-11-04 07:50:38 ERROR [!] 1 error(s) during startup (shown earlier in log)
2021-11-04 07:50:38  INFO Startup warnings displayed at 9.8551s
2021-11-04 07:50:38  INFO Activating Microphone: "Jabra Evolve 75"
2021-11-04 07:50:38 ERROR cb error topic="mic_change" cb=<bound method Noise.mic_change of <talon.noise.Noise object at 0x109b3d4f0>>
   23:  lib/python3.9/threading.py:930* # cron thread
   22:  lib/python3.9/threading.py:973* 
   21:  lib/python3.9/threading.py:910* 
   20:               talon/cron.py:155| 
   19:               talon/cron.py:106| 
   18: talon/scripting/dispatch.py:99 | 
   17: talon/scripting/dispatch.py:105| 
   16: talon/scripting/dispatch.py:144| 
   15: talon/scripting/dispatch.py:135| 
   14:     talon/scripting/rctx.py:233| # 'devices_changed' main:on_devices()
   13: talon/plugins/microphone.py:83 | 
   12: talon/plugins/microphone.py:153| 
   11: talon/scripting/dispatch.py:105| 
   10: talon/scripting/dispatch.py:144| 
    9: talon/scripting/dispatch.py:135| 
    8: -------------------------------# cron thread
    7:     talon/scripting/rctx.py:233| # 'mic_change' main:mic_change()
    6:              talon/noise.py:70 | 
    5:              talon/noise.py:30 | 
    4:          talon/lib/cubeb.py:333| 
    3:          talon/lib/cubeb.py:315| 
    2:          talon/lib/cubeb.py:282| 
    1:          talon/lib/cubeb.py:150| 
talon.lib.cubeb.CubebError: audio error: Result.ERROR
douglasg14b commented 2 years ago

I notice similar behavior if my PC sleeps & wakes back up, and a mic IS set.

nriley commented 2 years ago

Some workarounds:

@AndreasArvidsson pointed out that if you select "System Default" for a microphone rather than a specific microphone, this issue does not occur. This works for me since I only ever have 0 or 1 active microphone. He also mentioned that Windows allows you to disable microphones you're not using.

Alternately, you can use the sound.* actions to set the microphone to None and back, as I do here.