Comments (10)
@Danyzzz The speech recognizer doesn't offer such a continuous mode. However i've achieved to make a "continuous mode" in the same way that everybody does (and with acceptable results) with the Speech Recognition API in the browser : once the speech finishes, restart it again.
However i've faced the 2 obvious problems:
- The success callback is executed only once (read how to solve it here).
- As we need to use the same success callback to send results, we need to filter someway with Javascript when the result is sent from Java to Javascript (to know wheter the plugins says that the speech recognition ends or the results were retrieven). We can simply send an object from Java to JS with the structure:
{
"event":"event-name",
// Only for the onResult event
"matches": ["Recognized text","Recognized text","Recognized text"]
}
Then, the RecognitionListener events of the Java code should be modified too as follows (returns the previously mentioned structure):
@Override
public void onEndOfSpeech() {
try {
JSONObject response = new JSONObject();
response.put("event", "speech.onend");
callbackContext.success(response.toString());
} catch (Exception e) {
e.printStackTrace();
callbackContext.error(e.getMessage());
}
}
@Override
public void onResults(Bundle results) {
ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
Log.d(LOG_TAG, "SpeechRecognitionListener results: " + matches);
try {
JSONObject response = new JSONObject();
// Send type of event "on result"
response.put("event", "speech.onresults");
// Send recognized text
response.put("matches", new JSONArray(matches))
callbackContext.success(response.toString());
} catch (Exception e) {
e.printStackTrace();
callbackContext.error(e.getMessage());
}
}
And with Javascript (speechRecognition.js) would be now:
startListening: function (successCallback, errorCallback, options) {
options = options || {};
cordova.exec(function (data) {
var response = JSON.parse(data);
// Note that you need to add some way of conditional to know wheter the continuous mode is used or the simple mode
if (response.event == "speech.onend") {
// Note that you need to wait 500ms, otherwise the error "recognition busy" will be triggered.
setTimeout(function () {
// Restart the recognition with the callbacks
window.plugins.speechRecognition.startListening(successCallback, errorCallback, options);
}, 500);
} else if (response.event == "speech.onresults") {
console.log("Hey something was recognized, check out : ", response.matches);
}
}, errorCallback, 'SpeechRecognition', 'startListening', [options.language, options.matches, options.prompt, options.showPartial, options.showPopup]);
},
However i won't make a pull request because that would modify the entire structure in which the plugins works, i just let the idea here in case that someone really needs to make it work in continuous mode. Note that you need figure out how to set a "continuous option" to know when to start the plugin in continuous mode or normal mode.
from cordova-plugin-speechrecognition.
It is possible on iOS
from cordova-plugin-speechrecognition.
I'm interested on Android... Like a "ok Google"
from cordova-plugin-speechrecognition.
looking at the google docs it looks like they support continuous speech, will this get implemented?
from cordova-plugin-speechrecognition.
@sdkcarlos Thank you very much, I really needed to leave in continuous mode. I need some help to implement. I have modified the code but it is giving the following error:
..\pbakondy\S
peechRecognition.java:279: error: cannot find symbol
JSONObject response = new JSONObject();
^
from cordova-plugin-speechrecognition.
There are news for use continuos mode?
from cordova-plugin-speechrecognition.
also how does it work on iOS?
from cordova-plugin-speechrecognition.
I need to develop an app where speech recognition will be continous in order to detect hotword for both iOS and Android platforms , Does Speech Recognition Continuos mode is supported in Ionic v5?
from cordova-plugin-speechrecognition.
@hiteshtare Bro did you get any solution for this bro?
from cordova-plugin-speechrecognition.
I was also looking to continuous speech recognition, unfortunately it's still not supported and consumes a lot of power to restart speech recognition every time (see: https://developer.apple.com/documentation/speech/sfspeechrecognizer with the part on Create a Great User Experience for Speech Recognition).
I will try the wake word service of Porcupine : https://picovoice.ai/docs/porcupine/. The drawback is that it's a paid service if you have more than 3 users that use the service.
from cordova-plugin-speechrecognition.
Related Issues (20)
- Not working on iOS 13.2 HOT 8
- How to voice to text?
- Wondering about the pricing using this plugin on Android? HOT 5
- How can I get the data and send it to the server? HOT 2
- support of speechContext
- Failed iOs
- Speech recognition doesn't work on iOS 13.3 HOT 1
- Pop up disable is not working HOT 1
- completeSilenceLength on Android HOT 2
- plugin does not work with ionic 5
- speech recognition service is not available on system on Android 11 Beta HOT 7
- I cannot use microphone with Airpod Pro on iOS HOT 1
- Invalid provider for the NgModule 'AppModule' - only instances of Provider and Type are allowed HOT 1
- cordova ios recognition not working HOT 1
- recognition not working with android 12 HOT 2
- Disable "beep" sound on start and stop of speech recognition
- requestPermission method is broken in iOS
- Is it free to use (google speech api and ios cloud?)
- Not work for android 13
- Api key required
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-speechrecognition.