更新v2代码测试脚本,现在主要处理bert语义预测过慢的问题

This commit is contained in:
Karyl01 2025-05-09 17:02:30 +08:00
parent e270178100
commit bc8ca3efb4
2 changed files with 27 additions and 11 deletions

Binary file not shown.

38
test.py
View File

@ -1,24 +1,40 @@
import requests import requests
# API地址本地运行 # API地址本地运行
url = "http://127.0.0.1:9880" url = "http://127.0.0.1:9880/tts"
# 请求体 # 请求体(对齐 api_v2.py 的 POST 定义)
payload = { payload = {
"refer_wav_path": "Arona_Academy_In_2.ogg.wav", # 替换为你的参考音频路径 "ref_audio_path": "Arona_Academy_In_2.ogg.wav",
"prompt_text": "様々な授業やイベントが準備されているので、ご希望のスケジュールを選んでください!", # 参考音频中的文字 "prompt_text": "様々な授業やイベントが準備されているので、ご希望のスケジュールを選んでください!",
"prompt_language": "ja", # 语言 "prompt_lang": "ja",
"text": "你好。你好。你好。你好。你好。你好。你好。你好。你好。你好。你好。", "text": "中国大陆一共有31个省份啦",
"text_language": "zh" "text_lang": "zh",
"top_k": 5,
"top_p": 1.0,
"temperature": 1.0,
"text_split_method": "cut0",
"batch_size": 1,
"batch_threshold": 0.75,
"split_bucket": True,
"speed_factor": 1.0,
"fragment_interval": 0.3,
"seed": -1,
"media_type": "wav",
"streaming_mode": False,
"parallel_infer": True,
"repetition_penalty": 1.35,
"sample_steps": 32,
"super_sampling": False
} }
# 发送 POST 请求 # 发送 POST 请求
response = requests.post(url, json=payload) response = requests.post(url, json=payload)
# 检查返回 # 检查返回并保存音频
if response.status_code == 200: if response.status_code == 200:
with open("output.wav", "wb") as f: with open("output.wav", "wb") as f:
f.write(response.content) f.write(response.content)
print("生成成功,保存为 output.wav") print("生成成功,保存为 output.wav")
else: else:
print(f"生成失败: {response.status_code}, 返回信息: {response.text}") print(f"生成失败: {response.status_code}, 返回信息: {response.text}")