Skip to content

Commit 5350f5b

Browse files
smthfoxyNing HuTakhoffman
authored
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 <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
1 parent 53a2e72 commit 5350f5b

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Docs: https://docs.openclaw.ai
3939
- Feishu/Docx convert fallback chunking: recursively split oversized markdown chunks (including long no-heading sections) when `document.convert` hits content limits, while keeping fenced-code-aware split boundaries whenever possible. (#14402) Thanks @lml2468.
4040
- Feishu/Inbound media regression coverage: add explicit tests for message resource type mapping (`image` stays `image`, non-image maps to `file`) to prevent reintroducing unsupported Feishu `type=audio` fetches. (#16311, #8746) Thanks @Yaxuan42.
4141
- Feishu/API quota controls: add `typingIndicator` and `resolveSenderNames` config flags (top-level and per-account) so operators can disable typing reactions and sender-name lookup requests while keeping default behavior unchanged. (#10513) Thanks @BigUncle.
42+
- TTS/Voice bubbles: use opus output and enable `audioAsVoice` routing for Feishu and WhatsApp (in addition to Telegram) so supported channels receive voice-bubble playback instead of file-style audio attachments. (#27366) Thanks @smthfoxy.
4243
- Security/Feishu webhook ingress: bound unauthenticated webhook rate-limit state with stale-window pruning and a hard key cap to prevent unbounded pre-auth memory growth from rotating source keys. (#26050) Thanks @bmendonca3.
4344
- Security/Compaction audit: remove the post-compaction audit injection message. (#28507) Thanks @fuller-stack-dev and @vincentkoc.
4445
- Telegram/Reply media context: include replied media files in inbound context when replying to media, defer reply-media downloads to debounce flush, gate reply-media fetch behind DM authorization, and preserve replied media when non-vision sticker fallback runs (including cached-sticker paths). (#28488) Thanks @obviyus.

src/tts/tts.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ describe("tts", () => {
154154
});
155155

156156
describe("resolveOutputFormat", () => {
157-
it("selects opus for Telegram and mp3 for other channels", () => {
157+
it("selects opus for voice-bubble channels (telegram/feishu/whatsapp) and mp3 for others", () => {
158158
const cases = [
159159
{
160160
channel: "telegram",
@@ -165,6 +165,24 @@ describe("tts", () => {
165165
voiceCompatible: true,
166166
},
167167
},
168+
{
169+
channel: "feishu",
170+
expected: {
171+
openai: "opus",
172+
elevenlabs: "opus_48000_64",
173+
extension: ".opus",
174+
voiceCompatible: true,
175+
},
176+
},
177+
{
178+
channel: "whatsapp",
179+
expected: {
180+
openai: "opus",
181+
elevenlabs: "opus_48000_64",
182+
extension: ".opus",
183+
voiceCompatible: true,
184+
},
185+
},
168186
{
169187
channel: "discord",
170188
expected: {

src/tts/tts.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,11 @@ export function setLastTtsAttempt(entry: TtsStatusEntry | undefined): void {
480480
lastTtsAttempt = entry;
481481
}
482482

483+
/** Channels that require opus audio and support voice-bubble playback */
484+
const VOICE_BUBBLE_CHANNELS = new Set(["telegram", "feishu", "whatsapp"]);
485+
483486
function resolveOutputFormat(channelId?: string | null) {
484-
if (channelId === "telegram") {
487+
if (channelId && VOICE_BUBBLE_CHANNELS.has(channelId)) {
485488
return TELEGRAM_OUTPUT;
486489
}
487490
return DEFAULT_OUTPUT;
@@ -911,7 +914,8 @@ export async function maybeApplyTtsToPayload(params: {
911914
};
912915

913916
const channelId = resolveChannelId(params.channel);
914-
const shouldVoice = channelId === "telegram" && result.voiceCompatible === true;
917+
const shouldVoice =
918+
channelId !== null && VOICE_BUBBLE_CHANNELS.has(channelId) && result.voiceCompatible === true;
915919
const finalPayload = {
916920
...nextPayload,
917921
mediaUrl: result.audioPath,

0 commit comments

Comments
 (0)