From 4f4ab5325255f73c54306328da82be51455fc6c8 Mon Sep 17 00:00:00 2001 From: Bear-03 <64696287+Bear-03@users.noreply.github.com> Date: Sat, 23 Jul 2022 14:04:15 +0200 Subject: [PATCH] Add Tts::synthesize method --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 96fdc6a..9a6a55f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -375,6 +375,15 @@ impl Tts { .speak(text.into().as_str(), interrupt) } + pub fn synthesize>(&mut self, text: S) -> Result, 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();