mirror of
https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git
synced 2026-02-23 21:00:56 +00:00
Format code (#142)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
376bd31c19
commit
b4c653142d
@@ -2,27 +2,29 @@ from infer_pack.models_onnx_moess import SynthesizerTrnMs256NSFsidM
|
||||
from infer_pack.models_onnx import SynthesizerTrnMs256NSFsidO
|
||||
import torch
|
||||
|
||||
if __name__ == '__main__':
|
||||
MoeVS = True #模型是否为MoeVoiceStudio(原MoeSS)使用
|
||||
if __name__ == "__main__":
|
||||
MoeVS = True # 模型是否为MoeVoiceStudio(原MoeSS)使用
|
||||
|
||||
ModelPath = "Shiroha/shiroha.pth" #模型路径
|
||||
ExportedPath = "model.onnx" #输出路径
|
||||
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
|
||||
ModelPath = "Shiroha/shiroha.pth" # 模型路径
|
||||
ExportedPath = "model.onnx" # 输出路径
|
||||
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 = [
|
||||
@@ -52,7 +54,9 @@ if __name__ == '__main__':
|
||||
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 = [
|
||||
@@ -78,4 +82,4 @@ if __name__ == '__main__':
|
||||
verbose=False,
|
||||
input_names=input_names,
|
||||
output_names=output_names,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user