Update app.py
Browse filesSillence method added
app.py
CHANGED
@@ -56,21 +56,22 @@ async def paragraph_to_speech(text, voice, rate, pitch):
|
|
56 |
audio_segments = []
|
57 |
silence_durations = []
|
58 |
parts = re.split(r'(SS\d+\.?\d*)', text)
|
|
|
59 |
for part in parts:
|
60 |
if re.match(r'SS\d+\.?\d*', part):
|
61 |
# At the top of your file:
|
62 |
#SILENCE_PATH = Path(__file__).parent.absolute() / "Silence.mp3"
|
63 |
# At the top of your file (assuming you uploaded "Silence.mp3" to root)
|
64 |
-
SILENCE_PATH = Path(__file__).parent.absolute() / "Silence.mp3"
|
65 |
# At the top of your file:
|
66 |
#SILENCE_PATH = Path(__file__).parent.absolute() / "static" / "intro.mp3"
|
67 |
-
if SILENCE_PATH.exists():
|
68 |
-
|
69 |
-
|
70 |
-
else:
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
|
75 |
elif part.strip():
|
76 |
processed_text = part
|
|
|
56 |
audio_segments = []
|
57 |
silence_durations = []
|
58 |
parts = re.split(r'(SS\d+\.?\d*)', text)
|
59 |
+
silence_duration = float(part[2:]) * 1000 # Convert to milliseconds
|
60 |
for part in parts:
|
61 |
if re.match(r'SS\d+\.?\d*', part):
|
62 |
# At the top of your file:
|
63 |
#SILENCE_PATH = Path(__file__).parent.absolute() / "Silence.mp3"
|
64 |
# At the top of your file (assuming you uploaded "Silence.mp3" to root)
|
65 |
+
#SILENCE_PATH = Path(__file__).parent.absolute() / "Silence.mp3"
|
66 |
# At the top of your file:
|
67 |
#SILENCE_PATH = Path(__file__).parent.absolute() / "static" / "intro.mp3"
|
68 |
+
#if SILENCE_PATH.exists():
|
69 |
+
# audio_segments.append(str(SILENCE_PATH))
|
70 |
+
# print(f"Silence.mp3 file found at {SILENCE_PATH} and is inserted")
|
71 |
+
#else:
|
72 |
+
print(f"Silence.mp3 file NOT FOUND")
|
73 |
+
silence_file_path = get_silence(silence_duration) # Store the returned filename
|
74 |
+
audio_segments.append(silence_file_path) # Use the stored filename
|
75 |
|
76 |
elif part.strip():
|
77 |
processed_text = part
|