Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,9 @@ async def text_to_speech(text, voice, rate, pitch):
|
|
37 |
if not voice:
|
38 |
return None, gr.Warning("Please select a voice.")
|
39 |
|
40 |
-
|
|
|
|
|
41 |
audio_files = []
|
42 |
for paragraph in paragraphs:
|
43 |
audio_path = await paragraph_to_speech(paragraph, voice, rate, pitch)
|
|
|
37 |
if not voice:
|
38 |
return None, gr.Warning("Please select a voice.")
|
39 |
|
40 |
+
# Split by two or more newline characters, optionally preceded by carriage returns
|
41 |
+
paragraphs = [p for p in re.split(r'\r?\n\r?\n+', text) if p.strip()]
|
42 |
+
|
43 |
audio_files = []
|
44 |
for paragraph in paragraphs:
|
45 |
audio_path = await paragraph_to_speech(paragraph, voice, rate, pitch)
|