Format code (#142)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2023-04-24 20:35:56 +08:00
committed by GitHub
parent 376bd31c19
commit b4c653142d
8 changed files with 64 additions and 51 deletions

View File

@@ -119,7 +119,6 @@ for name in os.listdir(weight_uvr5_root):
uvr5_names.append(name.replace(".pth", ""))
def vc_single(
sid,
input_audio,
@@ -888,23 +887,27 @@ def change_info_(ckpt_path):
from infer_pack.models_onnx_moess import SynthesizerTrnMs256NSFsidM
from infer_pack.models_onnx import SynthesizerTrnMs256NSFsidO
def export_onnx(ModelPath, ExportedPath, MoeVS=True):
hidden_channels = 256 # hidden_channels为768Vec做准备
cpt = torch.load(ModelPath, map_location="cpu")
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
hidden_channels = 256 # hidden_channels为768Vec做准备
cpt = torch.load(ModelPath, map_location="cpu")
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
print(*cpt["config"])
test_phone = torch.rand(1, 200, hidden_channels) # hidden unit
test_phone_lengths = torch.tensor([200]).long() # hidden unit 长度(貌似没啥用)
test_pitch = torch.randint(size=(1, 200), low=5, high=255) # 基频(单位赫兹)
test_pitchf = torch.rand(1, 200) # nsf基频
test_ds = torch.LongTensor([0]) # 说话人ID
test_rnd = torch.rand(1, 192, 200) # 噪声(加入随机因子)
test_phone = torch.rand(1, 200, hidden_channels) # hidden unit
test_phone_lengths = torch.tensor([200]).long() # hidden unit 长度(貌似没啥用)
test_pitch = torch.randint(size=(1, 200), low=5, high=255) # 基频(单位赫兹)
test_pitchf = torch.rand(1, 200) # nsf基频
test_ds = torch.LongTensor([0]) # 说话人ID
test_rnd = torch.rand(1, 192, 200) # 噪声(加入随机因子)
device = "cpu" #导出时设备(不影响使用模型)
device = "cpu" # 导出时设备(不影响使用模型)
if MoeVS:
net_g = SynthesizerTrnMs256NSFsidM(*cpt["config"], is_half=False) # fp32导出C++要支持fp16必须手动将内存重新排列所以暂时不用fp16
net_g = SynthesizerTrnMs256NSFsidM(
*cpt["config"], is_half=False
) # fp32导出C++要支持fp16必须手动将内存重新排列所以暂时不用fp16
net_g.load_state_dict(cpt["weight"], strict=False)
input_names = ["phone", "phone_lengths", "pitch", "pitchf", "ds", "rnd"]
output_names = [
@@ -934,7 +937,9 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
output_names=output_names,
)
else:
net_g = SynthesizerTrnMs256NSFsidO(*cpt["config"], is_half=False) # fp32导出C++要支持fp16必须手动将内存重新排列所以暂时不用fp16
net_g = SynthesizerTrnMs256NSFsidO(
*cpt["config"], is_half=False
) # fp32导出C++要支持fp16必须手动将内存重新排列所以暂时不用fp16
net_g.load_state_dict(cpt["weight"], strict=False)
input_names = ["phone", "phone_lengths", "pitch", "pitchf", "ds"]
output_names = [
@@ -963,6 +968,7 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
)
return "Finished"
with gr.Blocks() as app:
gr.Markdown(
value=i18n(
@@ -1443,7 +1449,9 @@ with gr.Blocks() as app:
with gr.Row():
ckpt_dir = gr.Textbox(label=i18n("RVC模型路径"), value="", interactive=True)
with gr.Row():
onnx_dir = gr.Textbox(label=i18n("Onnx输出路径"), value="", interactive=True)
onnx_dir = gr.Textbox(
label=i18n("Onnx输出路径"), value="", interactive=True
)
with gr.Row():
moevs = gr.Checkbox(label=i18n("MoeVS模型"), value=True)
infoOnnx = gr.Label(label="Null")