fix(weixin): add prefer_platform_transcription config option - #81735
Open
answerallen wants to merge 1 commit into
Open
fix(weixin): add prefer_platform_transcription config option#81735answerallen wants to merge 1 commit into
answerallen wants to merge 1 commit into
Conversation
When WeChat (Weixin) delivers a voice message, Tencent Cloud provides voice_item.text as its own STT output. After NousResearch#27300, Hermes always ignores this text and downloads the raw audio for local STT re-transcription. This is correct for non-Chinese users (Tencent's STT garbles Russian, Arabic, etc.) but breaks Chinese-heavy users who: - Have stt.enabled=false (no local STT configured) - Were previously relying on Tencent's high-quality Chinese transcription - After upgrading, voice messages became unusable (placeholder with no transcript) This PR adds prefer_platform_transcription (default: false) to gateway.platforms.weixin.extra. When enabled: - _extract_text() returns Tencent's voice_item.text as the message body - _download_voice() skips downloading the .silk audio file When disabled (default), behaviour is unchanged from NousResearch#27300. Related: NousResearch#27300, NousResearch#65022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Adds a
prefer_platform_transcriptionconfig option to the WeChat (Weixin) adapter that lets users choose between Tencent Cloud's STT and Hermes' own local STT pipeline for voice messages.When
true: trust Tencent'svoice_item.textas the message body, skip downloading raw audio.When
false(default): always download raw audio and route through Hermes' local STT pipeline (unchanged from #27300).Problem
After #27300 was merged (PR #73515), Hermes always ignores Tencent Cloud's
voice_item.textand downloads raw.silkaudio for local STT re-transcription. This fixed garbled transcriptions for non-Chinese users but broke Chinese-heavy users who:stt.enabled: false(no local STT provider configured — nofaster-whisper, noGROQ_API_KEY, etc.)[The user sent a voice message: ...]) with no transcript at allThis is a common setup for Chinese users on low-resource servers where installing
faster-whisperis impractical (300MB+ model, OOM risks on ≤2GB RAM).Solution
Add
prefer_platform_transcriptiontogateway.platforms.weixin.extra:Changes
gateway/platforms/weixin.py:_extract_text(): newprefer_platform_transcriptionkeyword arg. Whentrue, returns Tencent'svoice_item.textas the message body (with[Voice transcription provided by Weixin]prefix from fix(weixin): preserve voice transcript origin #65022)._download_voice(): whenprefer_platform_transcriptionistrueand Tencent text is available, returnsNone(skip audio download).WeixinAdapter.__init__(): readsextra.prefer_platform_transcription(default:false).tests/gateway/test_weixin.py:TestWeixinPreferPlatformTranscriptionclass with 8 tests covering:Behavior matrix
prefer_platform_transcriptionfalse(default)false(default)false(default)truetruetrueRelated Issue
Related to #27300, #65022. Does not revert #27300 — adds an opt-in escape hatch for users who want platform-side transcription.
Type of Change
How to Test
gateway.platforms.weixin.extra.prefer_platform_transcription: true[Voice transcription provided by Weixin]\n<transcript>false(or remove), send the same voice messageAutomated:
Checklist