Add basic documentation.

This commit is contained in:
Nolan Darilek 2018-12-28 15:39:50 +00:00
parent 863ae0e8c3
commit 96722d7032
1 changed files with 33 additions and 0 deletions

View File

@ -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