Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startSpeech(){
- try{
- window.plugins.speechRecognition.isRecognitionAvailable(function(available){
- if(!available){
- console.log("Not available!!!");
- }
- // Check if has permission to use the microphone
- window.plugins.speechRecognition.hasPermission(function (isGranted){
- if(isGranted){
- startRecognition();
- }else{
- // Request the permission
- window.plugins.speechRecognition.requestPermission(function (){
- // Request accepted, start recognition
- startRecognition();
- }, function (err){
- console.log(err.message);
- });
- }
- }, function(err){
- console.log(err.message);
- });
- }, function(err){
- console.log(err.message);
- });
- }catch (err) {
- console.log(err.message);
- }
- }
- function startRecognition(){
- window.plugins.speechRecognition.startListening(function(result){
- // Show results in the console
- Log.d("Search", result);
- }, function(err){
- alert(err);
- }, {
- language: "en-US",
- showPopup: true
- });
- }
Add Comment
Please, Sign In to add comment