pub struct Transcript {
pub schema: String,
pub source_blake3: String,
pub language: String,
pub duration_ms: u64,
pub words: Vec<Word>,
pub vad: Vec<Span>,
pub model: ModelRef,
}Fields§
§schema: String§source_blake3: StringBLAKE3 (or other stable id) of the source this transcript describes. Empty when the producer has no registered source (SRT import, TTS).
language: StringBCP-47 language tag, e.g. “en”.
duration_ms: u64Source audio duration in milliseconds.
words: Vec<Word>§vad: Vec<Span>Voice-activity segments (speech present), sorted, non-overlapping.
model: ModelRefImplementations§
Source§impl Transcript
impl Transcript
Sourcepub fn from_words(
words: &[TimedWord],
language: &str,
duration_ms: Option<u64>,
model: ModelRef,
end_source: EndSource,
) -> Self
pub fn from_words( words: &[TimedWord], language: &str, duration_ms: Option<u64>, model: ModelRef, end_source: EndSource, ) -> Self
Build from timed words; duration_ms is the last word end unless given.
pub fn timed_words(&self) -> Vec<TimedWord>
pub fn validate(&self) -> Result<(), TranscriptError>
Sourcepub fn constrain_duration(
&mut self,
duration_ms: u64,
) -> Result<(), TranscriptError>
pub fn constrain_duration( &mut self, duration_ms: u64, ) -> Result<(), TranscriptError>
Clamps the transcript to registered media of duration_ms without
losing words (ported from CutRight’s constrain_duration).
The effective duration is the smaller of duration_ms and the current
duration_ms, so it never grows. Each word keeps one millisecond per
trailing word before the boundary, so earlier timings stay unchanged
unless they overlap that reserved tail. Words whose timing changed are
marked EndSource::SourceBoundary. VAD spans are clamped and empty
ones dropped. Fails with PastEnd { kind: "word", index: 0 } (leaving
the transcript untouched) when there is less room than words.
pub fn to_json(&self) -> String
Sourcepub fn to_json_with_schema_id(
&self,
schema_id: &str,
) -> Result<String, TranscriptError>
pub fn to_json_with_schema_id( &self, schema_id: &str, ) -> Result<String, TranscriptError>
Serialises with schema_id in place of self.schema, for consumers
that keep emitting an older id. Only ids in ACCEPTED_SCHEMAS are
accepted, so the output always reads back; any other id is
TranscriptError::Schema. self is not modified.
Sourcepub fn from_json(s: &str) -> Result<Self, TranscriptError>
pub fn from_json(s: &str) -> Result<Self, TranscriptError>
Parse and validate. Accepts every id in ACCEPTED_SCHEMAS. Unknown
fields are ignored; use Transcript::from_json_strict to reject them.
Sourcepub fn from_json_strict(s: &str) -> Result<Self, TranscriptError>
pub fn from_json_strict(s: &str) -> Result<Self, TranscriptError>
Parse and validate, rejecting any unknown field at every level (top
level, words, VAD spans, model). Accepts the same ids and values as
Transcript::from_json.