Skip to content

Instantly share code, notes, and snippets.

@xenotropic
Last active February 10, 2022 20:47
Show Gist options
  • Save xenotropic/d1ccab53e0bba34f280c93955958afbd to your computer and use it in GitHub Desktop.
Save xenotropic/d1ccab53e0bba34f280c93955958afbd to your computer and use it in GitHub Desktop.
Punctuation and capitalization commands for nerd-dictation
# This is a partial ~/.config/nerd-dictation/nerd-dictation.py file
# I wanted to be able to dictate punctuation and capitalization.
# This is GPLv3, following nerd-dictation's license
# Following vars set the word(s) will capitalize/all caps the next word.
# Make them whatver words suit your fancy
cap_token="capitalize"
all_cap_token="all caps"
TEXT_REPLACE_REGEX = (
("\\b" "data type" "\\b", "data-type"),
("\\b" "copy on write" "\\b", "copy-on-write"),
("\\b" "key word" "\\b", "keyword"),
("\\b" "open quote" "\\b", "“"),
("\\b" "close quote" "\\b", "”"),
("\\b" "quote mark" "\\b", "\\b\""),
("\\b" "open parenthesis" "\\b", "("),
("\\b" "close parenthesis" "\\b", ")"),
("\\b" "new line" "\\b", "\r"),
("full stop", "\\b."), # "period" just comes up too often, this is more unique / not confusable
("commas", "\\b,"), #this doesn't work so well, too many easily confused words like "karma" "come on", you may want to choose another keyword
( cap_token + "\s([a-z]*)", lambda x: x[1].capitalize() ),
( all_cap_token + "\s([a-z]*)", lambda y: y[1].upper() ),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment