Skip to content

feat: add Tencent Cloud ASR support (streaming + file recognition) - #110

Open
jiesou wants to merge 8 commits into
BryceWG:mainfrom
jiesou:feat/tencent-asr
Open

feat: add Tencent Cloud ASR support (streaming + file recognition)#110
jiesou wants to merge 8 commits into
BryceWG:mainfrom
jiesou:feat/tencent-asr

Conversation

@jiesou

@jiesou jiesou commented Jul 30, 2026

Copy link
Copy Markdown

概述

新增腾讯云 ASR 完整接入,支持实时/流式和一句话/非流两种识别模式。

  • 因为是纯 API 级接入,不依赖腾讯云 Android SDK,代码量比较大
  • 音频固定 16kHz PCM

因为看到了腾讯云 ASR 每月有 5 小时免费额度,然后效果很不错,于是考虑接入

-6293809092782396303_121

单元测试是不连 api,只是测本地逻辑

连 api 我自己测试是没问题的

-6293809092782396298_119 -6293809092782396362_119

- Implement TencentStreamAsrEngine with WebSocket-based real-time ASR (HMAC-SHA1 auth)
- Implement TencentFileAsrEngine with TC3-HMAC-SHA256 REST API (one-sentence recognition)
- Add Tencent to AsrVendor enum and AsrVendorRegistry with tags (Online, Streaming, NonStreaming, Accurate)
- Expose AppId, SecretId, SecretKey, engine type, streaming toggle, and VAD toggle in Prefs
- Add UI configuration fields: credential inputs, streaming switch, engine type dropdown, VAD switch
- Register engine in all factory tables (direct mic, Push PCM, file recognizer)
- Add engine mode resolver support for streaming/non-streaming selection
- Add Chinese, Arabic, Japanese, Traditional Chinese string resources
- Add comprehensive tests: baseline, factory, resolver, registry, and stream engine unit tests
@jiesou
jiesou force-pushed the feat/tencent-asr branch from e5ba028 to 9ce8641 Compare July 30, 2026 12:05
jiesou added 3 commits July 30, 2026 20:37
…cent engines

- Remove extractJsonStr, extractJsonInt, extractJsonStrRaw functions from
  TencentFileAsrEngine (hand-rolled string parsing, error-prone)
- Replace all calls in TencentStreamAsrEngine with JSONObject.optXxx()
- Update unit tests to use JSONObject directly
- Simplify class-level KDoc to bare doc URL
As the newest provider, Tencent should consistently appear last in
every enum, when-chain, data class, list, and conditional branch.
This avoids scattered insertion points and follows the convention.
- Add feature_tencent_vad_on_desc/off_desc strings in 5 locales
- Wire VAD switch through toRouteState parameter chain
- Add applyTencentVadSwitch handler with feature explainer dialog
@jiesou
jiesou marked this pull request as ready for review July 30, 2026 12:55
@jiesou
jiesou force-pushed the feat/tencent-asr branch from 3a566be to a2be174 Compare July 31, 2026 01:46
jiesou added 4 commits July 31, 2026 09:51
Without this, a CancellationException would be swallowed by the generic
Throwable catch, breaking coroutine cancellation.
Replace string interpolation with JSONObject to avoid injection issues
from special characters in base64 audio. Also rethrow CancellationException
and make buildJsonPayload internal for test access.
- enqueuePcm had a TOCTOU race: wsReady was checked outside the lock
- wssJob was never cancelled in cancelAll()
- clientOwned was dead code after removing dispatcher shutdown
- Add log warning for mismatched sampleRate/channels in appendPcm
@jiesou
jiesou force-pushed the feat/tencent-asr branch from a2be174 to 6f4886f Compare July 31, 2026 01:51
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.

1 participant