From e183e3a7bbe2908b2726da8553e30051ea5ab88f Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Wed, 3 Jan 2024 09:36:33 +0000 Subject: [PATCH 1/7] Filtering Demo page removed some of the demo filtering as it was stripping too much from the text. --- templates/admin.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/admin.html b/templates/admin.html index c90bfb1..8cd74f8 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -415,11 +415,11 @@ let textInput = formData.get('text'); let cleanedText = textInput.replace(/ \- | \– /g, ' '); // Replace hyphens cleanedText = cleanedText.replace(/%/g, " percent"); - cleanedText = cleanedText.replace(/([!?.])\1+/g, '$1'); + //cleanedText = cleanedText.replace(/([!?.])\1+/g, '$1'); cleanedText = cleanedText.replace(/[^a-zA-Z0-9\s\.,;:!?\-\'"]/g, ''); cleanedText = cleanedText.replace(/\n+/g, ' '); cleanedText = cleanedText.replace(/\.\s'/g, ".'"); // Remove space between period and single quote - cleanedText = cleanedText.replace(/'/g, ""); // Remove all single quotes + //cleanedText = cleanedText.replace(/'/g, ""); // Remove all single quotes // Set the cleaned text back to the form data formData.set('text', cleanedText); From e9feae12ad2119055ffe4347374d51b4170be1ba Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Wed, 3 Jan 2024 10:50:22 +0000 Subject: [PATCH 2/7] path corrected for word_addin --- tts_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tts_server.py b/tts_server.py index af77c99..2906b96 100644 --- a/tts_server.py +++ b/tts_server.py @@ -1057,7 +1057,7 @@ async def tts_generate( #### Word Add-in Sharing #### ############################# # Mount the static files from the 'word_addin' directory -app.mount('/api/word_addin', StaticFiles(directory='templates/word_addin'), name='word_addin') +app.mount("/api/word_addin", StaticFiles(directory=os.path.join(this_dir / 'templates' / 'word_addin')), name="word_addin") ################################################### #### Webserver Startup & Initial model Loading #### From 0ec580539ab3a43974d7a914cd04d2ba43ea0474 Mon Sep 17 00:00:00 2001 From: nicobubulle Date: Wed, 3 Jan 2024 16:54:25 +0100 Subject: [PATCH 3/7] Regex improvement Add greedy option to avoid apostrophe being removed Add accentuated character for foreign language --- tts_server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tts_server.py b/tts_server.py index 2906b96..65b8035 100644 --- a/tts_server.py +++ b/tts_server.py @@ -1006,7 +1006,7 @@ async def tts_generate( # Replace multiple exclamation marks, question marks, or other punctuation with a single instance cleaned_part = re.sub(r'([!?.])\1+', r'\1', part) # Further clean to remove any other unwanted characters - cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"]', '', cleaned_part) + cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ]\$', '', cleaned_part) # Remove all newline characters (single or multiple) cleaned_part = re.sub(r'\n+', ' ', cleaned_part) output_file = this_dir / "outputs" / f"{output_file_name}_{uuid.uuid4()}_{int(time.time())}.wav" @@ -1030,13 +1030,13 @@ async def tts_generate( cleaned_string = html.unescape(standard_filtering(text_input)) cleaned_string = re.sub(r'([!?.])\1+', r'\1', text_input) # Further clean to remove any other unwanted characters - cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"]', '', cleaned_string) + cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ]\$', '', cleaned_string) # Remove all newline characters (single or multiple) cleaned_string = re.sub(r'\n+', ' ', cleaned_string) elif text_filtering == "standard": cleaned_string = re.sub(r'([!?.])\1+', r'\1', text_input) # Further clean to remove any other unwanted characters - cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"]', '', cleaned_string) + cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ]\$', '', cleaned_string) # Remove all newline characters (single or multiple) cleaned_string = re.sub(r'\n+', ' ', cleaned_string) else: From b11a087dc889ea6764abcd0e7f195081f92e1207 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Wed, 3 Jan 2024 20:57:21 +0000 Subject: [PATCH 4/7] Update tts_server.py # Start Uvicorn Webserver host_parameter = params["ip_address"] port_parameter = int(params["port_number"]) Corrected format --- tts_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tts_server.py b/tts_server.py index 65b8035..9fcb52c 100644 --- a/tts_server.py +++ b/tts_server.py @@ -1087,8 +1087,8 @@ async def read_root(): return HTMLResponse(content=rendered_html, status_code=200) # Start Uvicorn Webserver -host_parameter = {params["ip_address"]} -port_parameter = str(params["port_number"]) +host_parameter = params["ip_address"] +port_parameter = int(params["port_number"]) if __name__ == "__main__": import uvicorn From 67dcc411adc9b2c77ad9abf4730db93dac37360e Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:13:38 +0000 Subject: [PATCH 5/7] Update script.py Extend allowed characters, additional European & Cyrillic characters --- script.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script.py b/script.py index d2a42dd..54f5fe2 100644 --- a/script.py +++ b/script.py @@ -600,7 +600,7 @@ def output_modifier(string, state): # Replace multiple exclamation marks, question marks, or other punctuation with a single instance cleaned_part = re.sub(r'([!?.])\1+', r'\1', part) # Further clean to remove any other unwanted characters - cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"]', '', cleaned_part) + cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\$]', '', cleaned_part) # Remove all newline characters (single or multiple) cleaned_part = re.sub(r'\n+', ' ', cleaned_part) @@ -622,7 +622,7 @@ def output_modifier(string, state): # Replace multiple instances of certain punctuation marks with a single instance cleaned_part = re.sub(r'([!?.])\1+', r'\1', cleaned_part) # Further clean to remove any other unwanted characters - cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"]', '', cleaned_part) + cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\$]', '', cleaned_part) # Remove all newline characters (single or multiple) cleaned_part = re.sub(r'\n+', ' ', cleaned_part) # Process the part and give it a non-character name if being used vai API or standalone. From d0dc9f321281fea80bc173f3b5a316443e63d976 Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:16:21 +0000 Subject: [PATCH 6/7] Update tts_server.py Additional European language & Cyrillic characters --- tts_server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tts_server.py b/tts_server.py index 9fcb52c..a34e8a8 100644 --- a/tts_server.py +++ b/tts_server.py @@ -1006,7 +1006,7 @@ async def tts_generate( # Replace multiple exclamation marks, question marks, or other punctuation with a single instance cleaned_part = re.sub(r'([!?.])\1+', r'\1', part) # Further clean to remove any other unwanted characters - cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ]\$', '', cleaned_part) + cleaned_part = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\$]', '', cleaned_part) # Remove all newline characters (single or multiple) cleaned_part = re.sub(r'\n+', ' ', cleaned_part) output_file = this_dir / "outputs" / f"{output_file_name}_{uuid.uuid4()}_{int(time.time())}.wav" @@ -1030,13 +1030,13 @@ async def tts_generate( cleaned_string = html.unescape(standard_filtering(text_input)) cleaned_string = re.sub(r'([!?.])\1+', r'\1', text_input) # Further clean to remove any other unwanted characters - cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ]\$', '', cleaned_string) + cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\$]', '', cleaned_string) # Remove all newline characters (single or multiple) cleaned_string = re.sub(r'\n+', ' ', cleaned_string) elif text_filtering == "standard": cleaned_string = re.sub(r'([!?.])\1+', r'\1', text_input) # Further clean to remove any other unwanted characters - cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ]\$', '', cleaned_string) + cleaned_string = re.sub(r'[^a-zA-Z0-9\s\.,;:!?\-\'"\u0400-\u04FFÀ-ÿ\$]', '', cleaned_string) # Remove all newline characters (single or multiple) cleaned_string = re.sub(r'\n+', ' ', cleaned_string) else: From abaa56e8f476d058ff8cd5df84f37a4c95c8c49c Mon Sep 17 00:00:00 2001 From: erew123 <35898566+erew123@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:17:23 +0000 Subject: [PATCH 7/7] Update admin.html Additional European and Cyrillic characters --- templates/admin.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/admin.html b/templates/admin.html index 8cd74f8..f815e56 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -416,7 +416,7 @@ let cleanedText = textInput.replace(/ \- | \– /g, ' '); // Replace hyphens cleanedText = cleanedText.replace(/%/g, " percent"); //cleanedText = cleanedText.replace(/([!?.])\1+/g, '$1'); - cleanedText = cleanedText.replace(/[^a-zA-Z0-9\s\.,;:!?\-\'"]/g, ''); + cleanedText = cleanedText.replace(/[^a-zA-Z0-9\s\.,;:!?\-\'"À-ÿ\u0400-\u04FF]/g, ''); cleanedText = cleanedText.replace(/\n+/g, ' '); cleanedText = cleanedText.replace(/\.\s'/g, ".'"); // Remove space between period and single quote //cleanedText = cleanedText.replace(/'/g, ""); // Remove all single quotes @@ -1431,4 +1431,4 @@ - \ No newline at end of file +