2019-09-10 15:41:28 +00:00
|
|
|
use std::io;
|
2018-12-15 15:56:13 +00:00
|
|
|
|
2020-08-12 14:49:51 +00:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
use cocoa_foundation::base::id;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
use cocoa_foundation::foundation::NSRunLoop;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
use objc::{msg_send, sel, sel_impl};
|
|
|
|
|
2019-03-25 16:34:30 +00:00
|
|
|
use tts::*;
|
2018-12-14 19:35:49 +00:00
|
|
|
|
2020-05-18 20:01:28 +00:00
|
|
|
fn main() -> Result<(), 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)?;
|
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
|
|
|
tts.set_rate(tts.max_rate())?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.speak("This is very fast.", false)?;
|
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
|
|
|
tts.set_rate(tts.min_rate())?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.speak("This is very slow.", false)?;
|
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
|
|
|
tts.set_rate(tts.normal_rate())?;
|
|
|
|
tts.speak("This is the normal rate.", false)?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.set_rate(original_rate)?;
|
|
|
|
}
|
|
|
|
let Features { pitch, .. } = tts.supported_features();
|
|
|
|
if pitch {
|
|
|
|
let original_pitch = tts.get_pitch()?;
|
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
|
|
|
tts.set_pitch(tts.max_pitch())?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.speak("This is high-pitch.", false)?;
|
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
|
|
|
tts.set_pitch(tts.min_pitch())?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.speak("This is low pitch.", false)?;
|
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
|
|
|
tts.set_pitch(tts.normal_pitch())?;
|
|
|
|
tts.speak("This is normal pitch.", false)?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.set_pitch(original_pitch)?;
|
|
|
|
}
|
|
|
|
let Features { volume, .. } = tts.supported_features();
|
|
|
|
if volume {
|
|
|
|
let original_volume = tts.get_volume()?;
|
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
|
|
|
tts.set_volume(tts.max_volume())?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.speak("This is loud!", false)?;
|
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
|
|
|
tts.set_volume(tts.min_volume())?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.speak("This is quiet.", false)?;
|
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
|
|
|
tts.set_volume(tts.normal_volume())?;
|
|
|
|
tts.speak("This is normal volume.", false)?;
|
2019-03-25 16:34:30 +00:00
|
|
|
tts.set_volume(original_volume)?;
|
|
|
|
}
|
2020-09-05 08:55:23 +00:00
|
|
|
/* let Features { voices, .. } = tts.supported_features();
|
2020-09-04 13:48:56 +00:00
|
|
|
if voices {
|
|
|
|
let original_voice = tts.voice()?;
|
|
|
|
let voices_list = tts.list_voices();
|
|
|
|
println!("Available voices:\n===");
|
|
|
|
for v in voices_list.iter() {
|
|
|
|
println!("{}",v);
|
|
|
|
tts.set_voice(v)?;
|
|
|
|
println!("voice set");
|
|
|
|
println!("{}", tts.voice()?);
|
|
|
|
tts.speak(v,false)?;
|
|
|
|
}
|
|
|
|
tts.set_voice(original_voice)?;
|
2020-09-05 08:55:23 +00:00
|
|
|
}*/
|
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();
|
2020-08-12 14:49:51 +00:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
{
|
|
|
|
let run_loop: id = unsafe { NSRunLoop::currentRunLoop() };
|
|
|
|
unsafe {
|
|
|
|
let _: () = msg_send![run_loop, run];
|
|
|
|
}
|
|
|
|
}
|
2019-09-10 15:41:28 +00:00
|
|
|
io::stdin().read_line(&mut _input)?;
|
2018-12-30 17:13:48 +00:00
|
|
|
Ok(())
|
2018-12-14 19:35:49 +00:00
|
|
|
}
|