Open ChristianNext opened 2 years ago
In your configuration file, add something like this. It capitalizes the first letter after a period, exclamation mark, or question mark.
import re
def nerd_dictation_process(text):
#...
# Add sentence case
REGEX_SENTENCE = re.compile(r"[\.?!] [a-z]")
def apply_sentence_case(match):
return match.group(0).upper()
text = REGEX_SENTENCE.sub(apply_sentence_case, text)
#...
return text
Works brilliantly, many tks! nerd-dictation is a great time saver for me and works like a charm, fantastic work.
Capitalizing sentence beginning might be a common request. I suggest it be added as a command-line option or to nerd_dictation_process.py
Hi !
Thank you for your contribution. Could you tell me exactly where I should copy your text? It may seem strange but I get an error message.
Failed to run "/home/bernard/.config/nerd-dictation/nerd-dictation.py" with error: unexpected indent (nerd-dictation.py, line 159)
This corresponds to return text
As I understood it, I inserted it after :
# Main Processing Function
def nerd_dictation_process(text):
for match, replacement in TEXT_REPLACE_REGEX:
text = match.sub(replacement, text)
words[i] = w
# Add sentence case
REGEX_SENTENCE = re.compile(r"[\.?!] [a-z]")
def apply_sentence_case(match):
return match.group(0).upper()
text = REGEX_SENTENCE.sub(apply_sentence_case, text)
return text
I think there is an error somewhere! Can you tell me where to put
return text
?
Thank you.
Translated with www.DeepL.com/Translator (free version)
A note that the workaround only seems to work if you are inserting the punctuation via voice typing rather than using the keyboard for punctuation together with the voice for the text since it is not the actual text in the input box that is analyzed, just the text that is spoken. So you would need to use this in combnation with osmething like https://github.com/ideasman42/nerd-dictation/blob/main/examples/default/nerd-dictation.py
We can release small and fast (50mb) autopunctuation/capitalization model soon btw.
Wow, that is great! Looking forward to that being available!
--full-sentence --punctuate-from-previous-timeout 2
This only capitalizes the first sentence, but not subsequent, plse advise.