in hfendpoints-tasks/src/audio/transcription.rs [106:126]
fn new(
text: String,
segments: Option<Vec<Segment>>,
prompt_tokens: Option<usize>,
total_tokens: Option<usize>,
) -> Self {
Self(TranscriptionResponse {
output: match segments {
None => Transcription::Text(text),
Some(segments) => {
Transcription::Detailed(DetailedTranscription { text, segments })
}
},
usage: match (prompt_tokens, total_tokens) {
(None, None) => None,
(Some(prompt), None) => Some(Usage::same(prompt)),
(None, Some(total)) => Some(Usage::new(0, total)),
(Some(prompt), Some(total)) => Some(Usage::new(prompt, total)),
},
})
}