AI models shared registry + Code cleanup + Better async handling + Some fixes, etc
This commit is contained in:
parent
a8ff3442ff
commit
520b98143f
62 changed files with 1683 additions and 1239 deletions
|
|
@ -5,9 +5,6 @@ use crate::config;
|
|||
use once_cell::sync::OnceCell;
|
||||
|
||||
use crate::config::structs::SpeechToTextEngine;
|
||||
|
||||
use crate::vosk_models;
|
||||
// use vosk_models::{scan_vosk_models, get_model_path, VoskModelInfo};
|
||||
pub use self::vosk::init_vosk;
|
||||
pub use self::vosk::recognize_wake_word;
|
||||
pub use self::vosk::recognize_speech;
|
||||
|
|
@ -16,21 +13,18 @@ pub use self::vosk::reset_wake_recognizer;
|
|||
|
||||
static STT_TYPE: OnceCell<SpeechToTextEngine> = OnceCell::new();
|
||||
|
||||
pub fn init() -> Result<(), ()> {
|
||||
pub fn init() -> Result<(), String> {
|
||||
if STT_TYPE.get().is_some() {
|
||||
return Ok(());
|
||||
} // already initialized
|
||||
}
|
||||
|
||||
// set default stt type
|
||||
// @TODO. Make it configurable?
|
||||
STT_TYPE.set(config::DEFAULT_SPEECH_TO_TEXT_ENGINE).unwrap();
|
||||
STT_TYPE.set(config::DEFAULT_SPEECH_TO_TEXT_ENGINE)
|
||||
.map_err(|_| "STT type already set".to_string())?;
|
||||
|
||||
// load given recorder
|
||||
match STT_TYPE.get().unwrap() {
|
||||
SpeechToTextEngine::Vosk => {
|
||||
// Init Vosk
|
||||
info!("Initializing Vosk STT backend.");
|
||||
vosk::init_vosk();
|
||||
vosk::init_vosk()?;
|
||||
info!("STT backend initialized.");
|
||||
}
|
||||
}
|
||||
|
|
@ -45,9 +39,3 @@ pub fn recognize(data: &[i16], include_partial: bool) -> Option<String> {
|
|||
vosk::recognize_speech(data)
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn recognize(data: &[i16], partial: bool) -> Option<String> {
|
||||
// match STT_TYPE.get().unwrap() {
|
||||
// SpeechToTextEngine::Vosk => vosk::recognize(data, partial),
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue