Spaces:
Build error
Build error
File size: 2,097 Bytes
cbf648c |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
from urllib import request
import json
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
if __name__ == "__main__":
url = "https://32d343o770.wicp.vip/tts"
lan = {"中文":0,
"日文":1,
"英文":2,
"德文":3,
"克罗地亚文":4
}
idols ={"南小鸟":0,
"园田海未":1,
"小泉花阳":2,
"星空凛":3,
"东条希":4,
"矢泽妮可":5,
"绚濑绘里":6,
"西木野真姬":7,
"高坂穗乃果":8}
headers ={
"content-type": "application/json"}
while True:
input_sig = input('输入1进入云端文字转语音程序,输入其他字符退出程序')
if not input_sig == "1":
break
input_language = input('请选择语言,请输入“中文”或“日文”或“英文”或“德文”或“克罗地亚文”,不要加双引号:')
input_speaker_id = input('请选择说话人“请输入“南小鸟”或“园田海未”或“绚濑绘里”,不要加双引号:')
input_noise_rate = input('请填写噪音比例,数值范围是0.1-1:')
input_noise_deviation = input('请填写噪音偏差,数值范围是0.1-1:')
input_length_scale = input('请填写倍速,这是一个数值:')
input_text = input('请输入需要转语音的文本,不要加双引号:')
v_dict = {
'lan': lan.get(input_language),
'spk': idols.get(input_speaker_id),
"noise_rate": float(input_noise_rate),
'noise_deviation': float(input_noise_deviation),
'speed': float(input_length_scale),
'text': str(input_text)
}
req = request.Request(url=url,
headers=headers,
data=json.dumps(v_dict).encode("utf-8"))
reps = request.urlopen(req).read()
with open(f"{input_text}+{input_speaker_id}.wav", "wb") as f:
f.write(reps) |