mirror of
https://github.com/aidygus/LinVAM.git
synced 2024-11-26 18:48:06 +11:00
create a config folder
This commit is contained in:
parent
edac47b16d
commit
e9c51b373e
15
main.py
15
main.py
@ -9,6 +9,8 @@ from profileexecutor import ProfileExecutor
|
|||||||
import sys
|
import sys
|
||||||
import pickle
|
import pickle
|
||||||
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):
|
||||||
@ -45,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:
|
||||||
@ -60,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 = {
|
||||||
|
@ -3,6 +3,7 @@ from pynput.mouse import Button, Controller
|
|||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import os, pyaudio
|
import os, pyaudio
|
||||||
|
import shutil
|
||||||
from pocketsphinx.pocketsphinx import *
|
from pocketsphinx.pocketsphinx import *
|
||||||
from sphinxbase.sphinxbase import *
|
from sphinxbase.sphinxbase import *
|
||||||
|
|
||||||
@ -28,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:
|
||||||
@ -42,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
|
||||||
|
Loading…
Reference in New Issue
Block a user