dictation-toolbox / dragonfly

Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS), Windows Speech Recognition (WSR), Kaldi and CMU Pocket Sphinx
GNU Lesser General Public License v3.0
388 stars 75 forks source link

Formatting of dictated numbers #386

Open drmfinlay opened 9 months ago

drmfinlay commented 9 months ago

Dragonfly's dictation word formatting does not include the transformation of number words into numerals. For example, if, as part of a command using a Dictation element, I say "forty two", the matching rule will receive the words "forty two", instead of the numeral form 42.

Dragon itself has extensive support and configuration for this which would not be feasible to implement in Dragonfly. I think, however, some basic transformations could be done. These would be optional and would use the active dragonfly.language implementation (based on the SR engine language).

drmfinlay commented 7 months ago

Maybe this formatting could be applied with a separate NumeralWordFormatter class with the following function:


def format_words(input, min, max, language=None):
    ...
    ...
    ...

That way it could be used with any engine and could be subclassed to add in contextual spacing for things like phone numbers, if desired.

LexiconCode commented 7 months ago

Maybe this formatting could be applied with a separate NumeralWordFormatter class with the following function:


def format_words(input, min, max, language=None):
    ...
    ...
    ...

That way it could be used with any engine and could be subclassed to add in contextual spacing for things like phone numbers, if desired.

I do like that approach with any engine.

drmfinlay commented 5 months ago

It would be nice if this feature also handled words like 'double', 'triple', 'dot' and 'point'. Of course, things common in one language are often not common in another. Apparently this is the case for double X and triple X. English has this, but the German language, for instance, does not.

So things like this should be done in language-specific functions under dragonfly.language.