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:
Abraham 2023-06-11 19:17:50 +05:00
parent ea489d5719
commit 1323505b0a
232 changed files with 5059 additions and 8081 deletions

5
app/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
# Generated by Cargo
# will have compiled files and executables
/target/
app.db
log.txt

3341
app/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

35
app/Cargo.toml Normal file
View file

@ -0,0 +1,35 @@
[package]
name = "jarvis-app"
version = "0.0.3"
description = "Jarvis Voice Assistant"
authors = ["Abraham Tugalov"]
license = "GPL-3.0-only"
repository = "https://github.com/Priler/jarvis"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.164", features = ["derive"] }
serde_json = "1.0.96"
hound = "3.5.0"
pv_recorder = "1.1.2"
pv_porcupine = "2.2.1"
seqdiff = "0.3.0"
vosk = "0.2.0"
rand = "0.8.5"
rodio = "0.17.1"
rustpotter = "2.0.0"
log = "0.4.18"
once_cell = "1.18.0"
atomic_enum = "0.2.0"
portaudio = "0.7.0"
platform-dirs = "0.3.0"
simple-log = "1.6.0"
tray-icon = { version = "0.5.1" }
winit = "0.28.6"
image = "0.24.6"
serde_yaml = "0.9.21"
kira = "0.8.3"
[features]

45
app/Makefile.toml Normal file
View file

@ -0,0 +1,45 @@
[tasks.format]
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]
[tasks.clean]
command = "cargo"
args = ["clean"]
[tasks.build_debug]
command = "cargo"
args = ["build"]
[tasks.run]
command = "cargo"
args = ["run"]
[tasks.build_release]
command = "cargo"
args = ["build", "--release"]
dependencies = ["clean"]
[tasks.test]
command = "cargo"
args = ["test"]
# dependencies = ["clean"]
[tasks.post_build]
script_runner = "python"
script_extension = "py"
script = { file = "post_build.py" }
[tasks.debug]
dependencies = [
"format",
"build_debug",
"post_build"
]
[tasks.release]
dependencies = [
"format",
"build_release",
"post_build"
]

4
app/build.rs Normal file
View file

@ -0,0 +1,4 @@
fn main() {
// link to Vosk lib
// println!("cargo:rustc-link-lib=libvosk.dll");
}

View file

@ -0,0 +1,19 @@
; Rerun as admin, if required
If Not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
; set partial title matching mode
SetTitleMatchMode, 2
; list of all browsers to close
GroupAdd, browsers, ahk_class MozillaWindowClass
GroupAdd, browsers, ahk_class IEFrame
GroupAdd, browsers, ahk_exe msedge.exe
GroupAdd, browsers, ahk_exe chrome.exe
GroupAdd, browsers, ahk_exe firefox.exe
; kill them all
Winclose, ahk_group browsers

Binary file not shown.

View file

@ -0,0 +1,11 @@
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
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.

View file

@ -0,0 +1,11 @@
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Include _include.ahk
args = %1%
path := DefaultBrowser()
Run, %path% %args%

Binary file not shown.

View file

@ -0,0 +1,19 @@
DefaultBrowser() {
; Find the Registry key name for the default browser
RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid
; Find the executable command associated with the above Registry key
RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command
; The above RegRead will return the path and executable name of the brower contained within quotes and optional parameters
; We only want the text contained inside the first set of quotes which is the path and executable
; Find the ending quote position (we know the beginning quote is in position 0 so start searching at position 1)
StringGetPos, pos, BrowserFullCommand, ",,1
; Decrement the found position by one to work correctly with the StringMid function
pos := --pos
; Extract and return the path and executable of the browser
StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
Return BrowserPathandEXE
}

View file

@ -0,0 +1,76 @@
list:
- command:
action: ahk
exe_path: ahk/Run browser.exe
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- открой браузер
- открой хром
- гугл хром
- command:
action: ahk
exe_path: ahk/Close browser.exe
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- закрой все браузеры
- закрой браузер
- выключи браузер
- убери браузер
- command:
action: ahk
exe_path: ahk/Run website.exe
exe_args:
- http://google.com
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- открой гугл
- запусти гугл
- перейди в гугл
- command:
action: ahk
exe_path: ahk/Run website.exe
exe_args:
- http://youtube.com
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- открой ютуб
- ютуб
- запусти ютуб
- command:
action: ahk
exe_path: ahk/Run website.exe
exe_args:
- https://translate.google.com
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- открой переводчик
- переводчик
- запусти переводчик

View file

@ -0,0 +1,33 @@
list:
- command:
action: cli
cli_cmd: calc
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- включи калькулятор
- открой калькулятор
- покажи калькулятор
- запусти калькулятор
- калькулятор
- command:
action: cli
cli_cmd: taskkill
cli_args:
- /f
- /im
- CalculatorApp.exe
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- закрой калькулятор
- отключи калькулятор
- выключи калькулятор
- убери калькулятор

View file

@ -0,0 +1,7 @@
WinKill, AHK_exe jarvis-app.exe
Process, Close, jarvis-app.exe
sleep 3000
Run shell:AppsFolder\com.priler.jarvis
sleep 2000
WinMinimize jarvis-app
WinMinimize Jarvis Voice Assistant

Binary file not shown.

View file

@ -0,0 +1,89 @@
list:
- command:
action: ahk
exe_path: ahk/reboot.exe
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- перезагрузись
- перезагрузи себя
- выполни перезагрузку
- command:
action: voice
voice:
sounds:
- stupid
phrases:
- ты дурак
- ты дебил
- ты глупый
- ты тупой
- command:
action: voice
voice:
sounds:
- thanks
phrases:
- спасибо
- молодец
- респект
- ты супер
- отличная работа
- ты крут
- ты большой молодец
- ты реально крут
- ты афигенный
- command:
action: voice
voice:
sounds:
- joke1
- joke2
- joke3
- joke4
- joke5
phrases:
- расскажи анекдот
- рассмеши
- пошути
- шутка
- расскажи шутку
- развесели меня
- что нибудь смешное
- подними мне настроение
- мне скучно
- хочу шутку
- хочу анекдот
- пошути
- расскажи что нибудь смешное
- расскажи смешное что нибудь
- хочу посмеяться
- command:
action: voice
voice:
sounds:
- thanks
phrases:
- спасибо
- молодец
- респект
- ты супер
- отличная работа
- ты крут
- ты большой молодец
- ты реально крут
- ты афигенный
- классная шутка
- очень смешно
- ты меня рассмешил
- веселая шутка
- смешной анекдот
- это было весело
- интересная шутка

View file

@ -0,0 +1,2 @@
WinKill, AHK_exe Steam.exe
Process, Close, Steam.exe

Binary file not shown.

View file

@ -0,0 +1,4 @@
WinKill, AHK_exe Steam.exe
Process, Close, Steam.exe
Run, steam://open/bigpicture

Binary file not shown.

View file

@ -0,0 +1,36 @@
list:
- command:
action: ahk
exe_path: ahk/Open steam.exe
voice:
sounds:
- game_mode
phrases:
- включи игровой режим
- перейди в игровой режим
- я хочу поиграть
- включи стим
- запусти стим
- открой стим
- command:
action: ahk
exe_path: ahk/Close steam.exe
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- рабочий режим
- вернись в рабочий режим
- отключи игровой режим
- выйди из игрового режима
- выход с игрового режима
- рабочее пространство
- выключи игровой режим
- выключи стим
- отключи стим
- выйди из стима
- закрой стим

View file

@ -0,0 +1,17 @@
list:
- command:
action: stop_chaining
voice:
sounds:
- thanks
- ok1
phrases:
- всё
- хватит
- отмена
- не слушай
- перестань слушать
- отдыхай
- на этом всё
- хватит слушать
- на этом всё

View file

@ -0,0 +1,16 @@
list:
- command:
action: terminate
voice:
sounds:
- off
phrases:
- выключись
- вырубись
- закройся
- отключись
- заверши свою работу
- на сегодня хватит
- выгрузи себя из памяти
- ты мне надоел
- пора спать

View file

@ -0,0 +1,6 @@
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Send {Volume_Mute} ; Mute/unmute the master volume.

Binary file not shown.

View file

@ -0,0 +1 @@
SoundSet, %1%

Binary file not shown.

View file

@ -0,0 +1,100 @@
list:
- command:
action: ahk
exe_path: ahk/Mute volume.exe
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- выключи звук
- беззвучный режим
- режим без звука
- отключи звук
- command:
action: ahk
exe_path: ahk/Mute volume.exe
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- включи звук
- режим со звуком
- верни звук
- command:
action: ahk
exe_path: ahk/Set sound.exe
exe_args:
- 25
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- звук на минимум
- громкость на минимум
- убавь звук
- сделай потише
- убавь громоксть
- поставь звук на минимум
- поставь громкость на минимум
- установи звук на минимум
- установи громкость на минимум
- минимальный уровень громкости
- command:
action: ahk
exe_path: ahk/Set sound.exe
exe_args:
- 50
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- звук пятьдесят
- громкость пятьдесят
- поставь звук на пятьдесят
- поставь громкость на пятьдесят
- установи звук на пятьдесят
- установи громкость на пятьдесят
- громкость на середину
- средний уровень громкости
- поставь звук на середину
- установи громкость на середину
- средний уровень громкости
- command:
action: ahk
exe_path: ahk/Set sound.exe
exe_args:
- 100
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- звук сто
- громкость сто
- поставь звук на сто
- поставь громкость на сто
- установи звук на сто
- установи громкость на сто
- громкость на максимум
- установи громкость на максимум
- звук на максимум
- полная громкость
- полный уровень громкости

View file

@ -0,0 +1 @@
FileRecycleEmpty,

Binary file not shown.

View file

@ -0,0 +1 @@
WinMinimizeAll

Binary file not shown.

View file

