init commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
list: user.arrow_key
|
||||
-
|
||||
down: down
|
||||
left: left
|
||||
right: right
|
||||
up: up
|
||||
@@ -0,0 +1,27 @@
|
||||
list: user.function_key
|
||||
-
|
||||
f one: f1
|
||||
f two: f2
|
||||
f three: f3
|
||||
f four: f4
|
||||
f five: f5
|
||||
f six: f6
|
||||
f seven: f7
|
||||
f eight: f8
|
||||
f nine: f9
|
||||
f ten: f10
|
||||
f eleven: f11
|
||||
f twelve: f12
|
||||
f thirteen: f13
|
||||
f fourteen: f14
|
||||
f fifteen: f15
|
||||
f sixteen: f16
|
||||
f seventeen: f17
|
||||
f eighteen: f18
|
||||
f nineteen: f19
|
||||
f twenty: f20
|
||||
# these f keys are not supported by all platforms (eg Mac) and are disabled by default
|
||||
#f twenty one: f21
|
||||
#f twenty two: f22
|
||||
#f twenty three: f23
|
||||
#f twenty four: f24
|
||||
@@ -0,0 +1,21 @@
|
||||
list: user.keypad_key
|
||||
-
|
||||
|
||||
key pad zero: keypad_0
|
||||
key pad one: keypad_1
|
||||
key pad two: keypad_2
|
||||
key pad three: keypad_3
|
||||
key pad four: keypad_4
|
||||
key pad five: keypad_5
|
||||
key pad six: keypad_6
|
||||
key pad seven: keypad_7
|
||||
key pad eight: keypad_8
|
||||
key pad nine: keypad_9
|
||||
key pad point: keypad_decimal
|
||||
key pad plus: keypad_plus
|
||||
key pad minus: keypad_minus
|
||||
key pad star: keypad_multiply
|
||||
key pad slash: keypad_divide
|
||||
key pad equals: keypad_equals
|
||||
key pad clear: keypad_clear
|
||||
key pad enter: keypad_enter
|
||||
@@ -0,0 +1,128 @@
|
||||
from talon import Context, Module, actions, app
|
||||
|
||||
from .symbols import (
|
||||
dragon_punctuation_dict,
|
||||
punctuation_dict,
|
||||
symbol_key_dict,
|
||||
)
|
||||
|
||||
mod = Module()
|
||||
ctx = Context()
|
||||
|
||||
ctx_dragon = Context()
|
||||
ctx_dragon.matches = r"""
|
||||
speech.engine: dragon
|
||||
"""
|
||||
|
||||
mod.list("letter", desc="The spoken phonetic alphabet")
|
||||
mod.list("symbol_key", desc="All symbols from the keyboard")
|
||||
mod.list("arrow_key", desc="All arrow keys")
|
||||
mod.list("number_key", desc="All number keys")
|
||||
mod.list("modifier_key", desc="All modifier keys")
|
||||
mod.list("function_key", desc="All function keys")
|
||||
mod.list("special_key", desc="All special keys")
|
||||
mod.list("keypad_key", desc="All keypad keys")
|
||||
mod.list("punctuation", desc="words for inserting punctuation into text")
|
||||
|
||||
|
||||
@mod.capture(rule="{self.modifier_key}+")
|
||||
def modifiers(m) -> str:
|
||||
"One or more modifier keys"
|
||||
return "-".join(m.modifier_key_list)
|
||||
|
||||
|
||||
@mod.capture(rule="{self.arrow_key}")
|
||||
def arrow_key(m) -> str:
|
||||
"One directional arrow key"
|
||||
return m.arrow_key
|
||||
|
||||
|
||||
@mod.capture(rule="<self.arrow_key>+")
|
||||
def arrow_keys(m) -> str:
|
||||
"One or more arrow keys separated by a space"
|
||||
return str(m)
|
||||
|
||||
|
||||
@mod.capture(rule="{self.number_key}")
|
||||
def number_key(m) -> str:
|
||||
"One number key"
|
||||
return m.number_key
|
||||
|
||||
|
||||
@mod.capture(rule="{self.keypad_key}")
|
||||
def keypad_key(m) -> str:
|
||||
"One keypad key"
|
||||
return m.keypad_key
|
||||
|
||||
|
||||
@mod.capture(rule="{self.letter}")
|
||||
def letter(m) -> str:
|
||||
"One letter key"
|
||||
return m.letter
|
||||
|
||||
|
||||
@mod.capture(rule="{self.special_key}")
|
||||
def special_key(m) -> str:
|
||||
"One special key"
|
||||
return m.special_key
|
||||
|
||||
|
||||
@mod.capture(rule="{self.symbol_key}")
|
||||
def symbol_key(m) -> str:
|
||||
"One symbol key"
|
||||
return m.symbol_key
|
||||
|
||||
|
||||
@mod.capture(rule="{self.function_key}")
|
||||
def function_key(m) -> str:
|
||||
"One function key"
|
||||
return m.function_key
|
||||
|
||||
|
||||
@mod.capture(rule="( <self.letter> | <self.number_key> | <self.symbol_key> )")
|
||||
def any_alphanumeric_key(m) -> str:
|
||||
"any alphanumeric key"
|
||||
return str(m)
|
||||
|
||||
|
||||
@mod.capture(
|
||||
rule="( <self.letter> | <self.number_key> | <self.symbol_key> "
|
||||
"| <self.arrow_key> | <self.function_key> | <self.special_key> | <self.keypad_key>)"
|
||||
)
|
||||
def unmodified_key(m) -> str:
|
||||
"A single key with no modifiers"
|
||||
return str(m)
|
||||
|
||||
|
||||
@mod.capture(rule="{self.modifier_key}* <self.unmodified_key>")
|
||||
def key(m) -> str:
|
||||
"A single key with optional modifiers"
|
||||
try:
|
||||
mods = m.modifier_key_list
|
||||
except AttributeError:
|
||||
mods = []
|
||||
return "-".join(mods + [m.unmodified_key])
|
||||
|
||||
|
||||
@mod.capture(rule="<self.key>+")
|
||||
def keys(m) -> str:
|
||||
"A sequence of one or more keys with optional modifiers"
|
||||
return " ".join(m.key_list)
|
||||
|
||||
|
||||
@mod.capture(rule="{self.letter}+")
|
||||
def letters(m) -> str:
|
||||
"Multiple letter keys"
|
||||
return "".join(m.letter_list)
|
||||
|
||||
|
||||
@mod.action_class
|
||||
class Actions:
|
||||
def get_punctuation_words():
|
||||
"""Gets the user.punctuation list"""
|
||||
return punctuation_dict
|
||||
|
||||
|
||||
ctx.lists["user.punctuation"] = punctuation_dict
|
||||
ctx.lists["user.symbol_key"] = symbol_key_dict
|
||||
ctx_dragon.lists["user.punctuation"] = dragon_punctuation_dict
|
||||
@@ -0,0 +1,12 @@
|
||||
<user.letter>: key(letter)
|
||||
(ship | uppercase) <user.letters> [(lowercase | sunk)]:
|
||||
user.insert_formatted(letters, "ALL_CAPS")
|
||||
<user.symbol_key>: key(symbol_key)
|
||||
<user.function_key>: key(function_key)
|
||||
<user.special_key>: key(special_key)
|
||||
<user.keypad_key>: key(keypad_key)
|
||||
<user.modifiers> <user.unmodified_key>: key("{modifiers}-{unmodified_key}")
|
||||
# for key combos consisting only of modifiers, eg. `press super`.
|
||||
press <user.modifiers>: key(modifiers)
|
||||
# for consistency with dictation mode and explicit arrow keys if you need them.
|
||||
press <user.keys>: key(keys)
|
||||
@@ -0,0 +1,30 @@
|
||||
list: user.letter
|
||||
-
|
||||
# for common alternative spoken forms for letters, visit
|
||||
# https://talon.wiki/Resource%20Hub/Speech%20Recognition/improving_recognition_accuracy#collected-alternatives-to-the-default-alphabet
|
||||
air: a
|
||||
bat: b
|
||||
cap: c
|
||||
drum: d
|
||||
each: e
|
||||
fine: f
|
||||
gust: g
|
||||
harp: h
|
||||
sit: i
|
||||
jury: j
|
||||
crunch: k
|
||||
look: l
|
||||
made: m
|
||||
near: n
|
||||
odd: o
|
||||
pit: p
|
||||
quench: q
|
||||
red: r
|
||||
sun: s
|
||||
trap: t
|
||||
urge: u
|
||||
vest: v
|
||||
whale: w
|
||||
plex: x
|
||||
yank: y
|
||||
zip: z
|
||||
@@ -0,0 +1,12 @@
|
||||
list: user.modifier_key
|
||||
os: mac
|
||||
-
|
||||
|
||||
alt: alt
|
||||
control: ctrl
|
||||
shift: shift
|
||||
super: cmd
|
||||
command: cmd
|
||||
option: alt
|
||||
function: fn
|
||||
globe: fn
|
||||
@@ -0,0 +1,18 @@
|
||||
list: user.special_key
|
||||
os: mac
|
||||
-
|
||||
|
||||
end: end
|
||||
home: home
|
||||
minus: minus
|
||||
return: return
|
||||
enter: keypad_enter
|
||||
page down: pagedown
|
||||
page up: pageup
|
||||
escape: escape
|
||||
space: space
|
||||
tab: tab
|
||||
insert: insert
|
||||
wipe: backspace
|
||||
delete: backspace
|
||||
forward delete: delete
|
||||
@@ -0,0 +1,12 @@
|
||||
list: user.number_key
|
||||
-
|
||||
zero: 0
|
||||
one: 1
|
||||
two: 2
|
||||
three: 3
|
||||
four: 4
|
||||
five: 5
|
||||
six: 6
|
||||
seven: 7
|
||||
eight: 8
|
||||
nine: 9
|
||||
@@ -0,0 +1,102 @@
|
||||
# fmt: off
|
||||
|
||||
# define the spoken forms for symbols in command and dictation mode
|
||||
punctuation_dict = {}
|
||||
|
||||
# for dragon, we add a couple of mappings that don't work for conformer
|
||||
# i.e. dragon supports some actual symbols as the spoken form
|
||||
dragon_punctuation_dict = {
|
||||
"`": "`",
|
||||
",": ",",
|
||||
}
|
||||
|
||||
# define the spoken forms for symbols that are intended for command mode only
|
||||
symbol_key_dict = {}
|
||||
|
||||
# define spoken form for symbols for use in create_spoken_forms.py functionality
|
||||
# we define a handful of symbol only. at present, this is restricted to one entry per symbol.
|
||||
symbols_for_create_spoken_forms = {
|
||||
# for application names like "Movies & TV"
|
||||
"and": "&",
|
||||
# for emails
|
||||
"at": "@",
|
||||
"dot": ".",
|
||||
# for application names like "notepad++"
|
||||
"plus": "+",
|
||||
}
|
||||
|
||||
|
||||
class Symbol:
|
||||
character: str
|
||||
command_and_dictation_forms: list[str] = None
|
||||
command_forms: list[str] = None
|
||||
|
||||
def __init__(
|
||||
self, character: str, command_and_dictation_forms=None, command_forms=None
|
||||
):
|
||||
self.character = character
|
||||
|
||||
if command_and_dictation_forms:
|
||||
self.command_and_dictation_forms = (
|
||||
[command_and_dictation_forms]
|
||||
if isinstance(command_and_dictation_forms, str)
|
||||
else command_and_dictation_forms
|
||||
)
|
||||
|
||||
if command_forms:
|
||||
self.command_forms = (
|
||||
[command_forms] if isinstance(command_forms, str) else command_forms
|
||||
)
|
||||
|
||||
currency_symbols = [
|
||||
Symbol("$", ["dollar sign"], ["dollar"]),
|
||||
Symbol("£", ["pound sign"], ["pound"]),
|
||||
]
|
||||
|
||||
symbols = [
|
||||
Symbol("`", ["back tick"], ["grave"]),
|
||||
Symbol(",", ["comma", "coma"]),
|
||||
Symbol(".", ["period", "full stop"], ["dot", "point"]),
|
||||
Symbol(";", ["semicolon"]),
|
||||
Symbol(":", ["colon"]),
|
||||
Symbol("?", ["question mark"], ["question"]),
|
||||
Symbol("!", ["exclamation mark", "exclamation point"], ["bang"]),
|
||||
Symbol("*", ["asterisk"], ["star"]),
|
||||
Symbol("#", ["hash sign", "number sign"], ["hash"]),
|
||||
Symbol("%", ["percent sign"], ["percent"]),
|
||||
Symbol("@", ["at symbol", "at sign"]),
|
||||
Symbol("&", ["ampersand", "and sign"], ["amper"]),
|
||||
Symbol("-", ["hyphen"], ["minus", "dash"]),
|
||||
Symbol("=", None, ["equals"]),
|
||||
Symbol("+", None, ["plus"]),
|
||||
Symbol("~", None, ["tilde"]),
|
||||
Symbol("_", None, ["down score", "underscore"]),
|
||||
Symbol("(", ["paren", "L paren", "left paren"], None),
|
||||
Symbol(")", ["R paren", "right paren"], None),
|
||||
Symbol("[", None,["brack", "L brack", "bracket", "L bracket", "left bracket", "square", "L square", "left square",],),
|
||||
Symbol("]", None, ["R brack", "R bracket", "right bracket", "R square", "right square"]),
|
||||
Symbol("/", ["forward slash"], ["slash"]),
|
||||
Symbol("\\", None, ["backslash"]),
|
||||
Symbol("{", None, ["brace", "L brace", "left brace", "curly bracket", "left curly bracket"],),
|
||||
Symbol("}", None, ["R brace", "right brace","R curly bracket", "right curly bracket"]),
|
||||
Symbol("<", None, ["angle", "L Angle", "left angle", "less than"]),
|
||||
Symbol(">", None, ["rangle", "R angle", "right angle", "greater than"]),
|
||||
Symbol("^", None, ["caret"]),
|
||||
Symbol("|", None, ["pipe"]),
|
||||
Symbol("'", None, ["quote", "apostrophe"]),
|
||||
Symbol('"', None, ["dub quote", "double quote"]),
|
||||
]
|
||||
|
||||
# by convention, symbols should include currency symbols
|
||||
symbols.extend(currency_symbols)
|
||||
|
||||
for symbol in symbols:
|
||||
if symbol.command_and_dictation_forms:
|
||||
for spoken_form in symbol.command_and_dictation_forms:
|
||||
punctuation_dict[spoken_form] = symbol.character
|
||||
symbol_key_dict[spoken_form] = symbol.character
|
||||
dragon_punctuation_dict[spoken_form] = symbol.character
|
||||
|
||||
if symbol.command_forms:
|
||||
for spoken_form in symbol.command_forms:
|
||||
symbol_key_dict[spoken_form] = symbol.character
|
||||
@@ -0,0 +1,13 @@
|
||||
list: user.modifier_key
|
||||
|
||||
|
||||
-
|
||||
alt: alt
|
||||
control: ctrl
|
||||
roll: ctrl
|
||||
shift: shift
|
||||
big: shift
|
||||
# super is the windows key
|
||||
super: super
|
||||
command: ctrl
|
||||
ope: alt
|
||||
@@ -0,0 +1,20 @@
|
||||
list: user.special_key
|
||||
os: windows
|
||||
os: linux
|
||||
-
|
||||
|
||||
end: end
|
||||
home: home
|
||||
minus: minus
|
||||
enter: enter
|
||||
page down: pagedown
|
||||
page up: pageup
|
||||
escape: escape
|
||||
space: space
|
||||
tab: tab
|
||||
insert: insert
|
||||
wipe: backspace
|
||||
delete: backspace
|
||||
forward delete: delete
|
||||
menu key: menu
|
||||
print screen: printscr
|
||||
Reference in New Issue
Block a user