mirror of
https://github.com/Priler/jarvis.git
synced 2026-05-26 07:08:11 +00:00
Fix intent classifier init
This commit is contained in:
@@ -99,8 +99,8 @@ fn main() -> Result<(), String> {
|
||||
// init intent-recognition engine
|
||||
let rt = tokio::runtime::Runtime::new().expect("Failed to create tokio runtime");
|
||||
rt.block_on(async {
|
||||
if intent::init(COMMANDS_LIST.get().unwrap()).await.is_err() {
|
||||
error!("Failed to initialize intent classifier");
|
||||
if let Err(e) = intent::init(COMMANDS_LIST.get().unwrap()).await {
|
||||
error!("Failed to initialize intent classifier: {}", e);
|
||||
app::close(1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -157,7 +157,7 @@ pub const VOSK_SPEECH_PARTIAL_WORDS: bool = false;
|
||||
pub const INTENT_CLASSIFIER_MIN_CONFIDENCE: f64 = 0.75;
|
||||
|
||||
// embedding classifier
|
||||
pub const EMBEDDING_MIN_CONFIDENCE: f64 = 0.60;
|
||||
pub const EMBEDDING_MIN_CONFIDENCE: f64 = 0.70;
|
||||
|
||||
// AUDIO PROCESSING DEFAULTS
|
||||
pub const DEFAULT_NOISE_SUPPRESSION: NoiseSuppressionBackend = NoiseSuppressionBackend::None;
|
||||
|
||||
@@ -7,6 +7,8 @@ use crate::{JCommandsList, commands::JCommand, config};
|
||||
use once_cell::sync::OnceCell;
|
||||
use crate::config::structs::IntentRecognitionEngine;
|
||||
|
||||
use crate::DB;
|
||||
|
||||
static IRE_TYPE: OnceCell<IntentRecognitionEngine> = OnceCell::new();
|
||||
|
||||
pub async fn init(commands: &Vec<JCommandsList>) -> Result<(), String> {
|
||||
@@ -15,14 +17,19 @@ pub async fn init(commands: &Vec<JCommandsList>) -> Result<(), String> {
|
||||
} // already initialized
|
||||
|
||||
// set default ire type
|
||||
IRE_TYPE.set(config::DEFAULT_INTENT_RECOGNITION_ENGINE).unwrap();
|
||||
// IRE_TYPE.set(config::DEFAULT_INTENT_RECOGNITION_ENGINE).unwrap();
|
||||
|
||||
// store current ire type
|
||||
IRE_TYPE
|
||||
.set(DB.get().unwrap().read().intent_recognition_engine)
|
||||
.unwrap();
|
||||
|
||||
// load given recorder
|
||||
match IRE_TYPE.get().unwrap() {
|
||||
IntentRecognitionEngine::IntentClassifier => {
|
||||
info!("Initializing IRE backend.");
|
||||
info!("Initializing IntentClassifier IRE backend.");
|
||||
intentclassifier::init(&commands).await?;
|
||||
info!("IRE backend initialized.");
|
||||
info!("IntentClassifier IRE backend initialized.");
|
||||
},
|
||||
IntentRecognitionEngine::EmbeddingClassifier => {
|
||||
info!("Initializing EmbeddingClassifier IRE backend.");
|
||||
|
||||
@@ -48,6 +48,8 @@ pub fn init(commands: &[JCommandsList]) -> Result<(), String> {
|
||||
}
|
||||
}
|
||||
|
||||
// info!("{}", model_dir.display());
|
||||
|
||||
let user_model = UserDefinedEmbeddingModel {
|
||||
onnx_file: std::fs::read(model_dir.join("model.onnx"))
|
||||
.map_err(|e| format!("Failed to read model.onnx: {}", e))?,
|
||||
@@ -194,6 +196,8 @@ pub fn classify(text: &str) -> Result<(String, f64), String> {
|
||||
}
|
||||
}
|
||||
|
||||
debug!("Embedding classify: '{}' -> '{}' ({:.2}%)", text, best_id, best_score * 100.0);
|
||||
|
||||
Ok((best_id, best_score))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user