Handle missing timestamps by using previous end time for word processing

This commit is contained in:
jondean-kami 2025-07-29 11:24:55 +12:00
parent 6b1e9d9128
commit 91b090a457

View file

@ -278,6 +278,7 @@ class KokoroV1(BaseModelBackend):
f"Processing chunk timestamps with {len(result.tokens)} tokens"
)
if result.pred_dur is not None:
previous_end_time = 0
try:
# Add timestamps with offset
for token in result.tokens:
@ -293,8 +294,15 @@ class KokoroV1(BaseModelBackend):
if not token.text or not token.text.strip():
continue
start_time = float(token.start_ts) + current_offset
end_time = float(token.end_ts) + current_offset
if token.start_ts is None:
start_time = previous_end_time
end_time = start_time
logger.debug(f"Missing timestamp for word '{token.text}'")
else:
start_time = float(token.start_ts) + current_offset
end_time = float(token.end_ts) + current_offset
previous_end_time = end_time
word_timestamps.append(
WordTimestamp(
word=str(token.text).strip(),