Commit 205e858a authored by nextime's avatar nextime

fix chrome voice recognition

parent 91985a0e
...@@ -217,6 +217,16 @@ ...@@ -217,6 +217,16 @@
$.post("/rest/v1.2/actions/speech_text/json", spobj.serialize(), speechResult ); $.post("/rest/v1.2/actions/speech_text/json", spobj.serialize(), speechResult );
} }
function setSpeechText(terms)
{
// XXX Sistema sta cosa!
console.debug("SpeechRecognized: "+terms);
$("#speech [name=text]").val(terms);
$("#speechsm [name=text]").val(terms);
sendSpeech($("#speech"));
}
// Test SpeechAPI // Test SpeechAPI
var speechStartWord='*terms'; var speechStartWord='*terms';
if((speechEnabled=='touch' && document.createElement('input').webkitSpeech==undefined) || speechEnabled=='continuous') if((speechEnabled=='touch' && document.createElement('input').webkitSpeech==undefined) || speechEnabled=='continuous')
...@@ -226,6 +236,7 @@ ...@@ -226,6 +236,7 @@
if(window.annyang) if(window.annyang)
{ {
$("#speechbutton").show(); // it isn't chrome with webkit-speech attribute, but it support WEB Speech API $("#speechbutton").show(); // it isn't chrome with webkit-speech attribute, but it support WEB Speech API
annyang.setCatchAll(setSpeechText);
} }
else else
{ {
...@@ -234,38 +245,33 @@ ...@@ -234,38 +245,33 @@
} }
} else { } else {
$("#speechbutton").hide(); $("#speechbutton").hide();
speechStartWord='ok domotica *terms'; if(window.annyang)
annyang.addCommands({'ok domotica *terms': setSpeechText});
} }
} else { } else {
speechEnabled='touch-chrome'; speechEnabled='touch-chrome';
} }
function setSpeechText(terms)
{
// XXX Sistema sta cosa!
$("#speech [name=text]").val(terms);
$("#speechsm [name=text]").val(terms);
console.debug("SpeechRecognized: "+terms)
sendSpeech($("#speech"));
}
var commands = { var commands = {
speechStartWord: setSpeechText 'hello domotica': function(){console.debug('hello domotika!');}
}; };
if(speechEnabled=='touch' || speechEnabled=='continuous') if(speechEnabled=='touch' || speechEnabled=='continuous')
{ {
try { try {
annyang.init(commands); annyang.addCommands(commands);
} catch(err) { } catch(err) {
annyang=null; annyang=null;
} }
if(annyang) { if(annyang) {
annyang.setLanguage('<?=$_DOMOTIKA['speechlang']?>'); annyang.setLanguage('<?=$_DOMOTIKA['speechlang']?>');
if(speechEnabled=='continuous') if(speechEnabled=='continuous')
annyang.start(); annyang.start({ autoRestart: true });
else if(speechEnabled=='touch') else if(speechEnabled=='touch')
annyang.setContinuous(false); //annyang.setContinuous(false);
$("#speechbutton").click(function() {
annyang.start({ autoRestart: false });
});
} else { } else {
$("#speechbutton").hide(); $("#speechbutton").hide();
speechEnabled='no'; speechEnabled='no';
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -32,9 +32,11 @@ IT_ACTIONS={ ...@@ -32,9 +32,11 @@ IT_ACTIONS={
"giu":c.IKAP_ACT_DOWN, "giu":c.IKAP_ACT_DOWN,
"apri":c.IKAP_ACT_OPEN, "apri":c.IKAP_ACT_OPEN,
"aprire":c.IKAP_ACT_OPEN, "aprire":c.IKAP_ACT_OPEN,
"apre":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,
"chiudimi":c.IKAP_ACT_CLOSE, "chiudimi":c.IKAP_ACT_CLOSE,
"alza":c.IKAP_ACT_UP, "alza":c.IKAP_ACT_UP,
"alzare":c.IKAP_ACT_UP, "alzare":c.IKAP_ACT_UP,
...@@ -43,9 +45,11 @@ IT_ACTIONS={ ...@@ -43,9 +45,11 @@ IT_ACTIONS={
"abbassare":c.IKAP_ACT_DOWN, "abbassare":c.IKAP_ACT_DOWN,
"abbassami":c.IKAP_ACT_DOWN, "abbassami":c.IKAP_ACT_DOWN,
"accendi":c.IKAP_ACT_ON, "accendi":c.IKAP_ACT_ON,
"accende":c.IKAP_ACT_ON,
"accendere":c.IKAP_ACT_ON, "accendere":c.IKAP_ACT_ON,
"spegni":c.IKAP_ACT_OFF, "spegni":c.IKAP_ACT_OFF,
"spegnere":c.IKAP_ACT_OFF, "spegnere":c.IKAP_ACT_OFF,
"spegne":c.IKAP_ACT_OFF,
"accendimi":c.IKAP_ACT_ON, "accendimi":c.IKAP_ACT_ON,
"spegnimi":c.IKAP_ACT_OFF, "spegnimi":c.IKAP_ACT_OFF,
"off":c.IKAP_ACT_OFF, "off":c.IKAP_ACT_OFF,
......
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