quick_test.py 718 B

12345678910111213141516171819
  1. import requests, json
  2. # 1. 音色列表
  3. r = requests.get('http://localhost:3000/api/tts/voices')
  4. voices = r.json()['data']['voices']
  5. print(f'1. 音色数: {len(voices)},前3: {[v["id"] for v in voices[:3]]}')
  6. # 2. 生成音频
  7. r = requests.post('http://localhost:3000/api/tts/generate', json={
  8. 'text': '春天来了万物复苏阳光温暖地洒在大地上花儿竞相开放小鸟在枝头歌唱',
  9. 'voiceId': 'longanyang'
  10. })
  11. d = r.json()
  12. print(f'2. 生成: code={d.get("code")}, msg={d.get("message")}')
  13. if d.get('data'):
  14. print(f' audioId={d["data"].get("audioId")}')
  15. print(f' audioUrl={d["data"].get("audioUrl","")[:80]}')
  16. else:
  17. print(f' err={json.dumps(d, ensure_ascii=False)[:200]}')