debug_endpoint.py 1000 B

1234567891011121314151617181920212223
  1. import requests
  2. # 1. CosyVoice 端点
  3. r = requests.post(
  4. 'https://dashscope.aliyuncs.com/api/v1/services/audio/tts/SpeechSynthesizer',
  5. headers={'Authorization': 'Bearer sk-c25679401ba24c749f53be86b0c9a7a6', 'Content-Type': 'application/json'},
  6. json={'model': 'cosyvoice-v3-flash', 'input': {'text': '春天来了', 'voice': 'longanyang'}}
  7. )
  8. print(f'SpeechSynthesizer: HTTP {r.status_code}')
  9. d = r.json()
  10. if r.status_code == 200:
  11. print(f' ✅ audioUrl={d["output"]["audio"]["url"][:60]}...')
  12. else:
  13. print(f' ❌ {d.get("message","")}')
  14. # 2. Qwen-TTS 端点(旧)
  15. r2 = requests.post(
  16. 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation',
  17. headers={'Authorization': 'Bearer sk-c25679401ba24c749f53be86b0c9a7a6', 'Content-Type': 'application/json'},
  18. json={'model': 'cosyvoice-v3-flash', 'input': {'text': '春天来了', 'voice': 'longanyang'}}
  19. )
  20. print(f'multimodal: HTTP {r2.status_code}')
  21. print(f' {r2.json().get("message","")}')