#[non_exhaustive]pub struct Transcript { /* private fields */ }Expand description
One clip’s transcription.
§Examples
use cactus_rs::whistle::{Language, Transcript};
let transcript: Transcript = r#"{"text":"Mach das Licht in der Kitche aus.",
"language":"de","ttft_ms":57.4,"decode_tps":182.4}"#
.parse()?;
assert_eq!(transcript.language(), Some(Language::De));
assert!(!transcript.is_empty());Implementations§
Source§impl Transcript
impl Transcript
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
What was said, as one string. Empty for silence.
§Examples
use cactus_rs::whistle::Transcript;
let transcript: Transcript = r#"{"text":"Turn off the kitchen lights."}"#.parse()?;
assert_eq!(transcript.text(), "Turn off the kitchen lights.");Sourcepub fn language(&self) -> Option<Language>
pub fn language(&self) -> Option<Language>
The language the clip was transcribed as: the forced one, or the one detected.
None for silence, which has no language, and for a code this crate does not know;
Transcript::language_code still has that code.
§Examples
use cactus_rs::whistle::{Language, Transcript};
let spoken: Transcript = r#"{"text":"Hallo.","language":"de"}"#.parse()?;
assert_eq!(spoken.language(), Some(Language::De));
let silence: Transcript = r#"{"text":"","language":""}"#.parse()?;
assert_eq!(silence.language(), None);Sourcepub fn language_code(&self) -> &str
pub fn language_code(&self) -> &str
The language code exactly as the engine wrote it, empty for silence.
§Examples
use cactus_rs::whistle::Transcript;
let transcript: Transcript = r#"{"text":"Hello.","language":"en"}"#.parse()?;
assert_eq!(transcript.language_code(), "en");Sourcepub fn words(&self) -> &[Word]
pub fn words(&self) -> &[Word]
Every word with its timing, when word timestamps were asked for; empty otherwise.
§Examples
use cactus_rs::whistle::Transcript;
let transcript: Transcript = r#"{"text":"On.","language":"en",
"words":[{"word":"On.","start":0.16,"end":0.4,"probability":0.85}]}"#
.parse()?;
assert_eq!(transcript.words()[0].word(), "On.");Sourcepub const fn ttft_ms(&self) -> f32
pub const fn ttft_ms(&self) -> f32
Milliseconds until the first token was decoded, which is mostly the encoder’s time.
§Examples
use cactus_rs::whistle::Transcript;
let transcript: Transcript = r#"{"text":"On.","ttft_ms":23.2}"#.parse()?;
assert_eq!(transcript.ttft_ms(), 23.2);Sourcepub const fn decode_tps(&self) -> f32
pub const fn decode_tps(&self) -> f32
Tokens per second while decoding the text.
§Examples
use cactus_rs::whistle::Transcript;
let transcript: Transcript = r#"{"text":"On.","decode_tps":274.8}"#.parse()?;
assert_eq!(transcript.decode_tps(), 274.8);Trait Implementations§
Source§impl Clone for Transcript
impl Clone for Transcript
Source§impl Debug for Transcript
impl Debug for Transcript
Source§impl Default for Transcript
impl Default for Transcript
Source§impl<'de> Deserialize<'de> for Transcript
impl<'de> Deserialize<'de> for Transcript
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromStr for Transcript
Parses a transcription envelope.
impl FromStr for Transcript
Parses a transcription envelope.
Source§impl PartialEq for Transcript
impl PartialEq for Transcript
Source§impl Serialize for Transcript
impl Serialize for Transcript
impl StructuralPartialEq for Transcript
Auto Trait Implementations§
impl Freeze for Transcript
impl RefUnwindSafe for Transcript
impl Send for Transcript
impl Sync for Transcript
impl Unpin for Transcript
impl UnsafeUnpin for Transcript
impl UnwindSafe for Transcript
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more