Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speech recognition using ionic framework

I am looking for a way to do speech recognition using ionic framework . I want to run an app in both ios and android device. Currently i am providing a web view in both ios and android and have a common code base . I want to include speech recognition feature to it and fetch the output of speech .

like image 724
saurabh jain Avatar asked Dec 03 '14 07:12

saurabh jain


2 Answers

It looks like you have at least a couple options if you search around for "cordova speech recognition" on Google and if you look at the plugin repo at Apache's Cordova site.

Here's two quick ones I found.

  • https://github.com/macdonst/SpeechRecognitionPlugin (Android & iPhone)
  • https://github.com/floatinghotpot/cordova-plugin-iflyspeech (Android & iPhone)

The key here is that Ionic Framework is built on Cordova, so really you want a Cordova plugin for speech recognition.

like image 183
jpoveda Avatar answered Nov 09 '22 19:11

jpoveda


I was stuck at the same point. Then I found a url where I got a solution. As per as url they followed a cordova plugin. So you need to follow these steps:

1 - add Cordova plugin

cordova plugin add https://github.com/macdonst/SpeechRecognitionPlugin

2 - add TTS plugin

cordova plugin add cordova-plugin-tts

3 - implementation of plugin code

app.controller('AppCtrl', function($scope) {
  $scope.data = {
    speechText: ''
  };
  $scope.recognizedText = '';

  $scope.speakText = function() {
    window.TTS.speak({
           text: $scope.data.speechText,
           locale: 'en-GB',
           rate: 0.7
       }, function () {
           // Do Something after success
       }, function (reason) {
           // Handle the error case
        alert(reason+"");
       });
  };

  $scope.record = function() {
    var recognition = new SpeechRecognition();
    recognition.onresult = function(event) {
        if (event.results.length > 0) {
            $scope.recognizedText = event.results[0][0].transcript;
            $scope.$apply()
        }
    };
    recognition.start();
  };
});

Enjoy your code time:)

like image 32
John smith Avatar answered Nov 09 '22 19:11

John smith