Skip to content

Android: continuous listening stops after silence timeout auto-restart workaround + beep fix for Android 15 #661

@surajpatil05

Description

@surajpatil05

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions