Skip to content

The agent that grows with you

fix(tts): improve Opus encoding quality for voice messages

shellybotmoyer88f7fe3b1f1f
diff --git a/plugins/platforms/matrix/adapter.py b/plugins/platforms/matrix/adapter.py
index d2de4061a80..c6b2dcdd615 100644
--- a/plugins/platforms/matrix/adapter.py
+++ b/plugins/platforms/matrix/adapter.py
@@ -249,7 +249,13 @@ def _matrix_transcode_voice_to_ogg(path: str) -> Optional[str]:
"-ac",
"1",
"-b:a",
- "64k",
+ "48k",
+ "-vbr",
+ "on",
+ "-application",
+ "voip",
+ "-compression_level",
+ "10",
ogg_path,
],
capture_output=True,
diff --git a/tools/tts_tool.py b/tools/tts_tool.py
index 947fe60ed74..5455b0a5eff 100644
--- a/tools/tts_tool.py
+++ b/tools/tts_tool.py
@@ -1083,7 +1083,8 @@ def _ffmpeg_transcode_to_opus(input_path: str, ogg_path: str) -> Optional[str]:
try:
result = subprocess.run(
["ffmpeg", "-i", input_path, "-acodec", "libopus",
- "-ac", "1", "-b:a", "64k", "-vbr", "off", "-f", "ogg",
+ "-ac", "1", "-b:a", "48k", "-vbr", "on",
+ "-application", "voip", "-compression_level", "10", "-f", "ogg",
work_path, "-y"],
capture_output=True, timeout=30,
stdin=subprocess.DEVNULL,
@@ -2202,7 +2203,8 @@ def _generate_gemini_tts(text: str, output_path: str, tts_config: Dict[str, Any]
cmd = [
ffmpeg, "-i", wav_path,
"-acodec", "libopus", "-ac", "1",
- "-b:a", "64k", "-vbr", "off",
+ "-b:a", "48k", "-vbr", "on",
+ "-application", "voip", "-compression_level", "10",
"-y", "-loglevel", "error",
output_path,
]