Katock commited on
Commit
5a899c5
·
1 Parent(s): 05889b1
app.py CHANGED
@@ -29,27 +29,13 @@ def audio_postprocess(self, y):
29
 
30
  gr.Audio.postprocess = audio_postprocess
31
  def create_vc_fn(model, sid):
32
- def vc_fn(input_audio, vc_transform, auto_f0, tts_text, tts_voice, tts_mode):
33
- if tts_mode:
34
- if len(tts_text) > 100 and limitation:
35
- return "Text is too long", None
36
- if tts_text is None or tts_voice is None:
37
- return "You need to enter text and select a voice", None
38
- asyncio.run(edge_tts.Communicate(tts_text, "-".join(tts_voice.split('-')[:-1])).save("tts.mp3"))
39
- audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
40
- raw_path = io.BytesIO()
41
- soundfile.write(raw_path, audio, 16000, format="wav")
42
- raw_path.seek(0)
43
- out_audio, out_sr = model.infer(sid, vc_transform, raw_path,
44
- auto_predict_f0=auto_f0,
45
- )
46
- return "Success", (44100, out_audio.cpu().numpy())
47
  if input_audio is None:
48
- return "You need to upload an audio", None
49
  sampling_rate, audio = input_audio
50
  duration = audio.shape[0] / sampling_rate
51
  if duration > 20 and limitation:
52
- return "Please upload an audio file that is less than 20 seconds. If you need to generate a longer audio file, please use Colab.", None
53
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
54
  if len(audio.shape) > 1:
55
  audio = librosa.to_mono(audio.transpose(1, 0))
@@ -64,11 +50,6 @@ def create_vc_fn(model, sid):
64
  return "Success", (44100, out_audio.cpu().numpy())
65
  return vc_fn
66
 
67
- def change_to_tts_mode(tts_mode):
68
- if tts_mode:
69
- return gr.Audio.update(visible=False), gr.Textbox.update(visible=True), gr.Dropdown.update(visible=True), gr.Checkbox.update(value=True)
70
- else:
71
- return gr.Audio.update(visible=True), gr.Textbox.update(visible=False), gr.Dropdown.update(visible=False), gr.Checkbox.update(value=False)
72
 
73
  if __name__ == '__main__':
74
  parser = argparse.ArgumentParser()
@@ -78,12 +59,6 @@ if __name__ == '__main__':
78
  args = parser.parse_args()
79
  hubert_model = utils.get_hubert_model().to(args.device)
80
  models = []
81
- # others = {
82
- # "rudolf": "https://huggingface.co/spaces/sayashi/sovits-rudolf",
83
- # "teio": "https://huggingface.co/spaces/sayashi/sovits-teio",
84
- # "goldship": "https://huggingface.co/spaces/sayashi/sovits-goldship",
85
- # "tannhauser": "https://huggingface.co/spaces/sayashi/sovits-tannhauser"
86
- # }
87
  voices = []
88
  tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
89
  for r in tts_voice_list:
@@ -95,13 +70,8 @@ if __name__ == '__main__':
95
  models.append((name, cover, create_vc_fn(model, name)))
96
  with gr.Blocks() as app:
97
  gr.Markdown(
98
- "# <center> Sovits Models\n"
99
- "## <center> The input audio should be clean and pure voice without background music.\n"
100
- "![visitor badge](https://visitor-badge.glitch.me/badge?page_id=sayashi.Sovits-Umamusume)\n\n"
101
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1wfsBbMzmtLflOJeqc5ZnJiLY7L239hJW?usp=share_link)\n\n"
102
- "[![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm-dark.svg)](https://huggingface.co/spaces/sayashi/sovits-models?duplicate=true)\n\n"
103
- "[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/svc-develop-team/so-vits-svc)"
104
-
105
  )
106
  with gr.Tabs():
107
  for (name, cover, vc_fn) in models:
@@ -114,28 +84,12 @@ if __name__ == '__main__':
114
  )
115
  with gr.Row():
116
  with gr.Column():
117
- vc_input = gr.Audio(label="Input audio"+' (less than 20 seconds)' if limitation else '')
118
- vc_transform = gr.Number(label="vc_transform", value=0)
119
- auto_f0 = gr.Checkbox(label="auto_f0", value=False)
120
- tts_mode = gr.Checkbox(label="tts (use edge-tts as input)", value=False)
121
- tts_text = gr.Textbox(visible=False, label="TTS text (100 words limitation)" if limitation else "TTS text")
122
- tts_voice = gr.Dropdown(choices=voices, visible=False)
123
- vc_submit = gr.Button("Generate", variant="primary")
124
  with gr.Column():
125
- vc_output1 = gr.Textbox(label="Output Message")
126
- vc_output2 = gr.Audio(label="Output Audio")
127
- vc_submit.click(vc_fn, [vc_input, vc_transform, auto_f0, tts_text, tts_voice, tts_mode], [vc_output1, vc_output2])
128
- tts_mode.change(change_to_tts_mode, [tts_mode], [vc_input, tts_text, tts_voice, auto_f0])
129
- # for category, link in others.items():
130
- # with gr.TabItem(category):
131
- # gr.Markdown(
132
- # f'''
133
- # <center>
134
- # <h2>Click to Go</h2>
135
- # <a href="{link}">
136
- # <img src="https://huggingface.co/datasets/huggingface/badges/raw/main/open-in-hf-spaces-xl-dark.svg"
137
- # </a>
138
- # </center>
139
- # '''
140
- # )
141
  app.queue(concurrency_count=1, api_open=args.api).launch(share=args.share)
 
