mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-17 10:39:36 +00:00
Add basic documentation.
This commit is contained in:
parent
863ae0e8c3
commit
96722d7032
33
src/lib.rs
33
src/lib.rs
|
@ -1,3 +1,8 @@
|
|||
/*!
|
||||
* a Text-To-Speech (TTS) library providing high-level interfaces to a variety of backends.
|
||||
* Currently supported backends are [Speech Dispatcher](https://freebsoft.org/speechd) (Linux).
|
||||
*/
|
||||
|
||||
use std::boxed::Box;
|
||||
|
||||
mod backends;
|
||||
|
@ -21,6 +26,10 @@ trait Backend {
|
|||
pub struct TTS(Box<Backend>);
|
||||
|
||||
impl TTS {
|
||||
|
||||
/**
|
||||
* Create a new `TTS` instance with the specified backend.
|
||||
*/
|
||||
pub fn new(backend: Backends) -> TTS {
|
||||
match backend {
|
||||
#[cfg(target_os = "linux")]
|
||||
|
@ -28,38 +37,62 @@ impl TTS {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Speaks the specified text, optionally interrupting current speech.
|
||||
*/
|
||||
pub fn speak<S: Into<String>>(&self, text: S, interrupt: bool) -> &Self {
|
||||
self.0.speak(text.into().as_str(), interrupt);
|
||||
self
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops current speech.
|
||||
*/
|
||||
pub fn stop(&self) -> &Self {
|
||||
self.0.stop();
|
||||
self
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current speech rate.
|
||||
*/
|
||||
pub fn get_rate(&self) -> u8 {
|
||||
self.0.get_rate()
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the desired speech rate.
|
||||
*/
|
||||
pub fn set_rate(&self, rate: u8) -> &Self {
|
||||
self.0.set_rate(rate);
|
||||
self
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current speech pitch.
|
||||
*/
|
||||
pub fn get_pitch(&self) -> u8 {
|
||||
self.0.get_pitch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the desired speech pitch.
|
||||
*/
|
||||
pub fn set_pitch(&self, pitch: u8) -> &Self {
|
||||
self.0.set_pitch(pitch);
|
||||
self
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current speech volume.
|
||||
*/
|
||||
pub fn get_volume(&self) -> u8 {
|
||||
self.0.get_volume()
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the desired speech volume.
|
||||
*/
|
||||
pub fn set_volume(&self, volume: u8) -> &Self {
|
||||
self.0.set_volume(volume);
|
||||
self
|
||||
|
|
Loading…
Reference in New Issue
Block a user