Guest User

Untitled

a guest
Oct 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. function startSpeech(){
  2. try{
  3.  
  4. window.plugins.speechRecognition.isRecognitionAvailable(function(available){
  5. if(!available){
  6. console.log("Not available!!!");
  7. }
  8.  
  9. // Check if has permission to use the microphone
  10. window.plugins.speechRecognition.hasPermission(function (isGranted){
  11. if(isGranted){
  12. startRecognition();
  13. }else{
  14. // Request the permission
  15. window.plugins.speechRecognition.requestPermission(function (){
  16. // Request accepted, start recognition
  17. startRecognition();
  18. }, function (err){
  19. console.log(err.message);
  20. });
  21. }
  22. }, function(err){
  23. console.log(err.message);
  24. });
  25. }, function(err){
  26. console.log(err.message);
  27. });
  28. }catch (err) {
  29. console.log(err.message);
  30. }
  31. }
  32.  
  33.  
  34.  
  35. function startRecognition(){
  36. window.plugins.speechRecognition.startListening(function(result){
  37. // Show results in the console
  38. Log.d("Search", result);
  39. }, function(err){
  40. alert(err);
  41. }, {
  42. language: "en-US",
  43. showPopup: true
  44. });
  45. }
Add Comment
Please, Sign In to add comment