Merge pull request #7 from E-Almqvist/speechbugfix

Bug fixes to the speech daemon & error/what handling
fetchIP
E. Almqvist 4 years ago committed by GitHub
commit 3162a199c8
  1. 2
      modules/speech/speech.py
  2. 1
      requirements.txt
  3. 19
      speech_daemon.py

@ -9,7 +9,7 @@ class voiceInput(object):
what = "??" what = "??"
error = "ERROR" 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 while( True ): # loop
try: try:
if( not self.muted ): # this thing is not the NSA if( not self.muted ): # this thing is not the NSA

@ -1 +1,2 @@
SpeechRecognition>=3.8.1 SpeechRecognition>=3.8.1
PyAudio>=0.2.11

@ -15,14 +15,12 @@ CONFIG = {}
class speech_daemon(object): class speech_daemon(object):
voiceInpObj = None voiceInpObj = None
deviceIndex = 30 deviceIndex = None
def __init__(self, deviceIndex=30): def __init__(self):
self.voiceInpObj = voiceInput() self.voiceInpObj = voiceInput()
self.voiceInpObj.setMuted(False) self.voiceInpObj.setMuted(False)
self.deviceIndex = deviceIndex
def loadconfig(self): def loadconfig(self):
path = homedir + "/.config/roomcomputer/config.json" path = homedir + "/.config/roomcomputer/config.json"
# if no config path is # if no config path is
@ -36,14 +34,19 @@ class speech_daemon(object):
global CONFIG global CONFIG
CONFIG = cfg CONFIG = cfg
self.deviceIndex = CONFIG["speech"]["device_index"] # Apply the device index
def start(self): def start(self):
controller.init() controller.init()
for inp in self.voiceInpObj.start( self.deviceIndex ): for inp in self.voiceInpObj.start( self.deviceIndex ):
cmdBuf = inp.lower().split(" ") if( inp != self.voiceInpObj.error and inp != self.voiceInpObj.what ):
if( cmdBuf[0] in CONFIG["speech"]["prefixes"] ): cmdBuf = inp.lower().split(" ")
print("CMD:", cmdBuf) if( cmdBuf[0] in CONFIG["speech"]["prefixes"] ):
parseCommandline( cmdBuf, False ) print("CMD:", cmdBuf)
parseCommandline( cmdBuf, False )
else:
print("Error/What: {0}".format(inp))
controller.end() controller.end()

Loading…
Cancel
Save