Skip to content

feat: add DashScope TTS provider and WeChat audio file sending#3270

Open
MrTreasure wants to merge 1 commit into
sipeed:mainfrom
MrTreasure:feat/dashscope-tts-weixin-audio
Open

feat: add DashScope TTS provider and WeChat audio file sending#3270
MrTreasure wants to merge 1 commit into
sipeed:mainfrom
MrTreasure:feat/dashscope-tts-weixin-audio

Conversation

@MrTreasure

Copy link
Copy Markdown

Summary

This PR adds DashScope (Bailian) TTS support and WeChat audio file sending to picoclaw.

Changes

1. DashScope TTS Provider (pkg/audio/tts/dashscope_tts.go — new file)

A complete TTS provider for Alibaba Cloud DashScope/Bailian platform:

  • Calls DashScope aigc/multimodal-generation/generation API
  • Supports qwen3-tts-flash and other DashScope TTS models
  • Auto-extracts workspace ID from Bailian MAAS base URL
  • Downloads generated audio from OSS URL
  • Returns WAV audio stream compatible with existing send_tts tool

2. TTS Provider Routing (pkg/audio/tts/tts.go)

Adds case "dashscope" to providerFromModelConfig:

  • Extracts voice config from extra_body
  • Resolves workspace ID from api_base or default DashScope base URL

3. WeChat Audio Support (pkg/channels/weixin/media.go)

  • outboundMediaKind: Detects audio/* MIME types and common audio extensions — routes as file attachment
  • sendUploadedMedia: Adds UploadMediaTypeVoice case with VoiceItem (forward-looking)
  • tryTranscodeAudioToSilk: ffmpeg PCM decode + silk_encoder -tencent → WeChat SILK

Platform Limitation

WeChat iLink bot API silently drops outbound VoiceItem messages. Audio is routed as file attachment which works reliably. SILK transcode + VoiceItem code paths preserved for future.

🤖 Generated with Claude Code

@CLAassistant

CLAassistant commented Jul 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

- Add DashScopeTTSProvider for Bailian/DashScope TTS API
  - Supports qwen3-tts-flash and other DashScope TTS models
  - Auto-extracts workspace ID from Bailian MAAS base URL
  - Downloads audio from OSS and returns WAV stream
  - Integrates with existing provider framework via 'dashscope' protocol

- Add audio type detection in WeChat outboundMediaKind
  - Detects audio/* MIME types and common audio file extensions
  - Routes audio as file attachment (WeChat iLink bots cannot send
    native voice bubbles - server-side limitation)

- Add tryTranscodeAudioToSilk helper for WeChat voice transcoding
  - ffmpeg decode to 24kHz mono PCM → silk_encoder -tencent SILK
  - Ready for future use when WeChat lifts voice bubble restriction

- Add UploadMediaTypeVoice / VoiceItem support in sendUploadedMedia
  - Forward-looking: VoiceItem structure is accepted by iLink API
    but silently dropped on delivery (platform limitation)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

2 participants