use std::env;
use std::io::{self, Write};
use sapi_lite::audio::{AudioFormat, AudioStream, BitRate, Channels, SampleRate};
use sapi_lite::tts::{SpeechOutput, SyncSynthesizer};
fn main() {
let path = {
if let Some(arg) = env::args().nth(1) {
arg
} else {
println!("Please specify the output pathname on the command line.");
return;
}
};
sapi_lite::initialize().unwrap();
print!("Enter the phrase to speak: ");
io::stdout().flush().unwrap();
let mut speech = String::new();
io::stdin().read_line(&mut speech).unwrap();
let audio_fmt = AudioFormat {
sample_rate: SampleRate::Hz44100,
bit_rate: BitRate::Bits8,
channels: Channels::Stereo,
};
let stream = AudioStream::create_file(path, &audio_fmt).unwrap();
let synth = SyncSynthesizer::new().unwrap();
synth
.set_output(SpeechOutput::Stream(stream), false)
.unwrap();
synth.speak(speech, None).unwrap();
sapi_lite::finalize();
}