Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onResult returns result only once in iOS #92

Open
Tawsif opened this issue May 23, 2017 · 5 comments
Open

onResult returns result only once in iOS #92

Tawsif opened this issue May 23, 2017 · 5 comments

Comments

@Tawsif
Copy link

Tawsif commented May 23, 2017

Hi,

I have used this plugin in my app, When Speech recognition is started for first time it recognizes the voice. But from second time and so on it returns null or "" in onResult function.

@jcesarmobile
Copy link
Collaborator

In which iOS version are you testing? it uses different engines based on the iOS version and might work in a different way

@Tawsif
Copy link
Author

Tawsif commented May 23, 2017

Hi @jcesarmobile,
I am using it in iOS 9.3.5 where iSpeech recorder pops up. It returns the voice converted text first time, and after that it returns blank values.

@Tawsif
Copy link
Author

Tawsif commented May 31, 2017

any update on this ? Please help

@Youdaman
Copy link

Youdaman commented Jun 2, 2017

I'm having the same issue on an iPhone 4S just upgraded to iOS 9.3.5.

Tested with a couple of different code variations, including the sample code provided in the Readme.

The iSpeech popup works the first time, however on subsquent popups it fails to set the text. The voice detection works (the microphone level animation oscillates when you speak) just the conversion to text doesn't.

Perhaps the sample code needs to be updated with a full demonstration of the various methods/properties/events -- I'm guessing that something needs to clear/reset after a successful conversion in order for another to succeed, i.e. there's something in the plugin looking for an empty/unset value but finds the initial successful data and skips a step for subsequent runs?

@Youdaman
Copy link

Youdaman commented Jun 2, 2017

I've come up with a workaround -- assign a new SpeechRecognition() and set recognition.onresult each time. Not sure whether that will chew up memory but I guess you can set the recognition = null after each successful result so the garbage collector takes care of things?

Anyway here is my working version of the readme example (note I'm not using the device ready event):

<script src="cordova.js"></script>
<script type="text/javascript">
var recognition;
function recognize() {
  recognition = new SpeechRecognition();
  recognition.onresult = function(event) {
    if (event.results.length > 0) {
      q.value = event.results[0][0].transcript;
      recognition = null;
    }
  }
  recognition.start();
}
</script>

<input id="q">
<input type="button" value="Recognize" onclick="recognize()">

Repository owner deleted a comment from smilesecond Dec 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants