1
0
mirror of https://github.com/ndarilek/tts-rs.git synced 2024-11-22 09:09:37 +00:00

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

View File

@ -375,6 +375,15 @@ impl Tts {
.speak(text.into().as_str(), interrupt) .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. /// 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();