Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,17 +28,12 @@ def strip_silence(audio: AudioSegment, silence_thresh=-40, min_silence_len=100,
|
|
| 28 |
end_trim = nonsilent[-1][1]
|
| 29 |
# Add padding before and after the trimmed audio
|
| 30 |
# Ensure the padding doesn't exceed the trimmed boundaries
|
| 31 |
-
|
| 32 |
if not check1:
|
| 33 |
silence_padding_ms=00
|
| 34 |
start_trim = max(0, start_trim - silence_padding_ms) # Ensure no negative start
|
| 35 |
end_trim = min(len(audio), end_trim + silence_padding_ms) # Ensure end doesn't go past audio length
|
| 36 |
# Return the trimmed and padded audio
|
| 37 |
# Debugging: print input arguments
|
| 38 |
-
print(f"Audio length: {len(audio)} ms")
|
| 39 |
-
print(f"Silence threshold: {silence_thresh} dB")
|
| 40 |
-
print(f"Minimum silence length: {min_silence_len} ms")
|
| 41 |
-
print(f"Silence padding: {silence_padding_ms} ms")
|
| 42 |
print(f"Check1: {check1}**")
|
| 43 |
return audio[start_trim:end_trim]
|
| 44 |
|
|
@@ -188,12 +183,12 @@ async def process_transcript_line(line, default_voice, rate, pitch):
|
|
| 188 |
check1 = False # set it to False
|
| 189 |
continue
|
| 190 |
if process_next and part.strip():
|
| 191 |
-
#if part == split_parts[-1]: # check if this is laster iteration,
|
| 192 |
-
# check1 = False # set it to False
|
| 193 |
audio_path = await generate_audio_with_voice_prefix(part, default_voice, rate, pitch)
|
| 194 |
if audio_path:
|
| 195 |
audio_segments.append(audio_path)
|
| 196 |
elif not process_next and part.strip():
|
|
|
|
|
|
|
| 197 |
audio_path = await generate_audio_with_voice_prefix(part, default_voice, rate, pitch) # Process unquoted text with default voice
|
| 198 |
if audio_path:
|
| 199 |
audio_segments.append(audio_path)
|
|
|
|
| 28 |
end_trim = nonsilent[-1][1]
|
| 29 |
# Add padding before and after the trimmed audio
|
| 30 |
# Ensure the padding doesn't exceed the trimmed boundaries
|
|
|
|
| 31 |
if not check1:
|
| 32 |
silence_padding_ms=00
|
| 33 |
start_trim = max(0, start_trim - silence_padding_ms) # Ensure no negative start
|
| 34 |
end_trim = min(len(audio), end_trim + silence_padding_ms) # Ensure end doesn't go past audio length
|
| 35 |
# Return the trimmed and padded audio
|
| 36 |
# Debugging: print input arguments
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
print(f"Check1: {check1}**")
|
| 38 |
return audio[start_trim:end_trim]
|
| 39 |
|
|
|
|
| 183 |
check1 = False # set it to False
|
| 184 |
continue
|
| 185 |
if process_next and part.strip():
|
|
|
|
|
|
|
| 186 |
audio_path = await generate_audio_with_voice_prefix(part, default_voice, rate, pitch)
|
| 187 |
if audio_path:
|
| 188 |
audio_segments.append(audio_path)
|
| 189 |
elif not process_next and part.strip():
|
| 190 |
+
if part == split_parts[-1]: # check if this is laster iteration,
|
| 191 |
+
check1 = True # set it to True
|
| 192 |
audio_path = await generate_audio_with_voice_prefix(part, default_voice, rate, pitch) # Process unquoted text with default voice
|
| 193 |
if audio_path:
|
| 194 |
audio_segments.append(audio_path)
|