vosk usage optimization
This commit is contained in:
parent
75edd47d18
commit
bd8e2c989d
6 changed files with 305 additions and 108 deletions
|
|
@ -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),
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue