1
0
mirror of https://github.com/aidygus/LinVAM.git synced 2024-11-26 02:28:06 +11:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Aidan Gustard
60b143be88
Merge pull request #2 from Mte90/improvements
Use profile folder for settings
2019-06-01 17:48:17 +01:00
Daniele Scasciafratte
6aa3d4c6a1 remove modules not used 2019-05-05 16:57:13 +02:00
Daniele Scasciafratte
e9c51b373e create a config folder 2019-05-05 16:51:22 +02:00
Daniele Scasciafratte
edac47b16d remove modules not used 2019-05-05 16:47:59 +02:00
Daniele Scasciafratte
fd724b6770 remove modules not used 2019-05-05 16:32:17 +02:00
7 changed files with 26 additions and 16 deletions

View File

@ -6,7 +6,6 @@ from keyactioneditwnd import KeyActionEditWnd
from mouseactioneditwnd import MouseActionEditWnd from mouseactioneditwnd import MouseActionEditWnd
from pauseactioneditwnd import PauseActionEditWnd from pauseactioneditwnd import PauseActionEditWnd
import json import json
import keyboard
class CommandEditWnd(QDialog): class CommandEditWnd(QDialog):
def __init__(self, p_command, p_parent = None): def __init__(self, p_command, p_parent = None):

View File

@ -2,9 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtGui import * from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
from ui_keyactioneditwnd import Ui_KeyActionEditDialog from ui_keyactioneditwnd import Ui_KeyActionEditDialog
import json
import keyboard import keyboard
import time
import threading import threading
class KeyActionEditWnd(QDialog): class KeyActionEditWnd(QDialog):

18
main.py
View File

@ -8,10 +8,9 @@ import json
from profileexecutor import ProfileExecutor from profileexecutor import ProfileExecutor
import sys import sys
import pickle import pickle
import time
import keyboard
import threading
import signal import signal
import os
import shutil
class MainWnd(QWidget): class MainWnd(QWidget):
def __init__(self, p_parent = None): def __init__(self, p_parent = None):
@ -48,12 +47,12 @@ class MainWnd(QWidget):
w_profile = json.loads(w_jsonProfile) w_profile = json.loads(w_jsonProfile)
w_profiles.append(w_profile) w_profiles.append(w_profile)
with open("profiles.dat", "wb") as f: with open(self.getSettingsPath("profiles.dat"), "wb") as f:
pickle.dump(w_profiles, f, pickle.HIGHEST_PROTOCOL) pickle.dump(w_profiles, f, pickle.HIGHEST_PROTOCOL)
def loadFromDatabase(self): def loadFromDatabase(self):
w_profiles = [] w_profiles = []
with open("profiles.dat", "rb") as f: with open(self.getSettingsPath("profiles.dat"), "rb") as f:
w_profiles = pickle.load(f) w_profiles = pickle.load(f)
for w_profile in w_profiles: for w_profile in w_profiles:
@ -63,6 +62,15 @@ class MainWnd(QWidget):
return len(w_profiles) return len(w_profiles)
def getSettingsPath(self, setting):
home = os.path.expanduser("~") + '/.linvam/'
if not os.path.exists(home):
os.mkdir(home)
if not os.path.exists(home + setting):
shutil.copyfile(setting, home + setting)
return home + setting
def loadTestProfiles(self): def loadTestProfiles(self):
w_carProfileDict = { w_carProfileDict = {

View File

@ -2,7 +2,6 @@ from PyQt5.QtCore import *
from PyQt5.QtGui import * from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
from ui_mouseactioneditwnd import Ui_MouseActionEditDialog from ui_mouseactioneditwnd import Ui_MouseActionEditDialog
import json
class MouseActionEditWnd(QDialog): class MouseActionEditWnd(QDialog):

View File

@ -2,7 +2,6 @@ from PyQt5.QtCore import *
from PyQt5.QtGui import * from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
from ui_pauseactioneditwnd import Ui_PauseActionEditDialog from ui_pauseactioneditwnd import Ui_PauseActionEditDialog
import json
class PauseActionEditWnd(QDialog): class PauseActionEditWnd(QDialog):
def __init__(self, p_pauseAction, p_parent = None): def __init__(self, p_pauseAction, p_parent = None):

View File

@ -5,7 +5,6 @@ from ui_profileeditwnd import Ui_ProfileEditDialog
from commandeditwnd import CommandEditWnd from commandeditwnd import CommandEditWnd
import json import json
from profileexecutor import * from profileexecutor import *
import sys
class ProfileEditWnd(QDialog): class ProfileEditWnd(QDialog):
def __init__(self, p_profile, p_parent = None): def __init__(self, p_profile, p_parent = None):

View File

@ -2,9 +2,8 @@ import keyboard
from pynput.mouse import Button, Controller from pynput.mouse import Button, Controller
import time import time
import threading import threading
import copy import os, pyaudio
import json import shutil
import sys, os, pyaudio
from pocketsphinx.pocketsphinx import * from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import * from sphinxbase.sphinxbase import *
@ -30,12 +29,21 @@ class ProfileExecutor(threading.Thread):
# Process audio chunk by chunk. On keyword detected perform action and restart search # Process audio chunk by chunk. On keyword detected perform action and restart search
self.m_decoder = Decoder(self.m_config) self.m_decoder = Decoder(self.m_config)
def getSettingsPath(self, setting):
home = os.path.expanduser("~") + '/.linvam/'
if not os.path.exists(home):
os.mkdir(home)
if not os.path.exists(home + setting):
shutil.copyfile(setting, home + setting)
return home + setting
def setProfile(self, p_profile): def setProfile(self, p_profile):
self.m_profile = p_profile self.m_profile = p_profile
if self.m_profile == None: if self.m_profile == None:
return return
w_commandWordFile = open('command.list', 'w') w_commandWordFile = open(self.getSettingsPath('command.list'), 'w')
w_commands = self.m_profile['commands'] w_commands = self.m_profile['commands']
i = 0 i = 0
for w_command in w_commands: for w_command in w_commands:
@ -44,7 +52,7 @@ class ProfileExecutor(threading.Thread):
w_commandWordFile.write(w_command['name'] + ' /1e-%d/' % w_command['threshold']) w_commandWordFile.write(w_command['name'] + ' /1e-%d/' % w_command['threshold'])
i = i + 1 i = i + 1
w_commandWordFile.close() w_commandWordFile.close()
self.m_config.set_string('-kws', 'command.list') self.m_config.set_string('-kws', self.getSettingsPath('command.list'))
def setEnableListening(self, p_enable): def setEnableListening(self, p_enable):
self.m_listening = p_enable self.m_listening = p_enable