Files
Ai_people_develop/test_file/AI_sounds/sounds_api_test.py
T
2024-07-02 13:54:57 +08:00

21 lines
623 B
Python

from gradio_client import Client
import wave
import os
client = Client("http://127.0.0.1:7860/")
result = client.predict(
"试一下效果怎么样?你好这是一个测试音频,实现了api音频实时输出",
"example",
"简体中文",
0.8,
fn_index=0
)
print(result)
# 获取当前目录
current_dir = os.getcwd()
# 构建目标文件路径
target_file_path = os.path.join(current_dir, 'audio.wav')
print(target_file_path)
# 复制文件到当前目录
with open(result[1], 'rb') as source_file:
with open(target_file_path, 'wb') as target_file:
target_file.write(source_file.read())