Finished speech daemon

fetchIP
E. Almqvist 4 years ago
parent eaa72ef06b
commit 2cdef57b4f
  1. 4
      hue_cmd.py
  2. 4
      modules/hue/config.py
  3. 4
      modules/hue/hue_controller.py
  4. 6
      modules/hue/hue_remote.py
  5. 17
      speech_daemon.py

@ -4,9 +4,9 @@ from modules.hue.hue_controller import controller
from modules.hue.hue_remote import parseCommandline from modules.hue.hue_remote import parseCommandline
def init(): def init():
hue.controller.init() # very important to initialize the controller controller.init() # very important to initialize the controller
parseCommandline() parseCommandline()
hue.controller.end() # also to end it controller.end() # also to end it
if __name__ == "__main__": if __name__ == "__main__":
init() init()

@ -1,6 +1,4 @@
# Speech CMD settings
prefix = "computer"
# Hue Remote Settings # Hue Remote Settings
class hue_config:
address = "192.168.0.3" address = "192.168.0.3"
username = "E0ru0AeVFKEH1E30X40JAJfovg4Uu1aTkdrKQ2Oi" username = "E0ru0AeVFKEH1E30X40JAJfovg4Uu1aTkdrKQ2Oi"

@ -5,7 +5,7 @@ import time
from .lib.func import * # useful functions from .lib.func import * # useful functions
#import .config as config # Configuration for the controller (/config.py <- change this file) from .config import * # Configuration for the controller (/config.py <- change this file)
from .presets import * # presets for the lights from .presets import * # presets for the lights
LIGHTS = {} # dictionary of all the lights LIGHTS = {} # dictionary of all the lights
@ -13,7 +13,7 @@ LIGHTS = {} # dictionary of all the lights
loop = asyncio.get_event_loop() # ASync loop loop = asyncio.get_event_loop() # ASync loop
def genUrl(params: str): def genUrl(params: str):
return "http://" + config.address + "/api/" + config.username + params return "http://" + hue_config.address + "/api/" + hue_config.username + params
class APIrequest: class APIrequest:
# Get Req # Get Req

@ -31,8 +31,7 @@ boolConvert = {
# this is the most spaghetti-ish code I have ever written but it works # this is the most spaghetti-ish code I have ever written but it works
def parseCommand( cmd:list, pos:int, i=-1, displayHelp=True ): def parseCommand( cmd:list, pos:int, index=-1, displayHelp=True ):
index = int(i)
try: try:
if( cmd[pos] == "on" or cmd[pos] == "off" ): if( cmd[pos] == "on" or cmd[pos] == "off" ):
if( index == -1 ): if( index == -1 ):
@ -94,6 +93,7 @@ def parseCommandline( cmd=sys.argv, needHelp=True ):
parseCommand( cmd, 3, cmd[2], displayHelp=needHelp ) parseCommand( cmd, 3, cmd[2], displayHelp=needHelp )
elif( cmd[1] == "lights" ): elif( cmd[1] == "lights" ):
print("gothere1")
parseCommand( cmd, 2, displayHelp=needHelp ) parseCommand( cmd, 2, displayHelp=needHelp )
else: elif( needHelp ):
help() help()

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from modules.hue.hue_remote import parseCommandline from modules.hue.hue_remote import parseCommandline
from modules.hue.hue_controller import controller
from modules.speech.speech import voiceInput from modules.speech.speech import voiceInput
prefixes = ["computer", "computers"] prefixes = ["computer", "computers"]
@ -13,14 +14,16 @@ class speech_daemon(object):
self.voiceInpObj.setMuted(False) self.voiceInpObj.setMuted(False)
def start(self): def start(self):
return self.voiceInpObj.start() controller.init()
if __name__ == "__main__": for inp in self.voiceInpObj.start():
daemon = speech_daemon()
cmdBuf = None
for inp in daemon.start():
cmdBuf = inp.lower().split(" ") cmdBuf = inp.lower().split(" ")
if( cmdBuf[0] in prefixes ): if( cmdBuf[0] in prefixes ):
print("CMD:", cmdBuf) print("CMD:", cmdBuf)
parseCommandline( cmdBuf[1:], False ) parseCommandline( cmdBuf, False )
controller.end()
if __name__ == "__main__":
daemon = speech_daemon()
daemon.start()

Loading…
Cancel
Save