BETA Fix4 changes

This commit is contained in:
Abraham
2023-04-28 19:05:35 +05:00
parent f88248643b
commit 2c2f0e71fd
38 changed files with 40 additions and 23 deletions

View File

@@ -1 +0,0 @@
[{"assistant_voice":"\"jarvis-remake\"","selected_microphone":"\"0\"","api_key__picovoice":"\"Hl7tfFyDT+S6fLhcT2nngK2qXsbhAwMsrVVp0Y9G0A2IfLlsPTm9eg==\"","api_key__openai":"\"\""},{}]

View File

@@ -3,4 +3,11 @@
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Run C:/Program Files (x86)/Google/Chrome/Application/chrome.exe RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid
RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command
StringGetPos, pos, BrowserFullCommand, ",,1
pos := --pos
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
Run, % BrowserPathandEXE

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -9,6 +9,7 @@ use std::env::current_dir;
// }; // };
pub const COMMANDS_PATH: &str = "commands/"; pub const COMMANDS_PATH: &str = "commands/";
pub const KEYWORDS_PATH: &str = "picovoice/keywords/";
pub const DB_FILE_NAME: &str = "app.db"; pub const DB_FILE_NAME: &str = "app.db";
pub const APP_VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); pub const APP_VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");

View File

@@ -2,11 +2,11 @@ use crate::DB;
#[tauri::command] #[tauri::command]
pub fn db_read(key: &str) -> String { pub fn db_read(key: &str) -> String {
if let Some(value) = DB.lock().unwrap().get(key) { if let Some(value) = DB.lock().unwrap().get::<String>(key) {
value return value
} else {
String::from("")
} }
String::from("")
} }
#[tauri::command] #[tauri::command]

View File

@@ -1,6 +1,7 @@
use porcupine::{BuiltinKeywords, Porcupine, PorcupineBuilder}; use porcupine::{BuiltinKeywords, Porcupine, PorcupineBuilder};
use pv_recorder::RecorderBuilder; use pv_recorder::RecorderBuilder;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::path::Path;
use crate::events::Payload; use crate::events::Payload;
use tauri::Manager; use tauri::Manager;
@@ -47,32 +48,39 @@ pub fn start_listening(app_handle: tauri::AppHandle) -> Result<bool, String> {
// vars // vars
let porcupine: Porcupine; let porcupine: Porcupine;
let picovoice_api_key: String; let mut picovoice_api_key: String = String::from("");
let selected_microphone: i32; let selected_microphone: i32;
let mut start = SystemTime::now(); let mut start = SystemTime::now();
// Retrieve API key from DB // Retrieve API key from DB
if let Some(pkey) = DB.lock().unwrap().get::<String>("api_key__picovoice") { if let Some(pkey) = DB.lock().unwrap().get::<String>("api_key__picovoice") {
picovoice_api_key = pkey; if !pkey.is_empty() {
} else { picovoice_api_key = pkey;
}
}
if picovoice_api_key.is_empty() {
return Err("Picovoice API key is not set!".into()); return Err("Picovoice API key is not set!".into());
} }
// Create instance of Porcupine with the given API key // Create instance of Porcupine with the given API key
if let Ok(pinstance) = match PorcupineBuilder::new_with_keyword_paths(picovoice_api_key, &[Path::new(config::KEYWORDS_PATH).join("jarvis_windows.ppn")])
PorcupineBuilder::new_with_keywords(picovoice_api_key, &[BuiltinKeywords::Jarvis]) .sensitivities(&[1.0f32]) // max sensitivity possible
.sensitivities(&[1.0f32]) // max sensitivity possible .init() {
.init() Ok(pinstance) => {
{ // porcupine successfully initialized with the valid API key
// porcupine successfully initialized with the valid API key println!("Porcupine successfully initialized with the valid API key ...");
porcupine = pinstance; porcupine = pinstance;
} else { }
// something went wrong Err(e) => {
return Err( println!("Porcupine error: either API key is not valid or there is no internet connection");
"Porcupine error: either API key is not valid or there is no internet connection" println!("Error details: {}", e);
.into(), return Err(
); "Porcupine error: either API key is not valid or there is no internet connection"
.into(),
);
}
} }
// Retrieve microphone index // Retrieve microphone index

View File

@@ -40,10 +40,12 @@
"commands", "commands",
"sound", "sound",
"vosk/model_small", "vosk/model_small",
"picovoice",
"libvosk.dll", "libvosk.dll",
"libstdc++-6.dll", "libstdc++-6.dll",
"libwinpthread-1.dll", "libwinpthread-1.dll",
"libgcc_s_seh-1.dll" "libgcc_s_seh-1.dll",
"libpv_recorder.dll"
] ]
}, },
"security": { "security": {