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

add allowForSilence during recording #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tobika
Copy link

@tobika tobika commented Jul 5, 2024

Responding to this issue: #102

We don't want the recording to stop immediately after the user stops to talk for a few milliseconds.

Since API 33 we need to use EXTRA_SEGMENTED_SESSION together with EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS to achieve this goal.

https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SEGMENTED_SESSION

Segmented session uses different callbacks on the RecognitionListener:
onSegmentResults which wors a bit like onPartialResults and onEndOfSegmentedSession.

If you want to use allowForSilence in the config you have to listen to this events in order to get the results.

This is a first proposal and I'm still questioning if there's not a simpler interface for the plugin users. Reusing the onPartialResults even though it works a bit different. Collecting all results on the java side and pushing them back in the classic promise resolve of the start function?

I'm not at all a java developer but it works. On the iOS side I haven't tested yet if there is a similar problem.

@maxcodefaster

This comment was marked as abuse.

@tobika
Copy link
Author

tobika commented Jul 29, 2024

I forgot to add that this approach doesn't work with popup: true maybe I should add a check in the plugin that returns an error if this config parameters are not compatible?

@vovanb
Copy link

vovanb commented Aug 4, 2024

@tobika can you share working example with EXTRA_SEGMENTED_SESSION ?

@msty
Copy link

msty commented Nov 17, 2024

On the iOS side I haven't tested yet if there is a similar problem.

I have not observed the same problem on iOS after testing my app on both devices.

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

Successfully merging this pull request may close these issues.

4 participants