Skip to content

Commit 663ecce

Browse files
committed
fix: use actual TTS duration as target_dur in tempo alignment
1 parent 207de50 commit 663ecce

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

youtube_auto_dub/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from youtube_auto_dub.models import (
2020
AUDIO_DEFAULT_AMBIENT_GAIN,
2121
DEFAULT_TTS_ENGINE,
22+
SR_TTS,
2223
TEMP_DIR,
2324
WHISPER_DEFAULT_MODEL,
2425
SubtitleSegment,
@@ -196,9 +197,13 @@ async def run(args) -> None:
196197
if use_tempo:
197198
info_list = []
198199
for seg in project.segments:
200+
tts_dur = 0.0
201+
if seg.tts_audio_path and seg.tts_audio_path.exists():
202+
import soundfile as sf
203+
tts_dur = len(sf.read(seg.tts_audio_path, dtype="float32")[0]) / SR_TTS
199204
info_list.append({
200205
"start": seg.start,
201-
"target_dur": seg.duration,
206+
"target_dur": tts_dur,
202207
"wav_path": seg.tts_audio_path,
203208
})
204209

0 commit comments

Comments
 (0)