Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -169,11 +169,21 @@ async def generate_audio_with_voice_prefix(text_segment, default_voice, rate, pi
|
|
169 |
rate_str = f"{current_rate:+d}%"
|
170 |
pitch_str = f"{current_pitch:+d}Hz"
|
171 |
communicate = edge_tts.Communicate(processed_text, current_voice_short, rate=rate_str, pitch=pitch_str)
|
172 |
-
communicate = strip_silence(communicate, silence_thresh=-40, min_silence_len=100)
|
173 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
174 |
audio_path = tmp_file.name
|
175 |
await communicate.save(audio_path)
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
return None
|
178 |
|
179 |
async def process_transcript_line(line, default_voice, rate, pitch):
|
|
|
169 |
rate_str = f"{current_rate:+d}%"
|
170 |
pitch_str = f"{current_pitch:+d}Hz"
|
171 |
communicate = edge_tts.Communicate(processed_text, current_voice_short, rate=rate_str, pitch=pitch_str)
|
|
|
172 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
173 |
audio_path = tmp_file.name
|
174 |
await communicate.save(audio_path)
|
175 |
+
|
176 |
+
# Load the audio from file
|
177 |
+
audio = AudioSegment.from_mp3(audio_path)
|
178 |
+
|
179 |
+
# Strip silence at start and end
|
180 |
+
audio = strip_silence(audio, silence_thresh=-40, min_silence_len=100)
|
181 |
+
|
182 |
+
# Save the stripped version back to file
|
183 |
+
stripped_path = tempfile.mktemp(suffix=".mp3")
|
184 |
+
audio.export(stripped_path, format="mp3")
|
185 |
+
|
186 |
+
return stripped_path
|
187 |
return None
|
188 |
|
189 |
async def process_transcript_line(line, default_voice, rate, pitch):
|