Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import tempfile
|
|
6 |
import os
|
7 |
import re # Import the regular expression module
|
8 |
from pathlib import Path
|
|
|
9 |
|
10 |
|
11 |
|
@@ -44,6 +45,11 @@ async def paragraph_to_speech(text, voice, rate, pitch):
|
|
44 |
print(f"Silence.mp3 file found at {SILENCE_PATH} and is inserted")
|
45 |
else:
|
46 |
print(f"Silence.mp3 file NOT FOUND")
|
|
|
|
|
|
|
|
|
|
|
47 |
elif part.strip():
|
48 |
processed_text = part
|
49 |
current_voice = voice
|
|
|
6 |
import os
|
7 |
import re # Import the regular expression module
|
8 |
from pathlib import Path
|
9 |
+
from pydub import AudioSegment
|
10 |
|
11 |
|
12 |
|
|
|
45 |
print(f"Silence.mp3 file found at {SILENCE_PATH} and is inserted")
|
46 |
else:
|
47 |
print(f"Silence.mp3 file NOT FOUND")
|
48 |
+
silent_audio = AudioSegment.silent(duration=1000)
|
49 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
50 |
+
silent_audio.export(tmp_file.name, format="mp3")
|
51 |
+
audio_segments.append(tmp_file.name)
|
52 |
+
|
53 |
elif part.strip():
|
54 |
processed_text = part
|
55 |
current_voice = voice
|