Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,8 @@ import librosa
|
|
9 |
import numpy as np
|
10 |
import soundfile
|
11 |
from scipy.io import wavfile
|
|
|
|
|
12 |
|
13 |
from inference.infer_tool import Svc
|
14 |
|
@@ -50,21 +52,28 @@ def create_fn(model, spk):
|
|
50 |
os.remove(temp_path)
|
51 |
return sr, out_audio
|
52 |
|
53 |
-
def tts_fn(input_text, gender, tts_rate, vc_transform, auto_f0, f0p):
|
54 |
if input_text == '':
|
55 |
return 0, None
|
56 |
input_text = re.sub(r"[\n\,\(\) ]", "", input_text)
|
57 |
voice = tts_voice[gender]
|
58 |
ratestr = "+{:.0%}".format(tts_rate) if tts_rate >= 0 else "{:.0%}".format(tts_rate)
|
59 |
-
temp_path = "temp.wav"
|
60 |
-
p = subprocess.Popen("edge-tts " +
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
p.wait()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
audio, sr = librosa.load(temp_path)
|
69 |
audio = librosa.resample(audio, orig_sr=sr, target_sr=sampling_rate)
|
70 |
os.remove(temp_path)
|
@@ -93,7 +102,7 @@ if __name__ == '__main__':
|
|
93 |
gr.Markdown(
|
94 |
"# <center> 罪恶都市角色语音生成,即将上线...\n"
|
95 |
"## <center> 模型作者:B站[Cyber蝈蝈总](https://space.bilibili.com/37706580)\n"
|
96 |
-
"<center> 圣安地列斯人物AI语音请移步[
|
97 |
)
|
98 |
with gr.Tabs():
|
99 |
for (name, cover, (svc_fn, tts_fn)) in models:
|
|
|
9 |
import numpy as np
|
10 |
import soundfile
|
11 |
from scipy.io import wavfile
|
12 |
+
import edge_tts
|
13 |
+
import tempfile
|
14 |
|
15 |
from inference.infer_tool import Svc
|
16 |
|
|
|
52 |
os.remove(temp_path)
|
53 |
return sr, out_audio
|
54 |
|
55 |
+
async def tts_fn(input_text, gender, tts_rate, vc_transform, auto_f0, f0p):
|
56 |
if input_text == '':
|
57 |
return 0, None
|
58 |
input_text = re.sub(r"[\n\,\(\) ]", "", input_text)
|
59 |
voice = tts_voice[gender]
|
60 |
ratestr = "+{:.0%}".format(tts_rate) if tts_rate >= 0 else "{:.0%}".format(tts_rate)
|
61 |
+
# temp_path = "temp.wav"
|
62 |
+
# p = subprocess.Popen("edge-tts " +
|
63 |
+
# " --text " + input_text +
|
64 |
+
# " --write-media " + temp_path +
|
65 |
+
# " --voice " + voice +
|
66 |
+
# " --rate=" + ratestr, shell=True,
|
67 |
+
# stdout=subprocess.PIPE,
|
68 |
+
# stdin=subprocess.PIPE)
|
69 |
+
# p.wait()
|
70 |
+
communicate = edge_tts.Communicate(text=input_text,
|
71 |
+
voice=voice,
|
72 |
+
rate=ratestr)
|
73 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
74 |
+
temp_path = tmp_file.name
|
75 |
+
await communicate.save(temp_path)
|
76 |
+
|
77 |
audio, sr = librosa.load(temp_path)
|
78 |
audio = librosa.resample(audio, orig_sr=sr, target_sr=sampling_rate)
|
79 |
os.remove(temp_path)
|
|
|
102 |
gr.Markdown(
|
103 |
"# <center> 罪恶都市角色语音生成,即将上线...\n"
|
104 |
"## <center> 模型作者:B站[Cyber蝈蝈总](https://space.bilibili.com/37706580)\n"
|
105 |
+
"<center> 圣安地列斯人物AI语音请移步[GTASA](https://huggingface.co/spaces/GroveStreet/GTA_SOVITS),使用此资源创作的作品请标明出处\n"
|
106 |
)
|
107 |
with gr.Tabs():
|
108 |
for (name, cover, (svc_fn, tts_fn)) in models:
|