mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-09-20 22:09:37 +00:00
Add ability to detect screen readers. Windows-only for now, and requires the tolk
feature.
This commit is contained in:
parent
7b8da53d81
commit
4088eb12a1
|
@ -12,6 +12,11 @@ use tts::*;
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let mut tts = Tts::default()?;
|
let mut tts = Tts::default()?;
|
||||||
|
if Tts::screen_reader_available() {
|
||||||
|
println!("A screen reader is available on this platform.");
|
||||||
|
} else {
|
||||||
|
println!("No screen reader is available on this platform.");
|
||||||
|
}
|
||||||
let Features {
|
let Features {
|
||||||
utterance_callbacks,
|
utterance_callbacks,
|
||||||
..
|
..
|
||||||
|
|
17
src/lib.rs
17
src/lib.rs
|
@ -527,6 +527,23 @@ impl Tts {
|
||||||
Err(Error::UnsupportedFeature)
|
Err(Error::UnsupportedFeature)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns `true` if a screen reader is available to provide speech.
|
||||||
|
*/
|
||||||
|
pub fn screen_reader_available() -> bool {
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
#[cfg(feature = "tolk")]
|
||||||
|
{
|
||||||
|
let tolk = tolk::Tolk::new();
|
||||||
|
return tolk.detect_screen_reader().is_some();
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "tolk"))]
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Tts {
|
impl Drop for Tts {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user