From 96722d703269cf79a8cd807e3520e8e148b4276b Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Fri, 28 Dec 2018 15:39:50 +0000 Subject: [PATCH] Add basic documentation. --- src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 5a6adb1..86c8c8e 100644 --- a/src/lib.rs +++ b/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); 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>(&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