Commit
·
8d5faea
1
Parent(s):
0ab542b
Improve text formatting in text_to_speech function to handle punctuation correctly
Browse files
app.py
CHANGED
|
@@ -76,7 +76,11 @@ async def text_to_speech(text, voice, rate, pitch, generate_subtitles=False):
|
|
| 76 |
phrase_start = start_time
|
| 77 |
|
| 78 |
current_phrase.append(boundary)
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
# Determine if we should end this phrase and start a new one
|
| 82 |
should_break = False
|
|
|
|
| 76 |
phrase_start = start_time
|
| 77 |
|
| 78 |
current_phrase.append(boundary)
|
| 79 |
+
|
| 80 |
+
if word in ['.', ',', '!', '?', ':', ';'] or word.startswith(('.', ',', '!', '?', ':', ';')):
|
| 81 |
+
current_text = current_text.rstrip() + word + " "
|
| 82 |
+
else:
|
| 83 |
+
current_text += word + " "
|
| 84 |
|
| 85 |
# Determine if we should end this phrase and start a new one
|
| 86 |
should_break = False
|