Skip to content

Commit ec1e282

Browse files
Added setting to restore system default microphone after Talon grammar tests (#2631)
There is no way of telling if Talon currently is using the system default microphone. Every time I run the Talon grammar tests this setting changes and I have to manually reset it which is really annoying. ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Phil Cohen <[email protected]>
1 parent 2ab0c73 commit ec1e282

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cursorless-talon-dev/src/spoken_form_test.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
from typing import Any, Optional
33

4-
from talon import Context, Module, actions, scope
4+
from talon import Context, Module, actions, scope, settings
55

66
mod = Module()
77

@@ -10,6 +10,12 @@
1010
"Used to run tests on the Cursorless spoken forms/grammar",
1111
)
1212

13+
mod.setting(
14+
"cursorless_spoken_form_test_restore_microphone",
15+
str,
16+
desc="The microphone to switch to after the spoken form tests are done. If unset, the microphone that was active before tests started is restored. (If you want to switch back to 'System Default', you should set that as the value here)",
17+
)
18+
1319
ctx = Context()
1420

1521
ctx.matches = r"""
@@ -72,7 +78,10 @@ def private_cursorless_spoken_form_test_mode(enable: bool): # pyright: ignore [
7278

7379
if enable:
7480
saved_modes = scope.get("mode")
75-
saved_microphone = actions.sound.active_microphone()
81+
saved_microphone = settings.get(
82+
"user.cursorless_spoken_form_test_restore_microphone",
83+
actions.sound.active_microphone(),
84+
)
7685

7786
disable_modes()
7887
actions.mode.enable("user.cursorless_spoken_form_test")

0 commit comments

Comments
 (0)