Commit 205e858a authored by nextime's avatar nextime

fix chrome voice recognition

parent 91985a0e
......@@ -217,6 +217,16 @@
$.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
var speechStartWord='*terms';
if((speechEnabled=='touch' && document.createElement('input').webkitSpeech==undefined) || speechEnabled=='continuous')
......@@ -226,6 +236,7 @@
if(window.annyang)
{
$("#speechbutton").show(); // it isn't chrome with webkit-speech attribute, but it support WEB Speech API
annyang.setCatchAll(setSpeechText);
}
else
{
......@@ -234,38 +245,33 @@
}
} else {
$("#speechbutton").hide();
speechStartWord='ok domotica *terms';
if(window.annyang)
annyang.addCommands({'ok domotica *terms': setSpeechText});
}
} else {
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 = {
speechStartWord: setSpeechText
'hello domotica': function(){console.debug('hello domotika!');}
};
if(speechEnabled=='touch' || speechEnabled=='continuous')
{
try {
annyang.init(commands);
annyang.addCommands(commands);
} catch(err) {
annyang=null;
}
if(annyang) {
annyang.setLanguage('<?=$_DOMOTIKA['speechlang']?>');
if(speechEnabled=='continuous')
annyang.start();
annyang.start({ autoRestart: true });
else if(speechEnabled=='touch')
annyang.setContinuous(false);
//annyang.setContinuous(false);
$("#speechbutton").click(function() {
annyang.start({ autoRestart: false });
});
} else {
$("#speechbutton").hide();
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={
"giu":c.IKAP_ACT_DOWN,
"apri":c.IKAP_ACT_OPEN,
"aprire":c.IKAP_ACT_OPEN,
"apre":c.IKAP_ACT_OPEN,
"aprimi":c.IKAP_ACT_OPEN,
"chiudi":c.IKAP_ACT_CLOSE,
"chiudere":c.IKAP_ACT_CLOSE,
"chiude":c.IKAP_ACT_CLOSE,
"chiudimi":c.IKAP_ACT_CLOSE,
"alza":c.IKAP_ACT_UP,
"alzare":c.IKAP_ACT_UP,
......@@ -43,9 +45,11 @@ IT_ACTIONS={
"abbassare":c.IKAP_ACT_DOWN,
"abbassami":c.IKAP_ACT_DOWN,
"accendi":c.IKAP_ACT_ON,
"accende":c.IKAP_ACT_ON,
"accendere":c.IKAP_ACT_ON,
"spegni":c.IKAP_ACT_OFF,
"spegnere":c.IKAP_ACT_OFF,
"spegne":c.IKAP_ACT_OFF,
"accendimi":c.IKAP_ACT_ON,
"spegnimi":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