pub struct SpeechEngine { /* private fields */ }Expand description
The voice in memory: Kokoro 82M or LFM3 Audio, by the model’s family. Loading takes a while and speaking blocks, so keep it away from the UI thread.
Implementations§
Source§impl SpeechEngine
impl SpeechEngine
Sourcepub fn load(
folder: &ModelFolder,
model: &LocalModel,
) -> Result<Self, EngineError>
pub fn load( folder: &ModelFolder, model: &LocalModel, ) -> Result<Self, EngineError>
Loads model from folder. Kokoro needs model.pth, config.json and its voices;
LFM3 Audio needs model.gguf, projector.gguf and tokenizer.json.
§Errors
When its files are missing or cannot be read.
Sourcepub fn speak(
&mut self,
text: &str,
settings: &SpeechSettings,
go_on: &mut dyn FnMut(usize) -> bool,
) -> Result<Vec<f32>, EngineError>
pub fn speak( &mut self, text: &str, settings: &SpeechSettings, go_on: &mut dyn FnMut(usize) -> bool, ) -> Result<Vec<f32>, EngineError>
Says text as the settings ask. go_on hears how much is ready and returning
false stops it with what it has.
§Errors
When it stops in the middle, or Kokoro is asked for a language other than Portuguese or a speaker it does not have.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SpeechEngine
impl !UnwindSafe for SpeechEngine
impl Freeze for SpeechEngine
impl Send for SpeechEngine
impl Sync for SpeechEngine
impl Unpin for SpeechEngine
impl UnsafeUnpin for SpeechEngine
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more