2018-01-12 17:28:39 +00:00
|
|
|
use speech_dispatcher::*;
|
2020-08-19 22:28:22 +00:00
|
|
|
use std::io;
|
2018-01-12 17:28:39 +00:00
|
|
|
|
2021-11-19 14:38:17 +00:00
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
2019-12-23 14:03:24 +00:00
|
|
|
let connection = speech_dispatcher::Connection::open(
|
|
|
|
"hello_world",
|
|
|
|
"hello_world",
|
|
|
|
"hello_world",
|
2020-08-19 22:28:22 +00:00
|
|
|
Mode::Threaded,
|
2021-11-19 14:38:17 +00:00
|
|
|
)?;
|
2020-09-25 15:36:00 +00:00
|
|
|
connection.on_begin(Some(Box::new(|msg_id, client_id| {
|
2020-08-20 01:59:48 +00:00
|
|
|
println!("Beginning {} from {}", msg_id, client_id)
|
2020-09-25 15:36:00 +00:00
|
|
|
})));
|
|
|
|
connection.on_end(Some(Box::new(|msg_id, client_id| {
|
2020-08-20 01:59:48 +00:00
|
|
|
println!("Ending {} from {}", msg_id, client_id)
|
2020-09-25 15:36:00 +00:00
|
|
|
})));
|
2019-12-23 14:03:24 +00:00
|
|
|
connection.say(
|
|
|
|
Priority::Important,
|
2020-08-20 01:59:48 +00:00
|
|
|
format!(
|
|
|
|
"Hello, world at rate {} from client {}.",
|
|
|
|
connection.get_voice_rate(),
|
|
|
|
connection.client_id()
|
|
|
|
),
|
2019-12-23 14:03:24 +00:00
|
|
|
);
|
2018-01-12 17:28:39 +00:00
|
|
|
connection.set_voice_rate(100);
|
2018-06-13 01:35:51 +00:00
|
|
|
connection.say(Priority::Important, "This is faster.");
|
2018-01-12 17:28:39 +00:00
|
|
|
connection.set_voice_rate(0);
|
|
|
|
connection.set_spelling(true);
|
2018-06-13 01:35:51 +00:00
|
|
|
connection.say(Priority::Important, "This is spelled.");
|
2018-01-12 17:28:39 +00:00
|
|
|
connection.set_spelling(false);
|
|
|
|
connection.set_punctuation(Punctuation::All);
|
2019-12-23 14:03:24 +00:00
|
|
|
connection.say(
|
|
|
|
Priority::Important,
|
|
|
|
"This statement, unlike others, has punctuation that is spoken!",
|
|
|
|
);
|
2018-01-12 17:28:39 +00:00
|
|
|
connection.set_punctuation(Punctuation::None);
|
2020-08-19 22:28:22 +00:00
|
|
|
let mut _input = String::new();
|
|
|
|
io::stdin().read_line(&mut _input).unwrap();
|
2021-11-19 14:38:17 +00:00
|
|
|
Ok(())
|
2018-01-12 17:28:39 +00:00
|
|
|
}
|