mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-08-31 21:59:28 +00:00
Handle missing timestamps by using previous end time for word processing
This commit is contained in:
parent
6b1e9d9128
commit
91b090a457
1 changed files with 10 additions and 2 deletions
|
@ -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(),
|
||||
|
|
Loading…
Add table
Reference in a new issue