oww-rs 0.3.3

Minimalistic version of the OpenWakeWord inference in Rust and ONNX runtime
Documentation
use crate::config::SpeechUnlockType;
use crate::config::{UnlockConfig};
use log::{debug};

pub const OWW_CZ_NAME_AHOJ_HUGO: &str = "Český - Ahoj Hugo";
pub const OWW_CZ_NAME_ALEXA: &str = "Alexa";
pub const OWW_CZ_NAME_HEY_MYCROFT: &str = "Hey Mycroft";
pub const OWW_CZ_NAME_HEY_JARVIS: &str = "Hey Jarvis";

#[derive(Debug)]
pub struct LanguageModel {
    pub name: String,
    pub selected: bool,
}

impl LanguageModel {
    pub fn new(name: &str, selected: bool) -> Self {
        LanguageModel { name: name.to_string(), selected }
    }
}

pub fn get_trigger_phases(unlock_config: &UnlockConfig) -> Vec<String> {
    match unlock_config.unlock_type {
        SpeechUnlockType::OpenWakeWordAlexa => vec!["Alexa".to_string()],
        SpeechUnlockType::OpenWakeWordHeyMycroft => vec!["Hey Mycroft".to_string()],
        SpeechUnlockType::OpenWakeWordHeyJarvis => vec!["Hey Jarvis".to_string()],
        SpeechUnlockType::OpenWakeWordAhojHugo => vec!["Ahoj Hugo".to_string()],
    }
}

pub fn set_unlock_model(language_model: &LanguageModel) -> Option<UnlockConfig> {
    let unlock_config = UnlockConfig::default(); // load_config(unlock_config_file.clone());

    let model_type = match language_model.name.as_str() {
        OWW_CZ_NAME_ALEXA => SpeechUnlockType::OpenWakeWordAlexa,
        OWW_CZ_NAME_HEY_MYCROFT => SpeechUnlockType::OpenWakeWordHeyMycroft,
        OWW_CZ_NAME_HEY_JARVIS => SpeechUnlockType::OpenWakeWordHeyJarvis,
        OWW_CZ_NAME_AHOJ_HUGO => SpeechUnlockType::OpenWakeWordAhojHugo,
        _ => {
            panic!("Unexpected language model {:?}", language_model);
        }
    };
    let mut new_unlock_config = unlock_config.clone();
    new_unlock_config.unlock_type = model_type;

    debug!("New unlock model config {:?}", new_unlock_config);

    Some(new_unlock_config)
}