Switch to line doc comments.

This commit is contained in:
Nolan Darilek 2022-06-13 10:35:32 -05:00
parent 323f129b7b
commit 10ac1021ee
1 changed files with 37 additions and 91 deletions

View File

@ -1,16 +1,14 @@
/*! //! * a Text-To-Speech (TTS) library providing high-level interfaces to a variety of backends.
* a Text-To-Speech (TTS) library providing high-level interfaces to a variety of backends. //! * Currently supported backends are:
* Currently supported backends are: //! * * Windows
* * Windows //! * * Screen readers/SAPI via Tolk (requires `tolk` Cargo feature)
* * Screen readers/SAPI via Tolk (requires `tolk` Cargo feature) //! * * WinRT
* * WinRT //! * * Linux via [Speech Dispatcher](https://freebsoft.org/speechd)
* * Linux via [Speech Dispatcher](https://freebsoft.org/speechd) //! * * MacOS/iOS
* * MacOS/iOS //! * * AppKit on MacOS 10.13 and below
* * AppKit on MacOS 10.13 and below //! * * AVFoundation on MacOS 10.14 and above, and iOS
* * AVFoundation on MacOS 10.14 and above, and iOS //! * * Android
* * Android //! * * WebAssembly
* * WebAssembly
*/
use std::collections::HashMap; use std::collections::HashMap;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
@ -267,9 +265,7 @@ unsafe impl Send for Tts {}
unsafe impl Sync for Tts {} unsafe impl Sync for Tts {}
impl Tts { impl Tts {
/** /// Create a new `TTS` instance with the specified backend.
* Create a new `TTS` instance with the specified backend.
*/
pub fn new(backend: Backends) -> Result<Tts, Error> { pub fn new(backend: Backends) -> Result<Tts, Error> {
let backend = match backend { let backend = match backend {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@ -360,16 +356,12 @@ impl Tts {
tts tts
} }
/** /// Returns the features supported by this TTS engine
* Returns the features supported by this TTS engine
*/
pub fn supported_features(&self) -> Features { pub fn supported_features(&self) -> Features {
self.0.read().unwrap().supported_features() self.0.read().unwrap().supported_features()
} }
/** /// Speaks the specified text, optionally interrupting current speech.
* Speaks the specified text, optionally interrupting current speech.
*/
pub fn speak<S: Into<String>>( pub fn speak<S: Into<String>>(
&mut self, &mut self,
text: S, text: S,
@ -381,9 +373,7 @@ impl Tts {
.speak(text.into().as_str(), interrupt) .speak(text.into().as_str(), interrupt)
} }
/** /// Stops current speech.
* Stops current speech.
*/
pub fn stop(&mut self) -> Result<&Self, Error> { pub fn stop(&mut self) -> Result<&Self, Error> {
let Features { stop, .. } = self.supported_features(); let Features { stop, .. } = self.supported_features();
if stop { if stop {
@ -394,30 +384,22 @@ impl Tts {
} }
} }
/** /// Returns the minimum rate for this speech synthesizer.
* Returns the minimum rate for this speech synthesizer.
*/
pub fn min_rate(&self) -> f32 { pub fn min_rate(&self) -> f32 {
self.0.read().unwrap().min_rate() self.0.read().unwrap().min_rate()
} }
/** /// Returns the maximum rate for this speech synthesizer.
* Returns the maximum rate for this speech synthesizer.
*/
pub fn max_rate(&self) -> f32 { pub fn max_rate(&self) -> f32 {
self.0.read().unwrap().max_rate() self.0.read().unwrap().max_rate()
} }
/** /// Returns the normal rate for this speech synthesizer.
* Returns the normal rate for this speech synthesizer.
*/
pub fn normal_rate(&self) -> f32 { pub fn normal_rate(&self) -> f32 {
self.0.read().unwrap().normal_rate() self.0.read().unwrap().normal_rate()
} }
/** /// Gets the current speech rate.
* Gets the current speech rate.
*/
pub fn get_rate(&self) -> Result<f32, Error> { pub fn get_rate(&self) -> Result<f32, Error> {
let Features { rate, .. } = self.supported_features(); let Features { rate, .. } = self.supported_features();
if rate { if rate {
@ -427,9 +409,7 @@ impl Tts {
} }
} }
/** /// Sets the desired speech rate.
* Sets the desired speech rate.
*/
pub fn set_rate(&mut self, rate: f32) -> Result<&Self, Error> { pub fn set_rate(&mut self, rate: f32) -> Result<&Self, Error> {
let Features { let Features {
rate: rate_feature, .. rate: rate_feature, ..
@ -447,30 +427,22 @@ impl Tts {
} }
} }
/** /// Returns the minimum pitch for this speech synthesizer.
* Returns the minimum pitch for this speech synthesizer.
*/
pub fn min_pitch(&self) -> f32 { pub fn min_pitch(&self) -> f32 {
self.0.read().unwrap().min_pitch() self.0.read().unwrap().min_pitch()
} }
/** /// Returns the maximum pitch for this speech synthesizer.
* Returns the maximum pitch for this speech synthesizer.
*/
pub fn max_pitch(&self) -> f32 { pub fn max_pitch(&self) -> f32 {
self.0.read().unwrap().max_pitch() self.0.read().unwrap().max_pitch()
} }
/** /// Returns the normal pitch for this speech synthesizer.
* Returns the normal pitch for this speech synthesizer.
*/
pub fn normal_pitch(&self) -> f32 { pub fn normal_pitch(&self) -> f32 {
self.0.read().unwrap().normal_pitch() self.0.read().unwrap().normal_pitch()
} }
/** /// Gets the current speech pitch.
* Gets the current speech pitch.
*/
pub fn get_pitch(&self) -> Result<f32, Error> { pub fn get_pitch(&self) -> Result<f32, Error> {
let Features { pitch, .. } = self.supported_features(); let Features { pitch, .. } = self.supported_features();
if pitch { if pitch {
@ -480,9 +452,7 @@ impl Tts {
} }
} }
/** /// Sets the desired speech pitch.
* Sets the desired speech pitch.
*/
pub fn set_pitch(&mut self, pitch: f32) -> Result<&Self, Error> { pub fn set_pitch(&mut self, pitch: f32) -> Result<&Self, Error> {
let Features { let Features {
pitch: pitch_feature, pitch: pitch_feature,
@ -501,30 +471,22 @@ impl Tts {
} }
} }
/** /// Returns the minimum volume for this speech synthesizer.
* Returns the minimum volume for this speech synthesizer.
*/
pub fn min_volume(&self) -> f32 { pub fn min_volume(&self) -> f32 {
self.0.read().unwrap().min_volume() self.0.read().unwrap().min_volume()
} }
/** /// Returns the maximum volume for this speech synthesizer.
* Returns the maximum volume for this speech synthesizer.
*/
pub fn max_volume(&self) -> f32 { pub fn max_volume(&self) -> f32 {
self.0.read().unwrap().max_volume() self.0.read().unwrap().max_volume()
} }
/** /// Returns the normal volume for this speech synthesizer.
* Returns the normal volume for this speech synthesizer.
*/
pub fn normal_volume(&self) -> f32 { pub fn normal_volume(&self) -> f32 {
self.0.read().unwrap().normal_volume() self.0.read().unwrap().normal_volume()
} }
/** /// Gets the current speech volume.
* Gets the current speech volume.
*/
pub fn get_volume(&self) -> Result<f32, Error> { pub fn get_volume(&self) -> Result<f32, Error> {
let Features { volume, .. } = self.supported_features(); let Features { volume, .. } = self.supported_features();
if volume { if volume {
@ -534,9 +496,7 @@ impl Tts {
} }
} }
/** /// Sets the desired speech volume.
* Sets the desired speech volume.
*/
pub fn set_volume(&mut self, volume: f32) -> Result<&Self, Error> { pub fn set_volume(&mut self, volume: f32) -> Result<&Self, Error> {
let Features { let Features {
volume: volume_feature, volume: volume_feature,
@ -555,9 +515,7 @@ impl Tts {
} }
} }
/** /// Returns whether this speech synthesizer is speaking.
* Returns whether this speech synthesizer is speaking.
*/
pub fn is_speaking(&self) -> Result<bool, Error> { pub fn is_speaking(&self) -> Result<bool, Error> {
let Features { is_speaking, .. } = self.supported_features(); let Features { is_speaking, .. } = self.supported_features();
if is_speaking { if is_speaking {
@ -567,9 +525,7 @@ impl Tts {
} }
} }
/** /// Returns list of available voices.
* Returns list of available voices.
*/
pub fn voices(&self) -> Result<Vec<Voice>, Error> { pub fn voices(&self) -> Result<Vec<Voice>, Error> {
let Features { voice, .. } = self.supported_features(); let Features { voice, .. } = self.supported_features();
if voice { if voice {
@ -579,9 +535,7 @@ impl Tts {
} }
} }
/** /// Return the current speaking voice.
* Return the current speaking voice.
*/
pub fn voice(&self) -> Result<Option<Voice>, Error> { pub fn voice(&self) -> Result<Option<Voice>, Error> {
let Features { get_voice, .. } = self.supported_features(); let Features { get_voice, .. } = self.supported_features();
if get_voice { if get_voice {
@ -591,9 +545,7 @@ impl Tts {
} }
} }
/** /// Set speaking voice.
* Set speaking voice.
*/
pub fn set_voice(&mut self, voice: &Voice) -> Result<(), Error> { pub fn set_voice(&mut self, voice: &Voice) -> Result<(), Error> {
let Features { let Features {
voice: voice_feature, voice: voice_feature,
@ -606,9 +558,7 @@ impl Tts {
} }
} }
/** /// Called when this speech synthesizer begins speaking an utterance.
* Called when this speech synthesizer begins speaking an utterance.
*/
pub fn on_utterance_begin( pub fn on_utterance_begin(
&self, &self,
callback: Option<Box<dyn FnMut(UtteranceId)>>, callback: Option<Box<dyn FnMut(UtteranceId)>>,
@ -628,9 +578,7 @@ impl Tts {
} }
} }
/** /// Called when this speech synthesizer finishes speaking an utterance.
* Called when this speech synthesizer finishes speaking an utterance.
*/
pub fn on_utterance_end( pub fn on_utterance_end(
&self, &self,
callback: Option<Box<dyn FnMut(UtteranceId)>>, callback: Option<Box<dyn FnMut(UtteranceId)>>,
@ -650,9 +598,7 @@ impl Tts {
} }
} }
/** /// Called when this speech synthesizer is stopped and still has utterances in its queue.
* Called when this speech synthesizer is stopped and still has utterances in its queue.
*/
pub fn on_utterance_stop( pub fn on_utterance_stop(
&self, &self,
callback: Option<Box<dyn FnMut(UtteranceId)>>, callback: Option<Box<dyn FnMut(UtteranceId)>>,