fix(tts): improve Opus encoding quality for Telegram voice messages - #18861
Closed
shellybotmoyer wants to merge 1 commit into
Closed
fix(tts): improve Opus encoding quality for Telegram voice messages#18861shellybotmoyer wants to merge 1 commit into
shellybotmoyer wants to merge 1 commit into
Conversation
Switch from CBR 64k to VBR 48k with -application voip and -compression_level 10 The previous settings (CBR 64k, no voip optimization) produced lower quality Opus audio that failed to trigger Telegram voice bubble rendering consistently. Fixes NousResearch#18818
Contributor
|
Thanks for addressing both Telegram Opus conversion paths. The current-main premise is confirmed: Problems
Suggested changes
Automated hermes-sweeper review. |
teknium1
pushed a commit
that referenced
this pull request
Jul 28, 2026
Salvaged from PR #18861 (@shellybotmoyer). Switch the central Opus transcoders from CBR 64k (-vbr off) to VBR 48k with -application voip and -compression_level 10. The old CBR settings produced lower-quality speech audio and occasionally failed to trigger Telegram's native voice-bubble rendering. Applied to _ffmpeg_transcode_to_opus (the single transcoder behind _convert_to_opus and _repair_ogg_container), the Gemini WAV→OGG path, and the Matrix adapter boundary transcoder added in this branch. Fixes #18818
teknium1
pushed a commit
that referenced
this pull request
Jul 28, 2026
Salvaged from PR #18861 (@shellybotmoyer). Switch the central Opus transcoders from CBR 64k (-vbr off) to VBR 48k with -application voip and -compression_level 10. The old CBR settings produced lower-quality speech audio and occasionally failed to trigger Telegram's native voice-bubble rendering. Applied to _ffmpeg_transcode_to_opus (the single transcoder behind _convert_to_opus and _repair_ogg_container), the Gemini WAV→OGG path, and the Matrix adapter boundary transcoder added in this branch. Fixes #18818
Contributor
|
Merged into main via consolidated salvage PR #73508 (merge Your contribution is credited to you in git history. Thank you! Closing this PR as merged-via-salvage. |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
Salvaged from PR NousResearch#18861 (@shellybotmoyer). Switch the central Opus transcoders from CBR 64k (-vbr off) to VBR 48k with -application voip and -compression_level 10. The old CBR settings produced lower-quality speech audio and occasionally failed to trigger Telegram's native voice-bubble rendering. Applied to _ffmpeg_transcode_to_opus (the single transcoder behind _convert_to_opus and _repair_ogg_container), the Gemini WAV→OGG path, and the Matrix adapter boundary transcoder added in this branch. Fixes NousResearch#18818
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.
Summary
Fixes #18818 — suboptimal Opus encoding for Gemini/Edge TTS causing quality loss in Telegram voice messages.
Problem
Both
_convert_to_opus()and_generate_gemini_tts()use ffmpeg with suboptimal Opus encoding settings:Issues:
-vbr offforces Constant Bitrate (CBR) — wastes bits on silence, starves complex segments-application voip— Opus encoder defaults toaudiomode, not optimized for speech-compression_level 10— lower compression qualityThis causes:
Fix
Changed ffmpeg encoding parameters at both call sites:
-b:a64k48k-vbroff(CBR)on(VBR)-applicationvoip-compression_level10Testing
-application voipis a standard libopus option (value 2048) that enables CELT+SILK hybrid mode optimized for speechAffected Code
tools/tts_tool.py:712—_convert_to_opus()(used by Edge TTS, xAI TTS, and other providers)tools/tts_tool.py:1201—_generate_gemini_tts()inline conversion