Bugfix in timestamping.
This commit is contained in:
1 parent
3db27d620c
commit
3d61f5c377
1 file changed
+18
-2
@@ -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())
|
||||
|
||||
Reference in new issue
Block a user