Add dummy line THE END
This commit is contained in:
@@ -293,6 +293,9 @@ def format_lines(transcript_data: Dict[str, Any]) -> str:
|
||||
if joined_song:
|
||||
lines.append(f"[00:01](Song) {joined_song}")
|
||||
|
||||
# Track the last utterance for calculating THE END timestamp
|
||||
last_utt = None
|
||||
|
||||
# Format remaining lines (skip those within first 15s as they're in the joined song)
|
||||
for utt in merged:
|
||||
# Skip utterances within opening song window (they're already included in joined_song)
|
||||
@@ -313,6 +316,18 @@ def format_lines(transcript_data: Dict[str, Any]) -> str:
|
||||
timestamp = format_timestamp(utt.get("start", 0))
|
||||
|
||||
lines.append(f"{timestamp}(Speaker {speaker}) {text}")
|
||||
last_utt = utt
|
||||
|
||||
# Add dummy "THE END" line after the last line
|
||||
# Calculate timestamp based on the duration of the last line
|
||||
if last_utt:
|
||||
last_start = last_utt.get("start", 0)
|
||||
last_end = last_utt.get("end", 0)
|
||||
duration = last_end - last_start
|
||||
# THE END timestamp = last line start + duration (same as last line's end time)
|
||||
the_end_time = last_start + duration
|
||||
the_end_timestamp = format_timestamp(the_end_time)
|
||||
lines.append(f"{the_end_timestamp}(Narrator) THE END")
|
||||
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user