pub trait Module {
type Error: Error + 'static;
// Required methods
fn config(&mut self, config_path: Option<&Path>) -> Result<(), Self::Error>;
fn init(&mut self) -> Result<String, Self::Error>;
fn list_voices(&mut self) -> Result<Voices, Self::Error>;
fn set_param(&mut self, param: Param) -> Result<bool, Self::Error>;
fn speak(
&mut self,
utterance: &str,
msg_type: Message,
) -> Result<(), Self::Error>;
fn speak_sync(
&mut self,
utterance: &str,
msg_type: Message,
) -> Result<(), Self::Error>;
fn pause(&mut self) -> Result<(), Self::Error>;
fn stop(&mut self) -> Result<(), Self::Error>;
fn audio_ctx(&mut self) -> &mut Context;
fn loglevel_set(
&mut self,
level: BoundedU8<0, 5>,
) -> Result<(), Self::Error>;
fn debug(&mut self, path: Option<&Path>) -> Result<(), Self::Error>;
}Required Associated Types§
Required Methods§
Sourcefn list_voices(&mut self) -> Result<Voices, Self::Error>
fn list_voices(&mut self) -> Result<Voices, Self::Error>
List available voices
Sourcefn set_param(&mut self, param: Param) -> Result<bool, Self::Error>
fn set_param(&mut self, param: Param) -> Result<bool, Self::Error>
Update speech parameter
See the supplied Param struct for a list of all recognized
parameters and their meaning.
If you need a storage container for received parameters consider using
the Params type in your code, otherwise you can also directly
update whatever internal state your code associates with the given
parameter without storing an extra copy. Parameters are only ever
written by the speech-dispatcher server, never read.
Return Result::Err to indicate an internal error (will be logged),
otherwise return an boolean indicating whether the given parameter is
supported by your output module or not.
Sourcefn speak(
&mut self,
utterance: &str,
msg_type: Message,
) -> Result<(), Self::Error>
Available on crate features async only.
fn speak( &mut self, utterance: &str, msg_type: Message, ) -> Result<(), Self::Error>
async only.Queue asynchronous speech
Your module should only check that it can speak the given utterance and
pass queue it for asynchronous processing in this function, not
generate the full utterance in this function. Disable the async
feature if you prefer synchronous processing.
You do not have to call modapi::module_speak_ok or
modapi::module_speak_error yourself, the framework will do so if you
return an error response.
Sourcefn speak_sync(
&mut self,
utterance: &str,
msg_type: Message,
) -> Result<(), Self::Error>
Available on non-crate feature async only.
fn speak_sync( &mut self, utterance: &str, msg_type: Message, ) -> Result<(), Self::Error>
async only.Perform synchronous speech
Your module should call notify_speak_ok after
ensuring that it can speak the given utterance, but before doing any
resource-intensive work to actually generate the spoken word.
It is recommended that module try to implement asynchorous background
processing and enable the async feature if possible.
You do not have to call modapi::module_speak_error yourself, the
framework will do so if you return an error response.
TODO: Pass a callback struct as parameter to report speak_ok/stop/pause/index_mark
TODO: Also let users call module_process here and somehow return async events maybe?
Sourcefn pause(&mut self) -> Result<(), Self::Error>
fn pause(&mut self) -> Result<(), Self::Error>
Pause
TODO: Document semantics, really want this to not part of sync and instead return those from process
Sourcefn stop(&mut self) -> Result<(), Self::Error>
fn stop(&mut self) -> Result<(), Self::Error>
Stop
TODO: Document semantics, really want this to not part of sync and instead return those from process
Sourcefn audio_ctx(&mut self) -> &mut Context
Available on crate features audio only.
fn audio_ctx(&mut self) -> &mut Context
audio only.Retrieve audio context object
When implementing this, simply make sure you create and store an
instance of audio::Context in your implementation and return it from
this callback.
Sourcefn loglevel_set(&mut self, level: BoundedU8<0, 5>) -> Result<(), Self::Error>
Available on non-crate feature logger only.
fn loglevel_set(&mut self, level: BoundedU8<0, 5>) -> Result<(), Self::Error>
logger only.Set the output verbosity level
A level or 0 means “no output”, while a level of 5 means
maximum/“trace” level verbosity, see section 2.4.7 (“Log Levels”) of
the speech-dispatcher manual for the list of standard logging levels.
Note: As an alternatice, there is an integrated logging framework
based on flexi_logger available when enabling the logger feature.
Sourcefn debug(&mut self, path: Option<&Path>) -> Result<(), Self::Error>
Available on non-crate feature logger only.
fn debug(&mut self, path: Option<&Path>) -> Result<(), Self::Error>
logger only.Enable or disable debug logging into the given file
If path is given, log to the given path, otherwise disable debug
logging.
Note: As an alternatice, there is an integrated logging framework
based on flexi_logger available when enabling the logger feature.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".