From f04f7ce9d7583a38c77d2460076592815685ac55 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 14 Apr 2024 00:43:28 +0200 Subject: [PATCH] [tts.picovoice] Better text pre-processing logic. --- platypush/plugins/tts/picovoice/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/platypush/plugins/tts/picovoice/__init__.py b/platypush/plugins/tts/picovoice/__init__.py index 9186eae73..2d2685ea5 100644 --- a/platypush/plugins/tts/picovoice/__init__.py +++ b/platypush/plugins/tts/picovoice/__init__.py @@ -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