Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

AccessibilityService + TTS/STT: How to keep YouTube playing, silence STT beeps, and make TTS↔STT handoff feel natural?

未关闭
#116 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
kotlin

调研方向

首先使用 AccessibilityService、TextToSpeech、SpeechRecognizer 和媒体播放,在 Android 14/15(包括 Samsung 和 Pixel 设备)上复现该交互。通过 startListening 跟踪 UtteranceProgressListener.onDone,并在 YouTube 播放期间比较音频焦点、AudioAttributes、提示音行为和 ERROR_NO_MATCH。完成的标准是记录或演示一种跨设备交接:保持媒体播放、抑制提示音或安全地处理提示音,并可靠地打开监听窗口。

由索引模型根据 Issue 内容生成。

描述

Environment

Android 14/15 (including Samsung devices)
An AccessibilityService detects order popups from a dispatch app overlay
Order details are spoken with TextToSpeech, and SpeechRecognizer listens for voice commands such as “confirm” / “cancel”
Drivers often keep YouTube playing while using the app

Goals (all three at once)

Do not interrupt YouTube (or other media) — no pause / stop, and avoid 1-second ducking loops
No STT start/stop/error beeps (the system “ding / ting” sound)
TTS and STT should work smoothly together — STT should become ready right after (or overlapping with) TTS so voice confirm feels natural

What we’ve tried / side effects

Audio focus

TTS with AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK → YouTube sometimes ducks or pauses
Requesting audio focus before/during STT → LOSS_TRANSIENT kills STT, or YouTube pauses
Requesting no focus keeps YouTube alive, but during media playback STT onReady is often late and ERROR_NO_MATCH (7) becomes common

Beep suppression

RecognizerIntent extras such as android.speech.extra.BEEP_SOUND=false, sound_start_beep=0 → ignored on some devices/engines
Temporarily muting only STREAM_NOTIFICATION / STREAM_SYSTEM → reduces beeps, but mute/restore ping-pong can still affect YouTube or system volume
Muting STREAM_MUSIC is unacceptable because it kills YouTube

TTS ↔ STT timing

Blocking startListening during TTS → STT resume after TTS is often delayed (seconds to tens of seconds)
Opening TTS and STT at the same time → mic contention with Google STT/SODA: TTS delay, or “ghost listen” (isListening=true but no onReady / no RMS)
Lost or delayed TTS onDone can leave the STT window never opened

Media + NO_MATCH

Immediately calling startListening again on every ERROR_NO_MATCH while YouTube plays causes ~1s pause/duck ping-pong
Backing off too much (e.g. 4–8s) makes users miss the confirm window

Questions
For an Accessibility-based field voice UI, is there a recommended pattern that satisfies all of the following?

STT that coexists with YouTube / isMusicActive media (do not disable STT just because a media app is in the foreground)
Fully suppress SpeechRecognizer/system beeps without volume hacks — or with the safest minimal hack
Start STT listening within ~1 second after TTS speak, ideally with an overlapping handoff that doesn’t fight for the mic/focus

In particular:

Which AudioAttributes / usage / contentType should TTS and STT each use?
Should we request audio focus at all — and if so, when and which type (MAY_DUCK vs none vs a short STT-only request)?
Is there an official or semi-official API to disable SpeechRecognizer beeps across OEMs / Google engine?
For accessibility voice commands, is on-device speech recognition / AudioRecord + custom VAD a better fit than SpeechRecognizer?
What is the recommended handoff from TTS UtteranceProgressListener.onDone to STT startListening (delay, audio session, mic release)?

Constraints

Accessibility is used only for core functionality (Play policy)
We can’t ask users to “turn off YouTube” or “accept beeps”
Needs to work across Samsung, Pixel, and similar devices

I can share repro logs or a minimal sample project. Looking for real-world patterns from anyone who has shipped something similar.

主要语言
Kotlin
星标
1.4k
派生
782
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

android/media-samples 的其他 Issue

查看 android/media-samples 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。