mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-17 08:29:36 +00:00
Add Tolk backend.
This commit is contained in:
parent
e388934e5e
commit
3bda7bcff4
|
@ -15,6 +15,9 @@ log = "0.4"
|
|||
[dev-dependencies]
|
||||
env_logger = "0.6"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
tolk = { git = "https://github.com/ndarilek/tolk-rs" }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
speech-dispatcher = "0.2"
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
#[cfg(target_os = "linux")]
|
||||
mod speech_dispatcher;
|
||||
|
||||
#[cfg(windows)]
|
||||
mod tolk;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod web;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use self::speech_dispatcher::*;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub use self::tolk::*;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub use self::web::*;
|
||||
|
|
61
src/backends/tolk.rs
Normal file
61
src/backends/tolk.rs
Normal file
|
@ -0,0 +1,61 @@
|
|||
#[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() -> impl Backend {
|
||||
info!("Initializing Tolk backend");
|
||||
let tolk = TolkPtr::new();
|
||||
Tolk(tolk)
|
||||
}
|
||||
}
|
||||
|
||||
impl Backend for Tolk {
|
||||
fn supported_features(&self) -> Features {
|
||||
Features {
|
||||
stop: false,
|
||||
rate: false,
|
||||
pitch: false,
|
||||
volume: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn speak(&self, text: &str, interrupt: bool) -> Result<(), Error> {
|
||||
trace!("speak({}, {})", text, interrupt);
|
||||
self.0.speak(text, interrupt);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop(&self) -> Result<(), Error> {
|
||||
trace!("stop()");
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn get_rate(&self) -> Result<u8, Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn set_rate(&mut self, _rate: u8) -> Result<(), Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn get_pitch(&self) -> Result<u8, Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn set_pitch(&mut self, _pitch: u8) -> Result<(), Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn get_volume(&self) -> Result<u8, Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn set_volume(&mut self, _volume: u8) -> Result<(), Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@ pub enum Backends {
|
|||
SpeechDispatcher,
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Web,
|
||||
#[cfg(windows)]
|
||||
Tolk,
|
||||
}
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
|
@ -75,12 +77,19 @@ impl TTS {
|
|||
let tts = backends::Web::new()?;
|
||||
Ok(TTS(Box::new(tts)))
|
||||
}
|
||||
#[cfg(windows)]
|
||||
Backends::Tolk => {
|
||||
let tts = backends::Tolk::new();
|
||||
Ok(TTS(Box::new(tts)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default() -> Result<TTS, Error> {
|
||||
#[cfg(target_os = "linux")]
|
||||
let tts = TTS::new(Backends::SpeechDispatcher);
|
||||
#[cfg(windows)]
|
||||
let tts = TTS::new(Backends::Tolk);
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let tts = TTS::new(Backends::Web);
|
||||
tts
|
||||
|
|
Loading…
Reference in New Issue
Block a user