@ -0,0 +1 @@
Send, {Shift down}{Alt}{Shift up}

Binary file not shown.

View file

@ -0,0 +1 @@
Run taskmgr.exe

Binary file not shown.

View file

@ -0,0 +1 @@
DllCall("LockWorkStation")

Binary file not shown.

View file

@ -0,0 +1 @@
Send #v

Binary file not shown.

View file

@ -0,0 +1,3 @@
Send {PrintScreen down} ; Press down the PrintScreen key.
Sleep 500 ; Keep it down
Send {Up PrintScreen} ; Release the PrintScreen key.

Binary file not shown.

View file

@ -0,0 +1 @@
DllCall("PowrProf\SetSuspendState", "int", 1, "int", 1, "int", 1)

Binary file not shown.

View file

@ -0,0 +1,124 @@
list:
- command:
action: ahk
exe_path: ahk/Roll up windows.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- сверни все окна
- сверни окна
- command:
action: ahk
exe_path: ahk/Empty trash.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- очисти корзину
- почисти корзину
- очистка корзины
- command:
action: ahk
exe_path: ahk/Task manager open.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- запусти диспетчер задач
- открой диспетчер задач
- диспетчер задач
- command:
action: ahk
exe_path: ahk/screenshot.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- сделай скриншот
- сделай снимок экрана
- сними экран
- command:
action: ahk
exe_path: ahk/blocking.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- заблокируй компьютер
- заблокируй комп
- command:
action: ahk
exe_path: ahk/sleep.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
- ok4
phrases:
- спящий режим
- ждущий режим
- иди поспи
- command:
action: ahk
exe_path: ahk/clipboard.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- открой буфер обмена
- покажи буфер обмена
- запусти буфер обмена
- буфер обмена
- command:
action: ahk
exe_path: ahk/Set language.exe
exe_args:
voice:
sounds:
- ok1
- ok2
- ok3
phrases:
- смени раскладку
- поменяй раскладку
- смени язык
- поменяй язык
- переключи на русский
- переключи на английский
- смени раскладку на русскую
- поменяй раскладку на русскую
- поменяй раскладку на английскую
- смени раскладку на английскую
- смени язык на русский
- поменяй язык на русский
- смени язык на английский
- поменяй язык на английский

BIN
app/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
app/icons/128x128@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
app/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
app/icons/StoreLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
app/icons/icon.icns Normal file

Binary file not shown.

BIN
app/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
app/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
app/libgcc_s_seh-1.dll Normal file

Binary file not shown.

BIN
app/libstdc++-6.dll Normal file

Binary file not shown.

BIN
app/libvosk.dll Normal file

Binary file not shown.

BIN
app/libvosk.lib Normal file

Binary file not shown.

BIN
app/libwinpthread-1.dll Normal file

Binary file not shown.

63
app/post_build.py Normal file
View file

@ -0,0 +1,63 @@
# Simple python script used to
# copy some libraries to the "target" directory
# after Rust build
# Note that Rust build should be run via "cargo make <cmd>" command
# in order to automate all the compile process
import os
from pathlib import Path
import shutil
# some config vars
SOURCE = (
"commands/",
"vosk/",
"lib/",
"keywords/",
"libgcc_s_seh-1.dll",
"libstdc++-6.dll",
"libvosk.dll",
"libvosk.lib",
"libwinpthread-1.dll"
)
TARGET_DIRS = (
"target/debug",
"target/release"
)
ABS_PATH = os.getcwd() + "/"
for tdir in TARGET_DIRS:
tdir = ABS_PATH + tdir
if not Path(tdir).is_dir():
print("Skipping target, not a directory: ", tdir)
continue
# copy lib files
for src in SOURCE:
if os.path.isdir(ABS_PATH + src):
# copy the whole directory
full_target_dir_path = os.path.join(tdir, src)
if os.path.isdir(full_target_dir_path):
print("[-] Directory already exists, skipping: ", src)
else:
shutil.copytree(ABS_PATH + src, os.path.join(tdir, src))
print("[+] Directory copied: ", src)
elif os.path.isfile(ABS_PATH + src):
# copy file
full_target_file_path = os.path.join(tdir, src)
if os.path.isfile(full_target_file_path):
print("[-] File already exists, skipping: ", src)
else:
shutil.copy(ABS_PATH + src, tdir)
print("[+] File copied: ", src)
else:
print("[?] Unknown entity to copy: ", src)
print("Post compile build done.")

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.

BIN
app/sound/jarvis-og/off.wav Normal file

Binary file not shown.

BIN
app/sound/jarvis-og/ok1.wav Normal file

Binary file not shown.

BIN
app/sound/jarvis-og/ok2.wav Normal file

Binary file not shown.

BIN
app/sound/jarvis-og/ok3.wav Normal file

Binary file not shown.

BIN
app/sound/jarvis-og/ok4.wav Normal file

Binary file not shown.

BIN
app/sound/jarvis-og/run.wav Normal file

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.

Some files were not shown because too many files have changed in this diff Show more