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