feat(weixin): add native voice bubble support with OGG→SILK transcoding - #1
Open
ryan-flow wants to merge 1 commit into
Open
feat(weixin): add native voice bubble support with OGG→SILK transcoding#1ryan-flow wants to merge 1 commit into
ryan-flow wants to merge 1 commit into
Conversation
Add outbound voice bubble delivery for WeChat. When TTS generates OGG/Opus
audio, the adapter now converts it to SILK format via pilk + ffmpeg and
sends it as a native WeChat voice bubble (the green audio bar), instead of
a file attachment.
Changes:
- New module `gateway/platforms/voice_utils.py`:
- `ogg_to_silk()`: OGG→PCM→SILK conversion pipeline
- `get_audio_duration_s()`: duration detection (SILK via pilk, others via ffprobe)
- `cleanup_silk_dir()`: temp file cleanup
- Modified `gateway/platforms/weixin.py`:
- `send_voice()`: convert OGG/Opus to SILK before sending; native voice
bubble for SILK files; fallback to file attachment on failure
- `_AUDIO_EXTS`: added `.ogg` and `.opus` so TTS output routes through send_voice
- `_send_file()`: added playtime field for SILK voice items
- New tests: `tests/gateway/test_voice_utils.py`, `tests/gateway/test_weixin_send_voice.py`
Requires: `pilk` (optional, in `[voice]` extra) + `ffmpeg` on PATH.
Falls back gracefully to file attachment when pilk/ffmpeg unavailable.
Closes NousResearch#9971
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 native WeChat voice bubble delivery for outbound TTS audio. When TTS generates
.ogg/.opusfiles, the adapter now converts them to SILK format viapilk+ffmpegand sends them as native WeChat voice bubbles (the green audio bar), instead of falling back to a file attachment.This addresses Issue #9971: TTS audio messages are not delivered as voice bubbles — need OGG → SILK transcoding.
How it works
Changes
gateway/platforms/voice_utils.pyogg_to_silk), duration detection (get_audio_duration_s), temp cleanup (cleanup_silk_dir).gateway/platforms/weixin.pysend_voice(): convert OGG/Opus to SILK before sending; native voice bubble for.silkfiles; fallback to file attachment on failure._AUDIO_EXTS: added.ogg,.opus._send_file(): addedplaytimefor SILK items.tests/gateway/test_voice_utils.pytests/gateway/test_weixin_send_voice.pysend_voice()with SILK, OGG, conversion failure, and cleanup.Fallback behavior
The implementation degrades gracefully at every layer:
pilknot installedffmpegnot on PATH.silkDependencies
pilk>=0.2.4,<1— added topyproject.tomlunder[voice]extra (optional)ffmpeg— system dependency, already widely availableHow to test
pip install hermes-agent[voice]Related
pilk— same library as fix(stt): preprocess .silk voice notes before transcription NousResearch/hermes-agent#11593Checklist