Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -104,9 +104,10 @@ async def generate_audio_with_voice_prefix(text_segment, default_voice, rate, pi
|
|
104 |
print(f"Generated audio duration: {audio_duration_ms}ms, Target duration: {target_duration_ms}ms") # Debug
|
105 |
|
106 |
if audio_duration_ms > target_duration_ms and target_duration_ms > 0:
|
107 |
-
speed_factor = audio_duration_ms / target_duration_ms
|
108 |
print(f"Speed factor (to reduce duration): {speed_factor}") # Debug
|
109 |
if speed_factor > 0:
|
|
|
110 |
y, sr = librosa.load(audio_path, sr=None)
|
111 |
y_stretched = librosa.effects.time_stretch(y, rate=speed_factor)
|
112 |
sf.write(audio_path, y_stretched, sr)
|
|
|
104 |
print(f"Generated audio duration: {audio_duration_ms}ms, Target duration: {target_duration_ms}ms") # Debug
|
105 |
|
106 |
if audio_duration_ms > target_duration_ms and target_duration_ms > 0:
|
107 |
+
speed_factor = (audio_duration_ms / target_duration_ms)
|
108 |
print(f"Speed factor (to reduce duration): {speed_factor}") # Debug
|
109 |
if speed_factor > 0:
|
110 |
+
speed_factor = speed_factor * 0.9 # Reduce the speed adjustment
|
111 |
y, sr = librosa.load(audio_path, sr=None)
|
112 |
y_stretched = librosa.effects.time_stretch(y, rate=speed_factor)
|
113 |
sf.write(audio_path, y_stretched, sr)
|