chore: remove dead build_karaoke_text, fix stale comments
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -345,7 +345,7 @@ fn find_next_timestamp(text: &str, from: usize) -> Option<(String, usize)> {
|
||||
}
|
||||
|
||||
/// A single spoken line extracted from a YouTube VTT cue.
|
||||
/// Used to build the rolling two-line subtitle display.
|
||||
/// Used to build the paged teleprompter subtitle display.
|
||||
struct SpokenLine {
|
||||
plain_text: String,
|
||||
raw_text: String,
|
||||
@@ -357,8 +357,7 @@ struct SpokenLine {
|
||||
|
||||
/// Extract a flat sequence of spoken lines from YouTube auto-generated VTT content.
|
||||
/// Skips zero-duration transition cues and extracts only the active (karaoke) line
|
||||
/// from two-line cues, ignoring the context line (which is reconstructed from the
|
||||
/// previous SpokenLine during ASS generation).
|
||||
/// from two-line cues.
|
||||
fn extract_spoken_lines(content: &str) -> Vec<SpokenLine> {
|
||||
let normalized = content.replace("\r\n", "\n");
|
||||
let blocks: Vec<&str> = normalized.split("\n\n").collect();
|
||||
@@ -428,26 +427,6 @@ fn extract_spoken_lines(content: &str) -> Vec<SpokenLine> {
|
||||
lines
|
||||
}
|
||||
|
||||
/// Build a karaoke text string with \k tags from a raw VTT line's word timings.
|
||||
fn build_karaoke_text(raw: &str, cue_start: f64, cue_end: f64) -> String {
|
||||
let words = parse_vtt_word_timings(raw, cue_start);
|
||||
if words.len() >= 2 {
|
||||
let mut parts = Vec::new();
|
||||
for (i, (word, start)) in words.iter().enumerate() {
|
||||
let next_start = if i + 1 < words.len() {
|
||||
words[i + 1].1
|
||||
} else {
|
||||
cue_end
|
||||
};
|
||||
let duration_cs = ((next_start - start) * 100.0).round().max(1.0) as u64;
|
||||
parts.push(format!("{{\\k{}}}{}", duration_cs, word));
|
||||
}
|
||||
parts.join(" ")
|
||||
} else {
|
||||
strip_vtt_tags(raw)
|
||||
}
|
||||
}
|
||||
|
||||
/// Group spoken lines into 2-line pages for the teleprompter display.
|
||||
/// If the gap between two consecutive lines exceeds `gap_threshold` seconds,
|
||||
/// the pair is split into separate single-line pages.
|
||||
|
||||
Reference in New Issue
Block a user