api_example.py 788 Bytes
Newer Older
yangzhong's avatar
yangzhong committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests

SERVER_PORT = 6006

# 1. 使用本地文件请求,将 audio_paths 中的路径改为本地音频文件
url = F"http://0.0.0.0:{SERVER_PORT}/tts_url"
data = {
    "text": "还是会想你,还是想登你",
    "audio_paths": [  # 支持多参考音频
        "assets/jay_promptvn.wav",
        "assets/vo_card_klee_endOfGame_fail_01.wav"
    ]
}

response = requests.post(url, json=data)
with open("output.wav", "wb") as f:
    f.write(response.content)



# 2. 使用角色名请求,角色注册请参考 `assets/speaker.json`
url = f"http://0.0.0.0:{SERVER_PORT}/tts"
data = {
    "text": "还是会想你,还是想登你",
    "character": "jay_klee"
}

response = requests.post(url, json=data)
with open("output.wav", "wb") as f:
    f.write(response.content)