Spaces:
Runtime error
Runtime error
zhuowen999
commited on
Commit
•
92c0935
1
Parent(s):
b645ce0
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,8 @@ import urllib.request
|
|
9 |
import zipfile
|
10 |
import gdown
|
11 |
from argparse import ArgumentParser
|
12 |
-
|
|
|
13 |
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt -d . -o hubert_base.pt")
|
14 |
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt -d . -o rmvpe.pt")
|
15 |
# os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/sail-rvc/yoimiya-jp/resolve/main/model.pth -d ./weights/yoimiya -o yoimiya.pth")
|
@@ -19,7 +20,7 @@ os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://hugging
|
|
19 |
# os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/sail-rvc/Eminem2333333/blob/main/model.pth -d ./weights/Eminem -o Eminem.pth")
|
20 |
# os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/sail-rvc/hitzeed-ch/resolve/main/model.index -d ./weights/Eminem -o Eminem.index")
|
21 |
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/zhuowen999/yutou/resolve/main/yutou.index -d ./weights/yutou -o yutou.index")
|
22 |
-
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/zhuowen999/yutou/resolve/main/yutou.pth -d ./weights/yutou -o .pth")
|
23 |
|
24 |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
25 |
|
@@ -65,6 +66,41 @@ if len(models) == 0:
|
|
65 |
raise ValueError("No model found in `weights` folder")
|
66 |
models.sort()
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
def model_data(model_name):
|
70 |
# global n_spk, tgt_sr, net_g, vc, cpt, version, index_file
|
@@ -178,11 +214,12 @@ def tts(
|
|
178 |
speed_str = f"+{speed}%"
|
179 |
else:
|
180 |
speed_str = f"{speed}%"
|
181 |
-
asyncio.run(
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
)
|
|
|
186 |
t1 = time.time()
|
187 |
edge_time = t1 - t0
|
188 |
audio, sr = librosa.load(edge_output_filename, sr=16000, mono=True)
|
|
|
9 |
import zipfile
|
10 |
import gdown
|
11 |
from argparse import ArgumentParser
|
12 |
+
import requests
|
13 |
+
import random
|
14 |
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt -d . -o hubert_base.pt")
|
15 |
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt -d . -o rmvpe.pt")
|
16 |
# os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/sail-rvc/yoimiya-jp/resolve/main/model.pth -d ./weights/yoimiya -o yoimiya.pth")
|
|
|
20 |
# os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/sail-rvc/Eminem2333333/blob/main/model.pth -d ./weights/Eminem -o Eminem.pth")
|
21 |
# os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/sail-rvc/hitzeed-ch/resolve/main/model.index -d ./weights/Eminem -o Eminem.index")
|
22 |
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/zhuowen999/yutou/resolve/main/yutou.index -d ./weights/yutou -o yutou.index")
|
23 |
+
os.system("aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/zhuowen999/yutou/resolve/main/yutou.pth -d ./weights/yutou -o yutou.pth")
|
24 |
|
25 |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
26 |
|
|
|
66 |
raise ValueError("No model found in `weights` folder")
|
67 |
models.sort()
|
68 |
|
69 |
+
def tts_new(text,path):
|
70 |
+
url = "https://www.text-to-speech.cn/getSpeek.php"
|
71 |
+
|
72 |
+
payload = {
|
73 |
+
"user_id": str(random.randint(120100,2000000)),
|
74 |
+
"language": "中文(普通话,简体)",
|
75 |
+
"voice": "zh-CN-XiaoxiaoMultilingualNeural",
|
76 |
+
"text": text,
|
77 |
+
"role": "0",
|
78 |
+
"style": "0",
|
79 |
+
"styledegree": "1",
|
80 |
+
"volume": "75",
|
81 |
+
"predict": "0",
|
82 |
+
"rate": "-8",
|
83 |
+
"pitch": "0",
|
84 |
+
"kbitrate": "audio-16khz-128kbitrate-mono-mp3",
|
85 |
+
"silence": "",
|
86 |
+
"yzm": "^\""
|
87 |
+
}
|
88 |
+
headers = {
|
89 |
+
"Referer": "https://www.text-to-speech.cn/",
|
90 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0",
|
91 |
+
"accept": "*/*",
|
92 |
+
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
93 |
+
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
94 |
+
"origin": "https://www.text-to-speech.cn",
|
95 |
+
"referer": "https://www.text-to-speech.cn/"
|
96 |
+
}
|
97 |
+
|
98 |
+
response = requests.post(url, data=payload, headers=headers)
|
99 |
+
url=response.json()['download']
|
100 |
+
print(response.json())
|
101 |
+
mp3=requests.get(url)
|
102 |
+
with open(path, "wb") as f:
|
103 |
+
f.write(mp3.content)
|
104 |
|
105 |
def model_data(model_name):
|
106 |
# global n_spk, tgt_sr, net_g, vc, cpt, version, index_file
|
|
|
214 |
speed_str = f"+{speed}%"
|
215 |
else:
|
216 |
speed_str = f"{speed}%"
|
217 |
+
# asyncio.run(
|
218 |
+
# edge_tts.Communicate(
|
219 |
+
# tts_text, "-".join(tts_voice.split("-")[:-1]), rate=speed_str
|
220 |
+
# ).save(edge_output_filename)
|
221 |
+
# )
|
222 |
+
tts_new(tts_text,edge_output_filename)
|
223 |
t1 = time.time()
|
224 |
edge_time = t1 - t0
|
225 |
audio, sr = librosa.load(edge_output_filename, sr=16000, mono=True)
|