ADD GPT SOVITS V2
Closed this issue · 4 comments
kyakuno commented
GPT-SOVITSのV1をONNXに変換した際に書き換えたコードは下記。
RVC-Boss/GPT-SoVITS#835
ooe1123 commented
Export speed parameter
〇 GPT_SoVITS\module\models_onnx.py
class TextEncoder(nn.Module):
...
def forward(self, y, text, ge):
...
y = self.encoder2(y * y_mask, y_mask)
↓
class TextEncoder(nn.Module):
...
def forward(self, y, text, ge, speed):
...
y = self.encoder2(y * y_mask, y_mask)
if torch.onnx.is_in_onnx_export():
a = torch.cat([
((y.shape[-1] / speed).long()+1).unsqueeze(0),
y.shape[-1].unsqueeze(0)
], dim=0)
size = a[(speed == torch.tensor(1.0)).long()]
y = F.interpolate(y, size=size, mode="linear")
y_mask = F.interpolate(y_mask, size=y.shape[-1], mode="nearest")
else:
if(speed!=1):
y = F.interpolate(y, size=int(y.shape[-1] / speed)+1, mode="linear")
y_mask = F.interpolate(y_mask, size=y.shape[-1], mode="nearest")