From 0b616bb2fc081927ae174583424e9186dc9a3103 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 8 Oct 2020 19:38:14 +0200 Subject: [PATCH 1/3] Removed default voice index value --- modules/speech/speech.py | 2 +- speech_daemon.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/speech/speech.py b/modules/speech/speech.py index 1043fc8..fd67957 100644 --- a/modules/speech/speech.py +++ b/modules/speech/speech.py @@ -9,7 +9,7 @@ class voiceInput(object): what = "??" error = "ERROR" - def start( self, deviceIndex=30 ): # a generator for everything that is said + def start( self, deviceIndex=None ): # a generator for everything that is said while( True ): # loop try: if( not self.muted ): # this thing is not the NSA diff --git a/speech_daemon.py b/speech_daemon.py index 0683395..f5981f9 100755 --- a/speech_daemon.py +++ b/speech_daemon.py @@ -15,14 +15,12 @@ CONFIG = {} class speech_daemon(object): voiceInpObj = None - deviceIndex = 30 + deviceIndex = None - def __init__(self, deviceIndex=30): + def __init__(self): self.voiceInpObj = voiceInput() self.voiceInpObj.setMuted(False) - self.deviceIndex = deviceIndex - def loadconfig(self): path = homedir + "/.config/roomcomputer/config.json" # if no config path is @@ -36,6 +34,8 @@ class speech_daemon(object): global CONFIG CONFIG = cfg + self.deviceIndex = CONFIG["speech"]["device_index"] + def start(self): controller.init() From 4a1087463918a062c167261cbfffb1d35e34699e Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 8 Oct 2020 19:48:27 +0200 Subject: [PATCH 2/3] Added error/what handeling --- speech_daemon.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/speech_daemon.py b/speech_daemon.py index f5981f9..f381b03 100755 --- a/speech_daemon.py +++ b/speech_daemon.py @@ -34,16 +34,19 @@ class speech_daemon(object): global CONFIG CONFIG = cfg - self.deviceIndex = CONFIG["speech"]["device_index"] + self.deviceIndex = CONFIG["speech"]["device_index"] # Apply the device index def start(self): controller.init() for inp in self.voiceInpObj.start( self.deviceIndex ): - cmdBuf = inp.lower().split(" ") - if( cmdBuf[0] in CONFIG["speech"]["prefixes"] ): - print("CMD:", cmdBuf) - parseCommandline( cmdBuf, False ) + if( inp != self.voiceInpObj.error and inp != self.voiceInpObj.what ): + cmdBuf = inp.lower().split(" ") + if( cmdBuf[0] in CONFIG["speech"]["prefixes"] ): + print("CMD:", cmdBuf) + parseCommandline( cmdBuf, False ) + else: + print("Error/What: {0}".format(inp)) controller.end() From 17e7e304a3d6e959c86e186942750db940db4cb1 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 8 Oct 2020 19:50:54 +0200 Subject: [PATCH 3/3] Added PyAudio to requirements --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8d2870c..f9f4715 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -SpeechRecognition>=3.8.1 \ No newline at end of file +SpeechRecognition>=3.8.1 +PyAudio>=0.2.11