import requests # 1. CosyVoice 端点 r = requests.post( 'https://dashscope.aliyuncs.com/api/v1/services/audio/tts/SpeechSynthesizer', headers={'Authorization': 'Bearer sk-c25679401ba24c749f53be86b0c9a7a6', 'Content-Type': 'application/json'}, json={'model': 'cosyvoice-v3-flash', 'input': {'text': '春天来了', 'voice': 'longanyang'}} ) print(f'SpeechSynthesizer: HTTP {r.status_code}') d = r.json() if r.status_code == 200: print(f' ✅ audioUrl={d["output"]["audio"]["url"][:60]}...') else: print(f' ❌ {d.get("message","")}') # 2. Qwen-TTS 端点(旧) r2 = requests.post( 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation', headers={'Authorization': 'Bearer sk-c25679401ba24c749f53be86b0c9a7a6', 'Content-Type': 'application/json'}, json={'model': 'cosyvoice-v3-flash', 'input': {'text': '春天来了', 'voice': 'longanyang'}} ) print(f'multimodal: HTTP {r2.status_code}') print(f' {r2.json().get("message","")}')