Skip to content

Commit cca9970

Browse files
author
jiangtao
committed
add tts.py
1 parent d75a17a commit cca9970

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tts.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
access_token= "_jYCQn1dqmJTlTtWEXivEmoWvQBFyAuS"
1515
cluster = "volcano_tts"
1616

17-
voice_type = "zh_male_yangguangqingnian_moon_bigtts"
17+
voice_type = "BV700_streaming"
1818
host = "openspeech.bytedance.com"
1919
api_url = f"https://{host}/api/v1/tts"
2020

@@ -31,10 +31,11 @@
3131
},
3232
"audio": {
3333
"voice_type": voice_type,
34-
"encoding": "pcm",
34+
"encoding": "wav",
3535
"speed_ratio": 1.0,
3636
"volume_ratio": 1.0,
3737
"pitch_ratio": 1.0,
38+
"rate":16000
3839
},
3940
"request": {
4041
"reqid": str(uuid.uuid4()),
@@ -50,10 +51,11 @@
5051
if __name__ == '__main__':
5152
try:
5253
resp = requests.post(api_url, json.dumps(request_json), headers=header)
53-
print(f"resp body: \n{resp.json()["addition"]["duration"]}")
54+
#print(f"resp body: \n{resp.json()["addition"]["duration"]}")
55+
print(f"resp body: \n{resp.json()}")
5456
if "data" in resp.json():
5557
data = resp.json()["data"]
56-
file_to_save = open("test_submit.mp3", "wb")
58+
file_to_save = open("test_submit.opus", "wb")
5759
file_to_save.write(base64.b64decode(data))
5860
except Exception as e:
5961
e.with_traceback()

0 commit comments

Comments
 (0)