Skip to content

feat: support sending voice messages (SILK/MP3/OGG)#62

Open
lemoncat7 wants to merge 2 commits intoTencent:mainfrom
lemoncat7:main
Open

feat: support sending voice messages (SILK/MP3/OGG)#62
lemoncat7 wants to merge 2 commits intoTencent:mainfrom
lemoncat7:main

Conversation

@lemoncat7
Copy link
Copy Markdown

Summary

Adds support for sending voice messages to WeChat, completing the round-trip for voice media.

What was added

  • sendVoiceMessageWeixin() in src/messaging/send.ts

    • Sends voice via CDN upload + MessageItemType.VOICE
    • Supports encode types: 6=SILK, 7=MP3, 8=OGG-SPEEX
    • Optional playtimeMs and encodeType params
    • Optional text caption sent as a separate TEXT item first
  • uploadVoiceToWeixin() in src/cdn/upload.ts

    • Uploads audio files with media_type=4 (VOICE) to WeChat CDN
    • Reuses the existing uploadMediaToCdn() pipeline (AES-128-ECB encryption)
  • sendWeixinMediaFile() now routes audio/* MIME types to the voice path

    • audio/mp3 → encode_type=7
    • audio/ogg → encode_type=8
    • Default → encode_type=6 (SILK)

API surface

// Direct call with pre-uploaded audio
sendVoiceMessageWeixin({
  to: "wxid_xxx",
  text: "Optional caption",
  uploaded: { filekey, downloadEncryptedQueryParam, aeskey, fileSize, fileSizeCiphertext },
  encodeType: 6, // SILK
  playtimeMs: 5000,
  opts: { baseUrl, token, contextToken }
})

// Via sendWeixinMediaFile (auto-routes by MIME type)
sendWeixinMediaFile({ filePath: "/path/to/audio.mp3", to: "wxid_xxx", text: "...", opts, cdnBaseUrl })

Note

Receiving voice was already implemented (silk-transcode.ts + VoiceItem). This PR adds the send direction, making voice a full two-way media type.


Closes #feature/voice-send

MoShang added 2 commits April 14, 2026 11:43
- sendVoiceMessageWeixin(): sends voice via CDN + MessageItemType.VOICE
- uploadVoiceToWeixin(): uploads audio with media_type=4 (VOICE)
- sendWeixinMediaFile() routes audio/* to voice upload path
- Supported encode types: 6=SILK, 7=MP3, 8=OGG-SPEEX
- Closes #feature/voice-send
- sendVoiceMessageWeixin(): sends voice via CDN + MessageItemType.VOICE
- uploadVoiceToWeixin(): uploads audio with media_type=4 (VOICE)
- sendWeixinMediaFile() routes audio/* to voice upload path
- Supported encode types: 6=SILK, 7=MP3, 8=OGG-SPEEX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant