add allowForSilence during recording #104
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 withEXTRA_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 likeonPartialResults
andonEndOfSegmentedSession
.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.