vosk usage optimization

This commit is contained in:
Priler 2026-01-05 04:20:43 +05:00
parent cab53abcbe
commit a640e6caea
6 changed files with 305 additions and 108 deletions

View file

@ -8,6 +8,11 @@ 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;
pub use self::vosk::reset_speech_recognizer;
pub use self::vosk::reset_wake_recognizer;
static STT_TYPE: OnceCell<SpeechToTextEngine> = OnceCell::new();
@ -33,9 +38,16 @@ pub fn init() -> Result<(), ()> {
Ok(())
}
pub fn recognize(data: &[i16], partial: bool) -> Option<String> {
match STT_TYPE.get().unwrap() {
SpeechToTextEngine::Vosk => vosk::recognize(data, partial),
pub fn recognize(data: &[i16], include_partial: bool) -> Option<String> {
if include_partial {
vosk::recognize_wake_word(data).map(|(text, _)| text)
} else {
vosk::recognize_speech(data)
}
}
// pub fn recognize(data: &[i16], partial: bool) -> Option<String> {
// match STT_TYPE.get().unwrap() {
// SpeechToTextEngine::Vosk => vosk::recognize(data, partial),
// }
// }