Pages

Wednesday, 28 September 2016

How to add speech recognize into ionic app

Hello friends here i am once again with intresting topic. Speech rocognize using ionic framework.

Follow the below steps.

1. create new project ionic project

    ionic start speechRecognize blank

2. go to project directory

    cd speechRecognize

3. add android platform

    ionic platform add android

4. after adding platform then add below plugin

    ionic plugin add https://github.com/poiuytrez/SpeechRecognizer

5. open your index.html and copy below line

<button ng-click="speechRecognize();">Click to recognize</button>

6. open app.js and copy the below lines under controller

  $scope.speechRecognize = function()
 {
      var maxMatches = 5;
      var promptString = "Speak now"; // optional
      var language = "en-US";                     // optional
      window.plugins.speechrecognizer.startRecognize(function(result)
    {
          alert(result);
     }, function(errorMessage){
          console.log("Error message: " + errorMessage);
      }, maxMatches, promptString, language);
  }

7. build and run the app

    ionic run android


Njoy and till then keep asking..

No comments:

Post a Comment