Wanlau commited on
Commit
e66c360
1 Parent(s): 79412f8

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -77
app.py DELETED
@@ -1,77 +0,0 @@
1
- import io
2
- import os
3
-
4
- #os.system("wget -P hubert/ https://huggingface.co/spaces/innnky/nanami/resolve/main/checkpoint_best_legacy_500.pt")
5
- import gradio as gr
6
- import librosa
7
- import numpy as np
8
- import soundfile
9
- from inference.infer_tool import Svc
10
- import logging
11
-
12
- logging.getLogger('numba').setLevel(logging.WARNING)
13
- logging.getLogger('markdown_it').setLevel(logging.WARNING)
14
- logging.getLogger('urllib3').setLevel(logging.WARNING)
15
- logging.getLogger('matplotlib').setLevel(logging.WARNING)
16
-
17
- model = Svc("logs/44k/06_21_27_28/G_61000.pth", "logs/44k/06_21_27_28/config.json", cluster_model_path="logs/44k/06_21_27_28/kmeans_10000.pt")
18
-
19
-
20
-
21
- def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, noise_scale):
22
- if input_audio is None:
23
- return "You need to upload an audio", None
24
- sampling_rate, audio = input_audio
25
- # print(audio.shape,sampling_rate)
26
- duration = audio.shape[0] / sampling_rate
27
- if duration > 45:
28
- return "请上传小于45s的音频,需要转换长音频请本地进行转换", None
29
- audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
30
- if len(audio.shape) > 1:
31
- audio = librosa.to_mono(audio.transpose(1, 0))
32
- if sampling_rate != 16000:
33
- audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
34
- print(audio.shape)
35
- out_wav_path = "temp.wav"
36
- soundfile.write(out_wav_path, audio, 16000, format="wav")
37
- print( cluster_ratio, auto_f0, noise_scale)
38
- out_audio, out_sr = model.infer(sid, vc_transform, out_wav_path,
39
- cluster_infer_ratio=cluster_ratio,
40
- auto_predict_f0=auto_f0,
41
- noice_scale=noise_scale
42
- )
43
- return "Success", (44100, out_audio.cpu().numpy())
44
-
45
-
46
- app = gr.Blocks()
47
- with app:
48
- with gr.Tabs():
49
- with gr.TabItem("Basic"):
50
- gr.Markdown(value="""
51
- datealive角色语音合成 so-vits-svc-4.0 在线试用
52
- 使用凛绪轮回中的语音数据训练而成。
53
- 目前可用角色为凛祢、凛绪、鞠亚、鞠奈。
54
- 其它角色的模型已训练完成,包含游戏中出现的大部分角色。
55
- 可以在models中下载其它角色的模型以试用,文件夹名称对应角色编号。
56
- """)
57
- spks = list(model.spk2id.keys())
58
- sid = gr.Dropdown(label="音色", choices=spks, value=spks[0])
59
- vc_input3 = gr.Audio(label="上传音频(长度小于45秒)")
60
- vc_transform = gr.Number(label="变调(整数,可以正负,半音数量,升高八度就是12),使用变调请务必同时将伴奏变调相同半音数!", value=0)
61
- cluster_ratio = gr.Number(label="聚类模型混合比例,0-1之间,默认为0不启用聚类,能提升音色相似度,但会导致咬字下降(如果使用建议0.5左右)", value=0)
62
- auto_f0 = gr.Checkbox(label="自动f0预测,配合聚类模型f0预测效果更好,会导致变调功能失效(仅限转换语音,歌声不要勾选此项会究极跑调)", value=False)
63
- noise_scale = gr.Number(label="noise_scale 建议不要动,会影响音质,玄学参数", value=0.4)
64
- vc_submit = gr.Button("转换", variant="primary")
65
- vc_output1 = gr.Textbox(label="Output Message")
66
- vc_output2 = gr.Audio(label="Output Audio")
67
- vc_submit.click(vc_fn, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, noise_scale], [vc_output1, vc_output2])
68
-
69
- gr.HTML("""
70
- <div style="text-align:center">
71
- 仅供学习交流试用,不可用于商业或非法用途。
72
- <br/>
73
- 由此项目产出的任何结果公开发表需指明输入源,注明原作者及<a href="https://github.com/svc-develop-team/so-vits-svc" target="_blank">代码来源</a>。
74
- </div>
75
- """)
76
-
77
- app.launch()