fix(tts): use opus format and enable voice bubbles for feishu and whatsapp (#27366)

* fix(tts): use opus format and enable voice bubbles for feishu and whatsapp

Previously only Telegram received opus output and had `shouldVoice=true`.
Feishu and WhatsApp also support voice-bubble playback and require opus audio,
but were falling back to mp3 with `audioAsVoice=false`.

- Extract VOICE_BUBBLE_CHANNELS set (telegram, feishu, whatsapp)
- resolveOutputFormat: return TELEGRAM_OUTPUT (opus) for all voice-bubble channels
- shouldVoice: enable for all voice-bubble channels, not just telegram
- Update test to cover feishu and whatsapp cases

* Changelog: add TTS voice-bubble channel coverage note

---------

Co-authored-by: Ning Hu <ninghu@Nings-MacBook-Pro.local>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
smthfoxy
2026-02-28 13:41:22 +08:00
committed by GitHub
parent 53a2e72fcb
commit 5350f5b035
3 changed files with 26 additions and 3 deletions

View File

@@ -480,8 +480,11 @@ export function setLastTtsAttempt(entry: TtsStatusEntry | undefined): void {
lastTtsAttempt = entry;
}
/** Channels that require opus audio and support voice-bubble playback */
const VOICE_BUBBLE_CHANNELS = new Set(["telegram", "feishu", "whatsapp"]);
function resolveOutputFormat(channelId?: string | null) {
if (channelId === "telegram") {
if (channelId && VOICE_BUBBLE_CHANNELS.has(channelId)) {
return TELEGRAM_OUTPUT;
}
return DEFAULT_OUTPUT;
@@ -911,7 +914,8 @@ export async function maybeApplyTtsToPayload(params: {
};
const channelId = resolveChannelId(params.channel);
const shouldVoice = channelId === "telegram" && result.voiceCompatible === true;
const shouldVoice =
channelId !== null && VOICE_BUBBLE_CHANNELS.has(channelId) && result.voiceCompatible === true;
const finalPayload = {
...nextPayload,
mediaUrl: result.audioPath,