use std::time::Duration;
use sapi_lite::stt::{Recognizer, Rule, SyncContext};
fn main() {
sapi_lite::initialize().unwrap();
println!("The Doors of Durin, Lord of Moria. Speak, friend, and enter.");
let recog = Recognizer::new().unwrap();
let ctx = SyncContext::new(&recog).unwrap();
let grammar = ctx
.grammar_builder()
.add_rule(&Rule::text("friend"))
.build()
.unwrap();
grammar.set_enabled(true).unwrap();
if let Some(phrase) = ctx.recognize(Duration::from_secs(5)).unwrap() {
println!(
"The gate swings open. Welcome to Moria, {}.",
phrase.text.to_string_lossy()
);
} else {
println!("The gate to Moria remains shut.")
}
sapi_lite::finalize();
}