forked from platypush/platypush
[tts.picovoice] Better text pre-processing logic.
This commit is contained in:
parent
37d70d67ac
commit
f04f7ce9d7
1 changed files with 5 additions and 5 deletions
|
@ -23,19 +23,19 @@ class TextConversionUtils:
|
|||
"""
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_number_re = re.compile(r'(([0-9]+)|([0-9]+\.[0-9]+)|([0-9]+\,[0-9]+))')
|
||||
_number_re = re.compile(r'(([0-9]+\.[0-9]+)|([0-9]+\,[0-9]+)|([0-9]+))')
|
||||
_conversions_map = {
|
||||
(re.compile(r'[(){}\[\]<>]'), ','),
|
||||
(re.compile(r'[:;]'), '.'),
|
||||
(re.compile(r'[;]'), '.'),
|
||||
(re.compile(r'[@#]'), ' at '),
|
||||
(re.compile(r'[$]'), ' dollar '),
|
||||
(re.compile(r'[%]'), ' percent '),
|
||||
(re.compile(r'[&]'), ', and'),
|
||||
(re.compile(r'[&]'), ' and '),
|
||||
(re.compile(r'[+]'), ' plus '),
|
||||
(re.compile(r'[=]'), ' equals '),
|
||||
(re.compile(r'[|]'), ' or '),
|
||||
(re.compile(r'[~]'), ' tilde '),
|
||||
(re.compile(r'[`\'"]'), ': quote:'),
|
||||
(re.compile(r'[`]'), ''),
|
||||
(re.compile(r'[*]'), ' star '),
|
||||
(re.compile(r'[\\/]'), ' slash '),
|
||||
(re.compile(r'[_]'), ' underscore '),
|
||||
|
@ -51,7 +51,7 @@ class TextConversionUtils:
|
|||
|
||||
while match := cls._number_re.search(text):
|
||||
number = match.group(1).replace(',', '')
|
||||
text = text.replace(number, num2words(int(number)))
|
||||
text = text.replace(number, num2words(float(number)))
|
||||
|
||||
return text
|
||||
|
||||
|
|
Loading…
Reference in a new issue