Speech Recognition Plugin Not Working In Cordova 6
I am using Visual studio tools for Apache Cordova to develop Android app. I started new project and added speech recognition plugin using GIT url. https://github.com/macdonst/Speec
Solution 1:
Was stuck with the same issue for a longtime. Finally able to crack it. The trick was to add the cordova media plugin.
The working code is as follows:
index.html
<!DOCTYPE html><html><head><metaname="format-detection"content="telephone=no"><metaname="msapplication-tap-highlight"content="no"><metaname="viewport"content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"><linktype="text/css"href="css/index.css"><title>Speech Recognition</title></head><body><br><br><br><br><br><br><br><br><form>
Click to speak <inputtype="button"value="speak"name="Download"id="speak" /><br><inputtype="text"id="q"name="q"size=60></form><scripttype="text/javascript"src="js/jquery.js"></script><scripttype="text/javascript"src="cordova.js"></script><scripttype="text/javascript"src="js/app.js"></script></body></html>
app.js
$(document).ready(function() {
document.addEventListener("deviceready", onDeviceReady, false);
});
var recognition;
functiononDeviceReady() {
$('#speak').click( function() {
recognition = newSpeechRecognition();
recognition.onresult = function(event) {
if (event.results.length > 0) {
console.log(event.results[0][0].transcript);
q.value = event.results[0][0].transcript;
}
};
recognition.start();
});
}
Post a Comment for "Speech Recognition Plugin Not Working In Cordova 6"