From 0078f3ce9ff1bc268b35a4978ab40368c276d281 Mon Sep 17 00:00:00 2001 From: ChanceNCounter Date: Tue, 24 Nov 2020 12:28:23 -0800 Subject: [PATCH] Fix LF localization error, bump text2speech ver. --- requirements.txt | 3 ++- setup.py | 3 ++- text2speech/modules/mimic2_tts.py | 13 +++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 056c590..2dd8d19 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ psutil gTTS>=2.2.2 voxpopuli # pyee pinned because of mycroft -pyee==8.1.0 \ No newline at end of file +pyee==8.1.0 +lingua_franca>=0.4.2 diff --git a/setup.py b/setup.py index a4c8b59..492e77f 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ setup( name='text2speech', - version='0.2.0a1', + version='0.2.1a1', packages=['text2speech', 'text2speech.modules'], url='https://github.com/HelloChatterbox/text2speech', license='apache', @@ -59,6 +59,7 @@ "psutil", "gTTS>=2.2.1", "pyee==8.1.0", + "lingua_franca>=0.4.2" "voxpopuli"], author_email='jarbasai@mailfence.com', description='TTS engines', diff --git a/text2speech/modules/mimic2_tts.py b/text2speech/modules/mimic2_tts.py index b562e0c..8ff6577 100644 --- a/text2speech/modules/mimic2_tts.py +++ b/text2speech/modules/mimic2_tts.py @@ -7,6 +7,10 @@ from requests.exceptions import ( ReadTimeout, ConnectionError, ConnectTimeout, HTTPError ) + +from lingua_franca.format import pronounce_number +import lingua_franca.config + from urllib import parse import math import base64 @@ -16,6 +20,8 @@ max_sentence_size = 170 +lingua_franca.config.load_langs_on_demand = True + def break_chunks(l, n): """Yield successive n-sized chunks from l.""" @@ -243,10 +249,9 @@ def _normalized_numbers(self, sentence): stf: normalized sentences to speak """ try: - from lingua_franca.format import pronounce_number numbers = re.findall(r'-?\d+', sentence) normalized_num = [ - (num, pronounce_number(int(num))) + (num, pronounce_number(int(num), lang=self.lang)) for num in numbers ] for num, norm_num in normalized_num: @@ -254,7 +259,8 @@ def _normalized_numbers(self, sentence): except TypeError: LOG.exception("type error in mimic2_tts.py _normalized_numbers()") except ImportError: - LOG.warning("lingua_franca not installed, can not normalize numbers") + LOG.warning( + "lingua_franca not installed, can not normalize numbers") return sentence def get_tts(self, sentence, wav_file): @@ -339,4 +345,3 @@ def validate_connection(self): def get_tts_class(self): return Mimic2 -