From 3d61f5c37768a8f7785c2d2e5510c18864410f24 Mon Sep 17 00:00:00 2001 From: translator Date: Thu, 5 Mar 2026 20:08:19 +0900 Subject: [PATCH] Bugfix in timestamping. --- backend/services/lyric_transcriber_service.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/services/lyric_transcriber_service.py b/backend/services/lyric_transcriber_service.py index 6424087..5d4b706 100755 --- a/backend/services/lyric_transcriber_service.py +++ b/backend/services/lyric_transcriber_service.py @@ -837,6 +837,18 @@ def _reconstruct_with_phonemes(phoneme_aligned: dict, original_words_per_seg: li word["phonemes"] = word_chars word["syllables"] = _group_chars_to_syllables(word_chars) + # Restore segment-level text from the now-English word texts. + # After phoneme alignment, seg["text"] still contains the IPA phoneme + # string; without this step every segment's display text is gibberish. + seg_words = seg.get("words", []) + if seg_words: + seg["text"] = " ".join( + w.get("word", "").strip() for w in seg_words + if w.get("word", "").strip() + ) + elif orig: + seg["text"] = " ".join(orig) + return phoneme_aligned @@ -864,8 +876,12 @@ def _apply_pyphen_syllables(segments: list) -> None: text = word_info.get("word", "").strip() if not text: continue - start = float(word_info.get("start") or 0.0) - end = float(word_info.get("end") or start) + _ws = word_info.get("start") + _we = word_info.get("end") + if _ws is None: + continue # skip unaligned words — 'or 0.0' would stamp syllables at t=0 + start = float(_ws) + end = float(_we if _we is not None else _ws) duration = max(end - start, 0.0) positions = dic.positions(text.lower())