2019-09-10 15:41:28 +00:00
|
|
|
use std::io;
|
2018-12-15 15:56:13 +00:00
|
|
|
use std::u8;
|
|
|
|
|
2019-03-25 16:34:30 +00:00
|
|
|
use tts::*;
|
2018-12-14 19:35:49 +00:00
|
|
|
|
2018-12-30 17:13:48 +00:00
|
|
|
fn main() -> Result<(), std::io::Error> {
|
2018-12-14 19:35:49 +00:00
|
|
|
env_logger::init();
|
2018-12-30 17:13:48 +00:00
|
|
|
let mut tts = TTS::default()?;
|
|
|
|
tts.speak("Hello, world.", false)?;
|
2019-03-25 16:34:30 +00:00
|
|
|
let Features { rate, .. } = tts.supported_features();
|
|
|
|
if rate {
|
|
|
|
let original_rate = tts.get_rate()?;
|
|
|
|
tts.speak(format!("Current rate: {}", original_rate), false)?;
|
|
|
|
tts.set_rate(u8::MAX)?;
|
|
|
|
tts.speak("This is very fast.", false)?;
|
|
|
|
tts.set_rate(0)?;
|
|
|
|
tts.speak("This is very slow.", false)?;
|
|
|
|
tts.set_rate(original_rate)?;
|
|
|
|
}
|
|
|
|
let Features { pitch, .. } = tts.supported_features();
|
|
|
|
if pitch {
|
|
|
|
let original_pitch = tts.get_pitch()?;
|
|
|
|
tts.set_pitch(u8::MAX)?;
|
|
|
|
tts.speak("This is high-pitch.", false)?;
|
|
|
|
tts.set_pitch(0)?;
|
|
|
|
tts.speak("This is low pitch.", false)?;
|
|
|
|
tts.set_pitch(original_pitch)?;
|
|
|
|
}
|
|
|
|
let Features { volume, .. } = tts.supported_features();
|
|
|
|
if volume {
|
|
|
|
let original_volume = tts.get_volume()?;
|
|
|
|
tts.set_volume(u8::MAX)?;
|
|
|
|
tts.speak("This is loud!", false)?;
|
|
|
|
tts.set_volume(0)?;
|
|
|
|
tts.speak("This is quiet.", false)?;
|
|
|
|
tts.set_volume(original_volume)?;
|
|
|
|
}
|
2018-12-30 17:13:48 +00:00
|
|
|
tts.speak("Goodbye.", false)?;
|
2019-09-10 15:41:28 +00:00
|
|
|
let mut _input = String::new();
|
|
|
|
io::stdin().read_line(&mut _input)?;
|
2018-12-30 17:13:48 +00:00
|
|
|
Ok(())
|
2018-12-14 19:35:49 +00:00
|
|
|
}
|