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 .
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.
The key here is that Ionic Framework is built on Cordova, so really you want a Cordova plugin for speech recognition.
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:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With