2021-01-21 16:49:11 +00:00
|
|
|
#[cfg(all(windows, feature = "tolk"))]
|
2021-05-20 18:59:02 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2019-03-25 19:15:08 +00:00
|
|
|
use log::{info, trace};
|
|
|
|
use tolk::Tolk as TolkPtr;
|
|
|
|
|
2020-09-23 15:31:21 +00:00
|
|
|
use crate::{Backend, BackendId, Error, Features, UtteranceId};
|
2019-03-25 19:15:08 +00:00
|
|
|
|
2020-11-03 03:44:47 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2021-05-20 18:59:02 +00:00
|
|
|
pub(crate) struct Tolk(Arc<TolkPtr>);
|
2019-03-25 19:15:08 +00:00
|
|
|
|
|
|
|
impl Tolk {
|
2020-09-23 17:23:46 +00:00
|
|
|
pub(crate) fn new() -> Option<Self> {
|
2019-03-25 19:15:08 +00:00
|
|
|
info!("Initializing Tolk backend");
|
|
|
|
let tolk = TolkPtr::new();
|
2021-05-20 18:59:02 +00:00
|
|
|
if tolk.detect_screen_reader().is_some() {
|
2020-06-11 18:00:24 +00:00
|
|
|
Some(Tolk(tolk))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
2019-03-25 19:15:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Backend for Tolk {
|
2020-09-23 15:31:21 +00:00
|
|
|
fn id(&self) -> Option<BackendId> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
2019-03-25 19:15:08 +00:00
|
|
|
fn supported_features(&self) -> Features {
|
|
|
|
Features {
|
2019-09-10 15:41:28 +00:00
|
|
|
stop: true,
|
2020-08-24 21:46:57 +00:00
|
|
|
..Default::default()
|
2019-03-25 19:15:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-22 17:40:03 +00:00
|
|
|
fn speak(&mut self, text: &str, interrupt: bool) -> Result<Option<UtteranceId>, Error> {
|
2019-03-25 19:15:08 +00:00
|
|
|
trace!("speak({}, {})", text, interrupt);
|
2020-09-21 20:13:22 +00:00
|
|
|
self.0.speak(text, interrupt);
|
2020-09-22 17:40:03 +00:00
|
|
|
Ok(None)
|
2019-03-25 19:15:08 +00:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:52:18 +00:00
|
|
|
fn stop(&mut self) -> Result<(), Error> {
|
2019-03-25 19:15:08 +00:00
|
|
|
trace!("stop()");
|
2019-09-10 15:41:28 +00:00
|
|
|
self.0.silence();
|
|
|
|
Ok(())
|
2019-03-25 19:15:08 +00:00
|
|
|
}
|
|
|
|
|
Clean up speech synthesis properties, and implement everything for WinRT.
I'd previously attempted to normalize everything to `u8`, but this had some drawbacks:
* It failed to account for some synthesis drivers defining normal as mid-range, while most define it very low.
* It didn't track the normal value for a given synthesizer.
* There was no clean way to map a curve between the minimum, normal, and maximum rates.
Here we track the minimum, normal, and maximum values of rate, pitch, and volume. Sanity checks are done on set.
Also, as a further proof-of-concept, all properties are now implemented for the WinRT driver.
2020-05-18 23:12:59 +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!();
|
|
|
|
}
|
|
|
|
|
Clean up speech synthesis properties, and implement everything for WinRT.
I'd previously attempted to normalize everything to `u8`, but this had some drawbacks:
* It failed to account for some synthesis drivers defining normal as mid-range, while most define it very low.
* It didn't track the normal value for a given synthesizer.
* There was no clean way to map a curve between the minimum, normal, and maximum rates.
Here we track the minimum, normal, and maximum values of rate, pitch, and volume. Sanity checks are done on set.
Also, as a further proof-of-concept, all properties are now implemented for the WinRT driver.
2020-05-18 23:12:59 +00:00
|
|
|
fn set_rate(&mut self, _rate: f32) -> Result<(), Error> {
|
2019-03-25 19:15:08 +00:00
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
Clean up speech synthesis properties, and implement everything for WinRT.
I'd previously attempted to normalize everything to `u8`, but this had some drawbacks:
* It failed to account for some synthesis drivers defining normal as mid-range, while most define it very low.
* It didn't track the normal value for a given synthesizer.
* There was no clean way to map a curve between the minimum, normal, and maximum rates.
Here we track the minimum, normal, and maximum values of rate, pitch, and volume. Sanity checks are done on set.
Also, as a further proof-of-concept, all properties are now implemented for the WinRT driver.
2020-05-18 23:12:59 +00:00
|
|
|
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!();
|
|
|
|
}
|
|
|
|
|
Clean up speech synthesis properties, and implement everything for WinRT.
I'd previously attempted to normalize everything to `u8`, but this had some drawbacks:
* It failed to account for some synthesis drivers defining normal as mid-range, while most define it very low.
* It didn't track the normal value for a given synthesizer.
* There was no clean way to map a curve between the minimum, normal, and maximum rates.
Here we track the minimum, normal, and maximum values of rate, pitch, and volume. Sanity checks are done on set.
Also, as a further proof-of-concept, all properties are now implemented for the WinRT driver.
2020-05-18 23:12:59 +00:00
|
|
|
fn set_pitch(&mut self, _pitch: f32) -> Result<(), Error> {
|
2019-03-25 19:15:08 +00:00
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
Clean up speech synthesis properties, and implement everything for WinRT.
I'd previously attempted to normalize everything to `u8`, but this had some drawbacks:
* It failed to account for some synthesis drivers defining normal as mid-range, while most define it very low.
* It didn't track the normal value for a given synthesizer.
* There was no clean way to map a curve between the minimum, normal, and maximum rates.
Here we track the minimum, normal, and maximum values of rate, pitch, and volume. Sanity checks are done on set.
Also, as a further proof-of-concept, all properties are now implemented for the WinRT driver.
2020-05-18 23:12:59 +00:00
|
|
|
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!();
|
|
|
|
}
|
|
|
|
|
Clean up speech synthesis properties, and implement everything for WinRT.
I'd previously attempted to normalize everything to `u8`, but this had some drawbacks:
* It failed to account for some synthesis drivers defining normal as mid-range, while most define it very low.
* It didn't track the normal value for a given synthesizer.
* There was no clean way to map a curve between the minimum, normal, and maximum rates.
Here we track the minimum, normal, and maximum values of rate, pitch, and volume. Sanity checks are done on set.
Also, as a further proof-of-concept, all properties are now implemented for the WinRT driver.
2020-05-18 23:12:59 +00:00
|
|
|
fn set_volume(&mut self, _volume: f32) -> Result<(), Error> {
|
2019-03-25 19:15:08 +00:00
|
|
|
unimplemented!();
|
|
|
|
}
|
2020-06-02 19:53:14 +00:00
|
|
|
|
|
|
|
fn is_speaking(&self) -> Result<bool, Error> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
2019-03-25 19:15:08 +00:00
|
|
|
}
|