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

Prepare Backend and Features for synthesis

This commit is contained in:
Bear-03 2022-07-22 17:29:48 +02:00
parent b3d2b788f7
commit bf522b42a7
No known key found for this signature in database
GPG Key ID: 3D1DC5AFDA57B32E
8 changed files with 35 additions and 0 deletions

View File

@ -250,6 +250,7 @@ impl Backend for Android {
utterance_callbacks: true, utterance_callbacks: true,
voice: false, voice: false,
get_voice: false, get_voice: false,
synthesize: false,
} }
} }
@ -284,6 +285,10 @@ impl Backend for Android {
} }
} }
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error> {
unimplemented!();
}
fn stop(&mut self) -> Result<(), Error> { fn stop(&mut self) -> Result<(), Error> {
let vm = Self::vm()?; let vm = Self::vm()?;
let env = vm.get_env()?; let env = vm.get_env()?;

View File

@ -123,6 +123,10 @@ impl Backend for AppKit {
Ok(None) Ok(None)
} }
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error> {
unimplemented!();
}
fn stop(&mut self) -> Result<(), Error> { fn stop(&mut self) -> Result<(), Error> {
trace!("stop()"); trace!("stop()");
unsafe { unsafe {

View File

@ -169,6 +169,7 @@ impl Backend for AvFoundation {
voice: true, voice: true,
get_voice: false, get_voice: false,
utterance_callbacks: true, utterance_callbacks: true,
synthesize: false,
} }
} }
@ -205,6 +206,10 @@ impl Backend for AvFoundation {
Ok(Some(UtteranceId::AvFoundation(utterance))) Ok(Some(UtteranceId::AvFoundation(utterance)))
} }
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error> {
unimplemented!();
}
fn stop(&mut self) -> Result<(), Error> { fn stop(&mut self) -> Result<(), Error> {
trace!("stop()"); trace!("stop()");
unsafe { unsafe {

View File

@ -85,6 +85,7 @@ impl Backend for SpeechDispatcher {
voice: true, voice: true,
get_voice: false, get_voice: false,
utterance_callbacks: true, utterance_callbacks: true,
synthesize: false,
} }
} }
@ -108,6 +109,10 @@ impl Backend for SpeechDispatcher {
} }
} }
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error> {
unimplemented!();
}
fn stop(&mut self) -> Result<(), Error> { fn stop(&mut self) -> Result<(), Error> {
trace!("stop()"); trace!("stop()");
self.0.cancel()?; self.0.cancel()?;

View File

@ -39,6 +39,10 @@ impl Backend for Tolk {
Ok(None) Ok(None)
} }
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error> {
unimplemented!();
}
fn stop(&mut self) -> Result<(), Error> { fn stop(&mut self) -> Result<(), Error> {
trace!("stop()"); trace!("stop()");
self.0.silence(); self.0.silence();

View File

@ -59,6 +59,7 @@ impl Backend for Web {
voice: true, voice: true,
get_voice: true, get_voice: true,
utterance_callbacks: true, utterance_callbacks: true,
synthesize: false,
} }
} }
@ -121,6 +122,10 @@ impl Backend for Web {
} }
} }
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error> {
unimplemented!();
}
fn stop(&mut self) -> Result<(), Error> { fn stop(&mut self) -> Result<(), Error> {
trace!("stop()"); trace!("stop()");
if let Some(window) = web_sys::window() { if let Some(window) = web_sys::window() {

View File

@ -156,6 +156,7 @@ impl Backend for WinRt {
voice: true, voice: true,
get_voice: true, get_voice: true,
utterance_callbacks: true, utterance_callbacks: true,
synthesize: false,
} }
} }
@ -207,6 +208,10 @@ impl Backend for WinRt {
Ok(Some(utterance_id)) Ok(Some(utterance_id))
} }
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error> {
unimplemented!()
}
fn stop(&mut self) -> std::result::Result<(), Error> { fn stop(&mut self) -> std::result::Result<(), Error> {
trace!("stop()"); trace!("stop()");
if !self.is_speaking()? { if !self.is_speaking()? {

View File

@ -162,6 +162,7 @@ unsafe impl Sync for UtteranceId {}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Features { pub struct Features {
pub is_speaking: bool, pub is_speaking: bool,
pub synthesize: bool,
pub pitch: bool, pub pitch: bool,
pub rate: bool, pub rate: bool,
pub stop: bool, pub stop: bool,
@ -217,6 +218,7 @@ pub trait Backend: Clone {
fn id(&self) -> Option<BackendId>; fn id(&self) -> Option<BackendId>;
fn supported_features(&self) -> Features; fn supported_features(&self) -> Features;
fn speak(&mut self, text: &str, interrupt: bool) -> Result<Option<UtteranceId>, Error>; fn speak(&mut self, text: &str, interrupt: bool) -> Result<Option<UtteranceId>, Error>;
fn synthesize(&mut self, text: &str) -> Result<Vec<u8>, Error>;
fn stop(&mut self) -> Result<(), Error>; fn stop(&mut self) -> Result<(), Error>;
fn min_rate(&self) -> f32; fn min_rate(&self) -> f32;
fn max_rate(&self) -> f32; fn max_rate(&self) -> f32;