From 295433b001a3d437c7431cc72ed3f4fbcf3b311e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Aug 2021 06:26:00 +0200 Subject: [PATCH 1/2] Added spoken command to API --- src/command.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/command.py b/src/command.py index 54fa3c93..3bffcff5 100644 --- a/src/command.py +++ b/src/command.py @@ -1,8 +1,19 @@ -from talon import actions, Module +from talon import actions, Module, speech_system from typing import Any, List mod = Module() +last_phrase = None + + +def on_phrase(d): + global last_phrase + if actions.speech.enabled(): + last_phrase = " ".join(d["phrase"]) + + +speech_system.register("pre:phrase", on_phrase) + class NotSet: def __repr__(self): @@ -70,6 +81,7 @@ def cursorless_multiple_target_command( args = list(filter(lambda x: x is not NotSet, [arg1, arg2, arg3])) actions.user.vscode_with_plugin_and_wait( "cursorless.command", + last_phrase, action, targets, *args, From 248d02a2d4de59cec4e852b30ec714156a2b42d4 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Aug 2021 06:44:15 +0200 Subject: [PATCH 2/2] cleanup --- src/command.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/command.py b/src/command.py index 3bffcff5..168d976c 100644 --- a/src/command.py +++ b/src/command.py @@ -8,9 +8,7 @@ def on_phrase(d): global last_phrase - if actions.speech.enabled(): - last_phrase = " ".join(d["phrase"]) - + last_phrase = d speech_system.register("pre:phrase", on_phrase) @@ -79,9 +77,10 @@ def cursorless_multiple_target_command( ): """Execute multi-target cursorless command""" args = list(filter(lambda x: x is not NotSet, [arg1, arg2, arg3])) + spoken_form = " ".join(last_phrase["phrase"]) actions.user.vscode_with_plugin_and_wait( "cursorless.command", - last_phrase, + spoken_form, action, targets, *args,