App architecture modifications.
Now GUI and the app itself is divided into two different binaries. The app also provides system tray icon. Whereas the GUI can be used to configure the app.
This commit is contained in:
parent
d4fcb0ea9c
commit
4f3d572b26
232 changed files with 5059 additions and 8081 deletions
36
app/src/stt.rs
Normal file
36
app/src/stt.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
mod vosk;
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
use crate::config;
|
||||
|
||||
use crate::config::structs::SpeechToTextEngine;
|
||||
|
||||
static STT_TYPE: OnceCell<SpeechToTextEngine> = OnceCell::new();
|
||||
|
||||
pub fn init() -> Result<(), ()> {
|
||||
if !STT_TYPE.get().is_none() {return Ok(());} // already initialized
|
||||
|
||||
// set default stt type
|
||||
// @TODO. Make it configurable?
|
||||
STT_TYPE.set(config::DEFAULT_SPEECH_TO_TEXT_ENGINE).unwrap();
|
||||
|
||||
// load given recorder
|
||||
match STT_TYPE.get().unwrap() {
|
||||
SpeechToTextEngine::Vosk => {
|
||||
// Init Vosk
|
||||
info!("Initializing Vosk STT backend.");
|
||||
vosk::init_vosk();
|
||||
info!("STT backend initialized.");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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