diff --git a/sentence_api/main.py b/sentence_api/main.py index 6c34336..c1173af 100644 --- a/sentence_api/main.py +++ b/sentence_api/main.py @@ -566,7 +566,7 @@ def _align_share_audio(audio_path: Path, target_seconds: float, transcriber: Tra start_seconds = max(0.0, min(segment.start_seconds for segment in speech_segments) - 0.05) end_seconds = min( _media_duration_seconds(audio_path), - max(segment.end_seconds for segment in speech_segments) + 0.08, + max(segment.end_seconds for segment in speech_segments) + 0.58, ) if end_seconds <= start_seconds + 0.1: return @@ -575,7 +575,8 @@ def _align_share_audio(audio_path: Path, target_seconds: float, transcriber: Tra "silenceremove=start_periods=1:start_threshold=-45dB:start_silence=0.03" ] if target_seconds > 0.2: - speed_factor = (end_seconds - start_seconds) / target_seconds + speech_seconds = max(0.1, end_seconds - start_seconds - 0.5) + speed_factor = speech_seconds / target_seconds if 0.5 <= speed_factor <= 2.0: filters.append(f"atempo={speed_factor:.6f}")