Commit 2313ce68 authored by nextime's avatar nextime

Add force action to speech commands

parent 43d8a02d
ALTER TABLE `speech_actions` ADD `ikap_force_act` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `ikap_arg`, ADD INDEX (`ikap_force_act`) ;
...@@ -1860,7 +1860,7 @@ class domotikaService(service.Service): ...@@ -1860,7 +1860,7 @@ class domotikaService(service.Service):
return 'NOACT' return 'NOACT'
def manageSpeechActions(self, results, speechres={"action":False}): def manageSpeechActions(self, results, speechres={"action":False}):
if len(results) > 0 and speechres["action"]: if len(results) > 0:
for res in results: for res in results:
log.info("SPEECH ACTION ID: "+str(res.id)+" NAME: "+str(res.speechaction_name)) log.info("SPEECH ACTION ID: "+str(res.id)+" NAME: "+str(res.speechaction_name))
if genutils.isTrue(res.active): if genutils.isTrue(res.active):
...@@ -1881,7 +1881,9 @@ class domotikaService(service.Service): ...@@ -1881,7 +1881,9 @@ class domotikaService(service.Service):
continue continue
res.lastrun=time.time() res.lastrun=time.time()
res.save() res.save()
if genutils.isTrue(res.ikapacket): if res.ikap_force_action > 0:
speechres["action"] = res.force_action
if genutils.isTrue(res.ikapacket) and speechres["action"]:
# XXX Manca gestione local only e ipdest! # XXX Manca gestione local only e ipdest!
# XXX Gestire gli arg! (e lo use arg! per il received) # XXX Gestire gli arg! (e lo use arg! per il received)
self.sendCommand(res.ikap_dst, act=int(speechres["action"]), ctx=res.ikap_ctx, msgtype=res.ikap_msgtype, self.sendCommand(res.ikap_dst, act=int(speechres["action"]), ctx=res.ikap_ctx, msgtype=res.ikap_msgtype,
...@@ -2190,7 +2192,7 @@ class domotikaService(service.Service): ...@@ -2190,7 +2192,7 @@ class domotikaService(service.Service):
def voiceRecognized(self, txt, confidence=0.0, lang="it", voicesrc='VoIP'): def voiceRecognized(self, txt, confidence=0.0, lang="it", voicesrc='VoIP'):
log.debug("voiceRecognized: ["+txt+"] confidence: "+str(confidence)+" lang: "+lang+" src: "+voicesrc) log.info("voiceRecognized: ["+txt+"] confidence: "+str(confidence)+" lang: "+lang+" src: "+voicesrc)
def speechactres(res, v): def speechactres(res, v):
if len(res)>0: if len(res)>0:
...@@ -2200,7 +2202,9 @@ class domotikaService(service.Service): ...@@ -2200,7 +2202,9 @@ class domotikaService(service.Service):
else: else:
useoutput=genutils.isTrue(self.config.get('voiceui', 'useoutput')) useoutput=genutils.isTrue(self.config.get('voiceui', 'useoutput'))
if useoutput: if useoutput:
log.info("Speech using output")
return ('OUTPUT', False) return ('OUTPUT', False)
log.info("Speech output disabled")
return ('NOACT',False) return ('NOACT',False)
def actionres(ares, vres): def actionres(ares, vres):
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
from dmlib import constants as c from dmlib import constants as c
IT_REMOVE=[ IT_REMOVE=[
"il","la","per","favore","mi","le","tiri","del","della","dell","dei","di","delle","degli","d","de" "il","la","per","favore","mi","le","tiri","del","della","dell","dei","di","delle","degli","d","de","i","lo"
] ]
IT_ACTIONS={ IT_ACTIONS={
...@@ -34,10 +34,14 @@ IT_ACTIONS={ ...@@ -34,10 +34,14 @@ IT_ACTIONS={
"aprire":c.IKAP_ACT_OPEN, "aprire":c.IKAP_ACT_OPEN,
"apre":c.IKAP_ACT_OPEN, "apre":c.IKAP_ACT_OPEN,
"aprimi":c.IKAP_ACT_OPEN, "aprimi":c.IKAP_ACT_OPEN,
"aprimi":c.IKAP_ACT_OPEN,
"chiudi":c.IKAP_ACT_CLOSE, "chiudi":c.IKAP_ACT_CLOSE,
"chiudere":c.IKAP_ACT_CLOSE, "chiudere":c.IKAP_ACT_CLOSE,
"chiude":c.IKAP_ACT_CLOSE, "chiude":c.IKAP_ACT_CLOSE,
"chiudimi":c.IKAP_ACT_CLOSE, "chiudimi":c.IKAP_ACT_CLOSE,
"cambia": c.IKAP_ACT_CHANGE,
"inverti": c.IKAP_ACT_CHANGE,
"muovi": c.IKAP_ACT_CHANGE,
"alza":c.IKAP_ACT_UP, "alza":c.IKAP_ACT_UP,
"alzare":c.IKAP_ACT_UP, "alzare":c.IKAP_ACT_UP,
"alzami":c.IKAP_ACT_UP, "alzami":c.IKAP_ACT_UP,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment