tts-rs/src/backends/tolk.rs

105 lines
2.0 KiB
Rust
Raw Normal View History

2019-03-25 19:15:08 +00:00
#[cfg(windows)]
use log::{info, trace};
use tolk::Tolk as TolkPtr;
use crate::{Backend, Error, Features};
pub struct Tolk(TolkPtr);
impl Tolk {
pub fn new() -> Option<Self> {
2019-03-25 19:15:08 +00:00
info!("Initializing Tolk backend");
let tolk = TolkPtr::new();
if tolk.detect_screen_reader().is_some() {
Some(Tolk(tolk))
} else {
None
}
2019-03-25 19:15:08 +00:00
}
}
impl Backend for Tolk {
fn supported_features(&self) -> Features {
Features {
stop: true,
2020-08-24 21:46:57 +00:00
..Default::default()
2019-03-25 19:15:08 +00:00
}
}
fn speak(&mut self, text: &str, interrupt: bool) -> Result<(), Error> {
2019-03-25 19:15:08 +00:00
trace!("speak({}, {})", text, interrupt);
self.0.speak(text, interrupt);
Ok(())
}
fn stop(&mut self) -> Result<(), Error> {
2019-03-25 19:15:08 +00:00
trace!("stop()");
self.0.silence();
Ok(())
2019-03-25 19:15:08 +00:00
}
fn min_rate(&self) -> f32 {
unimplemented!()
}
fn max_rate(&self) -> f32 {
unimplemented!()
}
fn normal_rate(&self) -> f32 {
unimplemented!()
}
fn get_rate(&self) -> Result<f32, Error> {
2019-03-25 19:15:08 +00:00
unimplemented!();
}
fn set_rate(&mut self, _rate: f32) -> Result<(), Error> {
2019-03-25 19:15:08 +00:00
unimplemented!();
}
fn min_pitch(&self) -> f32 {
unimplemented!()
}
fn max_pitch(&self) -> f32 {
unimplemented!()
}
fn normal_pitch(&self) -> f32 {
unimplemented!()
}
fn get_pitch(&self) -> Result<f32, Error> {
2019-03-25 19:15:08 +00:00
unimplemented!();
}
fn set_pitch(&mut self, _pitch: f32) -> Result<(), Error> {
2019-03-25 19:15:08 +00:00
unimplemented!();
}
fn min_volume(&self) -> f32 {
unimplemented!()
}
fn max_volume(&self) -> f32 {
unimplemented!()
}
fn normal_volume(&self) -> f32 {
unimplemented!()
}
fn get_volume(&self) -> Result<f32, Error> {
2019-03-25 19:15:08 +00:00
unimplemented!();
}
fn set_volume(&mut self, _volume: f32) -> Result<(), Error> {
2019-03-25 19:15:08 +00:00
unimplemented!();
}
fn is_speaking(&self) -> Result<bool, Error> {
unimplemented!()
}
2019-03-25 19:15:08 +00:00
}