29
 
30
  gr.Audio.postprocess = audio_postprocess
31
  def create_vc_fn(model, sid):
32
+ def vc_fn(input_audio, vc_transform, auto_f0):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  if input_audio is None:
34
+ return "请先上传音频", None
35
  sampling_rate, audio = input_audio
36
  duration = audio.shape[0] / sampling_rate
37
  if duration > 20 and limitation:
38
+ return "请上传小于20秒的音频,或点击右上角裁剪", None
39
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
40
  if len(audio.shape) > 1:
41
  audio = librosa.to_mono(audio.transpose(1, 0))
 
50
  return "Success", (44100, out_audio.cpu().numpy())
51
  return vc_fn
52
 
 
 
 
 
 
53
 
54
  if __name__ == '__main__':
55
  parser = argparse.ArgumentParser()
 
59
  args = parser.parse_args()
60
  hubert_model = utils.get_hubert_model().to(args.device)
61
  models = []
 
 
 
 
 
 
62
  voices = []
63
  tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
64
  for r in tts_voice_list:
 
70
  models.append((name, cover, create_vc_fn(model, name)))
71
  with gr.Blocks() as app:
72
  gr.Markdown(
73
+ "# <center> GTASA人物SOVITS\n"
74
+ "## <center> 作者:B站Cyber蝈蝈总\n"
 
 
 
 
 
75
  )
76
  with gr.Tabs():
77
  for (name, cover, vc_fn) in models:
 
84
  )
85
  with gr.Row():
86
  with gr.Column():
87
+ vc_input = gr.Audio(label="输入干声"+' (小于 20 )' if limitation else '')
88
+ vc_transform = gr.Number(label="音高调整(��持正负半音,12为一个八度)", value=0)
89
+ auto_f0 = gr.Checkbox(label="自动音高预测(说话模式)", value=False)
90
+ vc_submit = gr.Button("生成", variant="primary")
 
 
 
91
  with gr.Column():
92
+ vc_output1 = gr.Textbox(label="输出信息")
93
+ vc_output2 = gr.Audio(label="输出音频")
94
+ vc_submit.click(vc_fn, [vc_input, vc_transform, auto_f0], [vc_output1, vc_output2])
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  app.queue(concurrency_count=1, api_open=args.api).launch(share=args.share)
models/tomori/config_tomori.json DELETED
@@ -1,99 +0,0 @@
1
- {
2
- "train": {
3
- "log_interval": 200,
4
- "eval_interval": 3200,
5
- "seed": 1234,
6
- "epochs": 30000,
7
- "learning_rate": 0.0001,
8
- "betas": [
9
- 0.8,
10
- 0.99
11
- ],
12
- "eps": 1e-09,
13
- "batch_size": 12,
14
- "fp16_run": false,
15
- "lr_decay": 0.999875,
16
- "segment_size": 10240,
17
- "init_lr_ratio": 1,
18
- "warmup_epochs": 0,
19
- "c_mel": 45,
20
- "c_kl": 1.0,
21
- "use_sr": true,
22
- "max_speclen": 512,
23
- "port": "8001",
24
- "keep_ckpts": 3,
25
- "all_in_mem": false,
26
- "vol_aug": true
27
- },
28
- "data": {
29
- "training_files": "filelists/train.txt",
30
- "validation_files": "filelists/val.txt",
31
- "max_wav_value": 32768.0,
32
- "sampling_rate": 44100,
33
- "filter_length": 2048,
34
- "hop_length": 512,
35
- "win_length": 2048,
36
- "n_mel_channels": 80,
37
- "mel_fmin": 0.0,
38
- "mel_fmax": 22050
39
- },
40
- "model": {
41
- "inter_channels": 192,
42
- "hidden_channels": 192,
43
- "filter_channels": 768,
44
- "n_heads": 2,
45
- "n_layers": 6,
46
- "kernel_size": 3,
47
- "p_dropout": 0.1,
48
- "resblock": "1",
49
- "resblock_kernel_sizes": [
50
- 3,
51
- 7,
52
- 11
53
- ],
54
- "resblock_dilation_sizes": [
55
- [
56
- 1,
57
- 3,
58
- 5
59
- ],
60
- [
61
- 1,
62
- 3,
63
- 5
64
- ],
65
- [
66
- 1,
67
- 3,
68
- 5
69
- ]
70
- ],
71
- "upsample_rates": [
72
- 8,
73
- 8,
74
- 2,
75
- 2,
76
- 2
77
- ],
78
- "upsample_initial_channel": 512,
79
- "upsample_kernel_sizes": [
80
- 16,
81
- 16,
82
- 4,
83
- 4,
84
- 4
85
- ],
86
- "n_layers_q": 3,
87
- "use_spectral_norm": false,
88
- "gin_channels": 768,
89
- "ssl_dim": 768,
90
- "n_speakers": 1,
91
- "vocoder_name": "nsf-hifigan",
92
- "speech_encoder": "vec768l12",
93
- "speaker_embedding": false,
94
- "vol_embedding": true
95
- },
96
- "spk": {
97
- "tomori": 0
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
models/tomori/tomori.pth DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5e915470eed2322969ae9dfadb51393f2f5744092690c11149de0ed65f04413f
3
- size 209238367
 
 
 
 
models/tomori/tomori_index.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2a069b9dfacaec64cbfa500576134535cac59b9fc08087f52c2cbeae90db9076
3
- size 189669700