mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:28:26 +00:00
fix(discord): resample audio to 48kHz for voice messages (#32298)
Fixes #32293: Discord voice message plays at ~0.5x speed with 24kHz TTS source When TTS providers (like mlx-audio Qwen3-TTS) output audioHz, Discord voice at 24k messages play at half speed because Discord expects 48kHz. This fix adds explicit sample rate conversion to 48kHz in the ensureOggOpus function, ensuring voice messages always play at correct speed regardless of the input audio's sample rate. Co-authored-by: Kevin Shenghui <shenghuikevin@gmail.com>
This commit is contained in:
@@ -182,6 +182,8 @@ export async function ensureOggOpus(filePath: string): Promise<{ path: string; c
|
||||
}
|
||||
|
||||
// Convert to OGG/Opus
|
||||
// Always resample to 48kHz to ensure Discord voice messages play at correct speed
|
||||
// (Discord expects 48kHz; lower sample rates like 24kHz from some TTS providers cause 0.5x playback)
|
||||
const tempDir = resolvePreferredOpenClawTmpDir();
|
||||
const outputPath = path.join(tempDir, `voice-${crypto.randomUUID()}.ogg`);
|
||||
|
||||
@@ -189,6 +191,8 @@ export async function ensureOggOpus(filePath: string): Promise<{ path: string; c
|
||||
"-y",
|
||||
"-i",
|
||||
filePath,
|
||||
"-ar",
|
||||
"48000",
|
||||
"-c:a",
|
||||
"libopus",
|
||||
"-b:a",
|
||||
|
||||
Reference in New Issue
Block a user