Mahiruoshi
commited on
Commit
•
e822849
1
Parent(s):
9060ca6
Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,3 @@
|
|
1 |
-
import ONNXVITS_models
|
2 |
-
import utils
|
3 |
-
from text import text_to_sequence
|
4 |
-
import torch
|
5 |
-
import commons
|
6 |
-
|
7 |
-
def get_text(text, hps):
|
8 |
-
text_norm = text_to_sequence(text, hps.symbols, hps.data.text_cleaners)
|
9 |
-
if hps.data.add_blank:
|
10 |
-
text_norm = commons.intersperse(text_norm, 0)
|
11 |
-
text_norm = torch.LongTensor(text_norm)
|
12 |
-
return text_norm
|
13 |
-
|
14 |
-
hps = utils.get_hparams_from_file("lovelive/config.json")
|
15 |
-
symbols = hps.symbols
|
16 |
-
net_g = ONNXVITS_models.SynthesizerTrn(
|
17 |
-
len(symbols),
|
18 |
-
hps.data.filter_length // 2 + 1,
|
19 |
-
hps.train.segment_size // hps.data.hop_length,
|
20 |
-
n_speakers=hps.data.n_speakers,
|
21 |
-
**hps.model)
|
22 |
-
_ = net_g.eval()
|
23 |
-
_ = utils.load_checkpoint("lovelive/G_525000.pth", net_g)
|
24 |
-
|
25 |
-
text1 = get_text("[JA]ありがとうございます。[JA]", hps)
|
26 |
-
stn_tst = text1
|
27 |
-
with torch.no_grad():
|
28 |
-
x_tst = stn_tst.unsqueeze(0)
|
29 |
-
x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
|
30 |
-
sid = torch.tensor([0])
|
31 |
-
o = net_g(x_tst, x_tst_lengths, sid=sid, noise_scale=.667, noise_scale_w=0.8, length_scale=1)
|
32 |
-
'''
|
33 |
import romajitable
|
34 |
import re
|
35 |
import numpy as np
|
@@ -39,7 +7,7 @@ import IPython.display as ipd
|
|
39 |
import torch
|
40 |
import commons
|
41 |
import utils
|
42 |
-
import
|
43 |
from text.symbols import symbols
|
44 |
from text import text_to_sequence
|
45 |
import gradio as gr
|
@@ -181,7 +149,7 @@ lan = ["中文","日文","自动"]
|
|
181 |
idols = ["高咲侑","歩夢","かすみ","しずく","果林","愛","せつ菜","璃奈","栞子","エマ","ランジュ","ミア","派蒙"]
|
182 |
dev = torch.device("cpu")
|
183 |
hps_ms = utils.get_hparams_from_file("lovelive/config.json")
|
184 |
-
net_g_ms =
|
185 |
len(symbols),
|
186 |
hps_ms.data.filter_length // 2 + 1,
|
187 |
hps_ms.train.segment_size // hps_ms.data.hop_length,
|
@@ -193,7 +161,7 @@ app = gr.Blocks()
|
|
193 |
with app:
|
194 |
with gr.Tabs():
|
195 |
|
196 |
-
with gr.TabItem("虹团vits
|
197 |
|
198 |
tts_input1 = gr.TextArea(label="去标贝新模型,老版本在lovelive文件夹中", value="数千怀言者已经为你集结,列队在通往主舰桥的过道上。他们歌唱着你们名字,高声呼喊,以一种原始的、咆哮般的合唱作为对你的致敬。你从他们中间走过,一边点头,一边接受他们的赞美,你沉溺其中,几乎被他们巨大的音量所震撼。\n他们之中没有一个胆敢直视你。没有一个能够承受。你对他们超人类的眼睛来说都太过光辉。从他们中间走过时,你巨大的影子从他们身上掠过,他们立时将目光挪开,眼含泪水,吟诵你的大名时甚至不敢看你一眼。他们的吟唱中含有愤怒。几乎是疯狂的绝望。那感觉就好像他们害怕停下来,害怕自己会喘息停顿,好像尖叫出你的名字是唯一能让他们活着的事情。\n或许确实如此。作为对他们崇拜的回应,你谦虚地抬抬手,随后走进主舰桥。\nI In a word, Horus is a joker.")
|
199 |
language = gr.Dropdown(label="选择语言,目前勉强可以做到自动识别",choices=lan, value="自动", interactive=True)
|
@@ -205,5 +173,4 @@ with app:
|
|
205 |
tts_output2 = gr.Audio(label="Output")
|
206 |
tts_submit.click(infer, [language,tts_input1,speaker1,para_input1,para_input2,para_input3], [tts_output2])
|
207 |
#app.launch(share=True)
|
208 |
-
app.launch()
|
209 |
-
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import romajitable
|
2 |
import re
|
3 |
import numpy as np
|
|
|
7 |
import torch
|
8 |
import commons
|
9 |
import utils
|
10 |
+
from models import SynthesizerTrn
|
11 |
from text.symbols import symbols
|
12 |
from text import text_to_sequence
|
13 |
import gradio as gr
|
|
|
149 |
idols = ["高咲侑","歩夢","かすみ","しずく","果林","愛","せつ菜","璃奈","栞子","エマ","ランジュ","ミア","派蒙"]
|
150 |
dev = torch.device("cpu")
|
151 |
hps_ms = utils.get_hparams_from_file("lovelive/config.json")
|
152 |
+
net_g_ms = SynthesizerTrn(
|
153 |
len(symbols),
|
154 |
hps_ms.data.filter_length // 2 + 1,
|
155 |
hps_ms.train.segment_size // hps_ms.data.hop_length,
|
|
|
161 |
with app:
|
162 |
with gr.Tabs():
|
163 |
|
164 |
+
with gr.TabItem("虹团vits模型,现可按句分割实现长文本合成,可自行用export_to_onnx.py导出"):
|
165 |
|
166 |
tts_input1 = gr.TextArea(label="去标贝新模型,老版本在lovelive文件夹中", value="数千怀言者已经为你集结,列队在通往主舰桥的过道上。他们歌唱着你们名字,高声呼喊,以一种原始的、咆哮般的合唱作为对你的致敬。你从他们中间走过,一边点头,一边接受他们的赞美,你沉溺其中,几乎被他们巨大的音量所震撼。\n他们之中没有一个胆敢直视你。没有一个能够承受。你对他们超人类的眼睛来说都太过光辉。从他们中间走过时,你巨大的影子从他们身上掠过,他们立时将目光挪开,眼含泪水,吟诵你的大名时甚至不敢看你一眼。他们的吟唱中含有愤怒。几乎是疯狂的绝望。那感觉就好像他们害怕停下来,害怕自己会喘息停顿,好像尖叫出你的名字是唯一能让他们活着的事情。\n或许确实如此。作为对他们崇拜的回应,你谦虚地抬抬手,随后走进主舰桥。\nI In a word, Horus is a joker.")
|
167 |
language = gr.Dropdown(label="选择语言,目前勉强可以做到自动识别",choices=lan, value="自动", interactive=True)
|
|
|
173 |
tts_output2 = gr.Audio(label="Output")
|
174 |
tts_submit.click(infer, [language,tts_input1,speaker1,para_input1,para_input2,para_input3], [tts_output2])
|
175 |
#app.launch(share=True)
|
176 |
+
app.launch()
|
|