segmentsFromTrans

fun segmentsFromTrans(trans: TransData, lessonType: LessonType, audioDurationSec: Float, onWarning: (String) -> Unit = { Logger.w(WARN_TAG, it) }): List<Segment>

Build this lesson's Segments from a parsed .trans (TransData), with lessonType as the authority for the mapping:

  • LessonType.SINGAFTER: teacher_vocal/student_vocal window pairs (cross-linked by related_seg) collapse into ONE segment per phrase — reference window from the teacher, student window from the student. Phrases missing a student window get one derived (the gap before the next phrase; the last phrase's own duration clamped to audioDurationSec); phrases with no usable room are dropped.

  • LessonType.SINGALONG: one segment per window; stray student windows are promoted to their own phrases.

Every derivation or drop is reported through onWarning (default: a Napier warning). The lesson-extractor uses the same logic at authoring time; this entry point gives runtime loading of legacy .trans files the identical guarantee.