Add Tts::synthesize method

This commit is contained in:
Bear-03 2022-07-23 14:04:15 +02:00
parent 91a0f03f1a
commit 4f4ab53252
No known key found for this signature in database
GPG Key ID: 3D1DC5AFDA57B32E
1 changed files with 9 additions and 0 deletions

View File

@ -375,6 +375,15 @@ impl Tts {
.speak(text.into().as_str(), interrupt)
}
pub fn synthesize<S: Into<String>>(&mut self, text: S) -> Result<Vec<u8>, Error> {
let Features { synthesize, .. } = self.supported_features();
if synthesize {
self.0.write().unwrap().synthesize(text.into().as_str())
} else {
Err(Error::UnsupportedFeature)
}
}
/// Stops current speech.
pub fn stop(&mut self) -> Result<&Self, Error> {
let Features { stop, .. } = self.supported_features();