Problem
Android's SpeechRecognizer stops automatically after a few seconds of silence there's no official API to keep it alive. On Android 15 (Realme P3, ColorOS), every speech.listen() call also triggers an audible beep via STREAM_SYSTEM, making auto-restart unusable without a fix.
Root Cause
SpeechRecognizer enforces a silence timeout with no opt-out flag
speech.listen() triggers a system beep on Android 15 some OEMs also route it through STREAM_NOTIFICATION and STREAM_RING
- The Google Speech Recognition service entry in the manifest independently triggers audio feedback
Fix
1. Auto-restart loop
Listen for onStatus ('done' / 'notListening') and onError callbacks, then immediately call speech.listen() again, accumulating text across restarts.
2. Audio muting with 300ms delay
Before every speech.listen(), mute STREAM_SYSTEM, STREAM_NOTIFICATION, and STREAM_RING via AudioManager — then wait 300ms before calling speech.listen(). The delay is critical; 100ms is not enough for the audio subsystem to apply the mute before the beep fires.
3. Manifest fix
Remove the Google Speech Recognition service entry via tools:node="remove" in AndroidManifest.xml to stop the beep at its source.
Tested On
- Device: Realme P3 — Android 15 (ColorOS)
- Result: ✅ No beep, seamless continuous listening
References
Proposal
Would love to raise a PR adding a continuousListening: true flag to listen() so this is strictly opt-in. Happy to proceed if the maintainer is open to it.
Problem
Android's
SpeechRecognizerstops automatically after a few seconds of silence there's no official API to keep it alive. On Android 15 (Realme P3, ColorOS), everyspeech.listen()call also triggers an audible beep viaSTREAM_SYSTEM, making auto-restart unusable without a fix.Root Cause
SpeechRecognizerenforces a silence timeout with no opt-out flagspeech.listen()triggers a system beep on Android 15 some OEMs also route it throughSTREAM_NOTIFICATIONandSTREAM_RINGFix
1. Auto-restart loop
Listen for
onStatus('done'/'notListening') andonErrorcallbacks, then immediately callspeech.listen()again, accumulating text across restarts.2. Audio muting with 300ms delay
Before every
speech.listen(), muteSTREAM_SYSTEM,STREAM_NOTIFICATION, andSTREAM_RINGviaAudioManager— then wait 300ms before callingspeech.listen(). The delay is critical; 100ms is not enough for the audio subsystem to apply the mute before the beep fires.3. Manifest fix
Remove the Google Speech Recognition service entry via
tools:node="remove"inAndroidManifest.xmlto stop the beep at its source.Tested On
References
Proposal
Would love to raise a PR adding a
continuousListening: trueflag tolisten()so this is strictly opt-in. Happy to proceed if the maintainer is open to it.