Struct Engine

Source
pub struct Engine { /* private fields */ }
Expand description

A Pico TTS engine.

Implementations§

Source§

impl Engine

Source

pub fn put_text( &mut self, utf8_text: impl AsRef<[u8]>, ) -> Result<usize, PicoError>

Puts UTF-8 text to be spoken into the TTS engine. Returns the number of bytes of utf8_text that were in fact put in the engine (or a PicoError on failure).

Put null terminators (\0) in the text to flush the engine, forcing speech generation.

§See

ttspico_sys::pico_putTextUtf8.

Source

pub fn flush(&mut self) -> Result<usize, PicoError>

Flushes the TTS engine, forcing speech generation. Equivalent to `self.put_text(“\0”).

Source

pub fn reset(&mut self, mode: EngineResetMode) -> Result<(), PicoError>

Resets the TTS engine according to mode.

§See

ttspico_sys::pico_resetEngine.

Source

pub fn get_data( &mut self, buf: impl AsMut<[i16]>, ) -> Result<(usize, EngineStatus), PicoError>

Generates speech audio from the text input via put_text, outputting to buf.
Returns either a <number of samples generated, EngineStatus after stepping> pair (on success) or a PicoError (on failure).

Output data is encoded as 16-bit signed PCM, at a sample rate of 16kHz. buf should have length <= PICO_INT16_MAX.

§See

ttspico_sys::pico_getData.

Trait Implementations§

Source§

impl Debug for Engine

Source§

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

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

impl PartialEq for Engine

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Engine

Source§

impl Send for Engine

Auto Trait Implementations§

§

impl Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl !Sync for Engine

§

impl Unpin for Engine

§

impl !UnwindSafe for Engine

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.