Skip to main content

Transcript

Struct Transcript 

Source
#[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

Source

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.");
Source

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);
Source

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");
Source

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.");
Source

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);
Source

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);
Source

pub fn is_empty(&self) -> bool

Whether nothing was recognised: silence, noise or an empty clip.

§Examples
use cactus_rs::whistle::Transcript;

let silence: Transcript = r#"{"text":"","language":""}"#.parse()?;
assert!(silence.is_empty());

Trait Implementations§

Source§

impl Clone for Transcript

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transcript

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Transcript

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Transcript

Source§

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.

Source§

fn from_str(s: &str) -> Result<Self>

§Errors

Returns Error::Envelope when the text is not the JSON this crate expects.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl PartialEq for Transcript

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Transcript

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Transcript

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.