Finally, he can hack. The trick was to add the media cord plugin .
The working code is as follows:
index.html
<!DOCTYPE html> <html> <head> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <link rel="stylesheet" type="text/css" href="css/index.css"> <title>Speech Recognition</title> </head> <body> <br> <br> <br> <br> <br> <br> <br> <br> <form> Click to speak <input type="button" value="speak" name="Download" id="speak" /> <br> <input type="text" id="q" name="q" size=60> </form> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="js/app.js"></script> </body> </html>
app.js
$(document).ready(function() { document.addEventListener("deviceready", onDeviceReady, false); }); var recognition; function onDeviceReady() { $('#speak').click( function() { recognition = new SpeechRecognition(); 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(); }); }
source share