Mahiruoshi commited on
Commit
c300a0f
1 Parent(s): 43bee8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -120,7 +120,7 @@ def extrac(text):
120
  final_list = [x for x in final_list if x != '']
121
  print(final_list)
122
  return final_list
123
- def infer(language,text,speaker_id, n_scale= 0.667,n_scale_w = 0.8, l_scale = 1 ):
124
  speaker_id = int(selection(speaker_id))
125
  a = ['【','[','(','(']
126
  b = ['】',']',')',')']
@@ -152,7 +152,9 @@ def infer(language,text,speaker_id, n_scale= 0.667,n_scale_w = 0.8, l_scale = 1
152
  print(time_end)
153
  f1.write(str(c-1)+'\n'+time_start+' --> '+time_end+'\n'+sentence+'\n\n')
154
  audio_fin.append(audio)
155
- return (hps_ms.data.sampling_rate, np.concatenate(audio_fin))
 
 
156
  lan = ["中文","日文","自动"]
157
  idols = ["高咲侑","歩夢","かすみ","しずく","果林","愛","せつ菜","璃奈","栞子","エマ","ランジュ","ミア","派蒙"]
158
  hps_ms = utils.get_hparams_from_file("lovelive/config.json")
@@ -164,20 +166,18 @@ net_g_ms = SynthesizerTrn(
164
  **hps_ms.model).to(dev)
165
  _ = net_g_ms.eval()
166
  _ = utils.load_checkpoint("lovelive/G_936000.pth", net_g_ms)
167
- app = gr.Blocks()
168
- with app:
169
- with gr.Tabs():
170
-
171
- with gr.TabItem("虹团vits模型,现可按句分割实现长文本合成,可自行用export_to_onnx.py导出"):
172
-
173
- tts_input1 = gr.TextArea(label="如需实现快速合成,建议在colab上克隆后运行本仓库", value="为什么你会那么熟练啊?你和雪菜亲过多少次了?我想做只属于你一个人的学院偶像,所以,请只注视我一个人,好吗?【中文】\nなんでそんなに慣れてんだよっ?せつ菜と…何回キスしたんだよ?どこまであたしを置いてきぼりにすれば気が済むんだよ?[日文]\nI can't choose just one(English)")
174
- language = gr.Dropdown(label="选择语言,目前勉强可以做到自动识别",choices=lan, value="自动", interactive=True)
175
- para_input1 = gr.Slider(minimum= 0,maximum=1.0,label="更改噪声比例,以控制情感", value=0.667)
176
- para_input2 = gr.Slider(minimum= 0,maximum=1.0,label="更改噪声偏差,以控制音素长短", value=0.7)
177
- para_input3 = gr.Slider(minimum= 0.1,maximum=10,label="更改时间比例", value=1)
178
- tts_submit = gr.Button("Generate", variant="primary")
179
- speaker1 = gr.Dropdown(label="选择说话人",choices=idols, value="歩夢", interactive=True)
180
- tts_output2 = gr.Audio(label="字幕见 https://huggingface.co/spaces/Mahiruoshi/Lovelive_Nijigasaki_VITS/subtitles.srt")
181
- tts_submit.click(infer, [language,tts_input1,speaker1,para_input1,para_input2,para_input3], [tts_output2])
182
- #app.launch(share=True)
183
- app.launch()
 
120
  final_list = [x for x in final_list if x != '']
121
  print(final_list)
122
  return final_list
123
+ def infer(text ,language, speaker_id,n_scale= 0.667,n_scale_w = 0.8, l_scale = 1):
124
  speaker_id = int(selection(speaker_id))
125
  a = ['【','[','(','(']
126
  b = ['】',']',')',')']
 
152
  print(time_end)
153
  f1.write(str(c-1)+'\n'+time_start+' --> '+time_end+'\n'+sentence+'\n\n')
154
  audio_fin.append(audio)
155
+ with open("subtitles.srt", 'r', encoding='utf-8') as file:
156
+ subtitles = file.read()
157
+ return (hps_ms.data.sampling_rate, np.concatenate(audio_fin)),subtitles
158
  lan = ["中文","日文","自动"]
159
  idols = ["高咲侑","歩夢","かすみ","しずく","果林","愛","せつ菜","璃奈","栞子","エマ","ランジュ","ミア","派蒙"]
160
  hps_ms = utils.get_hparams_from_file("lovelive/config.json")
 
166
  **hps_ms.model).to(dev)
167
  _ = net_g_ms.eval()
168
  _ = utils.load_checkpoint("lovelive/G_936000.pth", net_g_ms)
169
+ inputs = [gr.TextArea(label="如需实现快速合成,建议在colab上克隆后运行本仓库", value="为什么你会那么熟练啊?你和雪菜亲过多少次了?我想做只属于你一个人的学院偶像,所以,请只注视我一个人,好吗?【中文】\nなんでそんなに慣れてんだよっ?せつ菜と…何回キスしたんだよ?どこまであたしを置いてきぼりにすれば気が済むんだよ?[日文]\nI can't choose just one(English)"),
170
+ gr.Dropdown(label="选择语言,目前勉强可以做到自动识别",choices=lan, value="自动", interactive=True),
171
+ gr.Dropdown(label="选择说话人",choices=idols, value="歩夢", interactive=True),
172
+ gr.Slider(minimum= 0,maximum=1.0,label="更改噪声比例,以控制情感", value=0.267),
173
+ gr.Slider(minimum= 0,maximum=1.0,label="更改噪声偏差,以控制音素长短", value=0.7),
174
+ gr.Slider(minimum= 0.1,maximum=10,label="更改时间比例", value=1)]
175
+ outputs=[gr.Audio(label="采样率22050"), gr.outputs.File(label="字幕文件:subtitles.srt")]
176
+ iface = gr.Interface(
177
+ fn=infer,
178
+ inputs=inputs,
179
+ outputs=outputs,
180
+ title="Vits",
181
+ description="虹团11人模型",
182
+ )
183
+ iface.launch()