Merge branch 'Stardust-minus:master' into master

This commit is contained in:
源文雨
2023-09-03 16:51:45 +08:00
committed by GitHub
6 changed files with 29 additions and 28 deletions

View File

@@ -3,3 +3,5 @@
VITS2 Backbone with bert VITS2 Backbone with bert
## 成熟的旅行者/开拓者/舰长/博士/sensei/猎魔人/喵喵露/V应该参阅代码自己学习如何训练。 ## 成熟的旅行者/开拓者/舰长/博士/sensei/猎魔人/喵喵露/V应该参阅代码自己学习如何训练。
### 严禁将此项目用于一切违反《中华人民共和国宪法》,《中华人民共和国刑法》,《中华人民共和国治安管理处罚法》和《中华人民共和国民法典》之用途。 ### 严禁将此项目用于一切违反《中华人民共和国宪法》,《中华人民共和国刑法》,《中华人民共和国治安管理处罚法》和《中华人民共和国民法典》之用途。
#### Video:https://www.bilibili.com/video/BV1hp4y1K78E
#### Demo:https://www.bilibili.com/video/BV1TF411k78w

View File

@@ -43,11 +43,11 @@ class Encoder(nn.Module):
self.kernel_size = kernel_size self.kernel_size = kernel_size
self.p_dropout = p_dropout self.p_dropout = p_dropout
self.window_size = window_size self.window_size = window_size
if isflow: #if isflow:
cond_layer = torch.nn.Conv1d(256, 2*hidden_channels*n_layers, 1) # cond_layer = torch.nn.Conv1d(256, 2*hidden_channels*n_layers, 1)
self.cond_pre = torch.nn.Conv1d(hidden_channels, 2*hidden_channels, 1) # self.cond_pre = torch.nn.Conv1d(hidden_channels, 2*hidden_channels, 1)
self.cond_layer = weight_norm(cond_layer, name='weight') # self.cond_layer = weight_norm(cond_layer, name='weight')
self.gin_channels = 256 # self.gin_channels = 256
self.cond_layer_idx = self.n_layers self.cond_layer_idx = self.n_layers
if 'gin_channels' in kwargs: if 'gin_channels' in kwargs:
self.gin_channels = kwargs['gin_channels'] self.gin_channels = kwargs['gin_channels']

View File

@@ -1,11 +1,11 @@
import torch import torch
from torch.utils.data import DataLoader from torch.utils.data import DataLoader
from multiprocessing import Pool
import commons import commons
import utils import utils
from data_utils import TextAudioSpeakerLoader, TextAudioSpeakerCollate from data_utils import TextAudioSpeakerLoader, TextAudioSpeakerCollate
from tqdm import tqdm from tqdm import tqdm
from multiprocessing import Pool import warnings
from text import cleaned_text_to_sequence, get_bert from text import cleaned_text_to_sequence, get_bert
@@ -40,14 +40,14 @@ def process_line(line):
torch.save(bert, bert_path) torch.save(bert, bert_path)
lines = [] if __name__ == '__main__':
with open(hps.data.training_files) as f: lines = []
lines.extend(f.readlines()) with open(hps.data.training_files, encoding='utf-8' ) as f:
lines.extend(f.readlines())
with open(hps.data.validation_files) as f: with open(hps.data.validation_files, encoding='utf-8' ) as f:
lines.extend(f.readlines()) lines.extend(f.readlines())
with Pool(processes=12) as pool: #A100 40GB suitable config,if coom,please decrease the processess number.
with Pool(processes=12) as pool: #A100 suitable config,if coom,please decrease the processess number. for _ in tqdm(pool.imap_unordered(process_line, lines)):
for _ in tqdm(pool.imap_unordered(process_line, lines)): pass
pass

View File

@@ -15,8 +15,6 @@ from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
from commons import init_weights, get_padding from commons import init_weights, get_padding
from text import symbols, num_tones, num_languages from text import symbols, num_tones, num_languages
class DurationDiscriminator(nn.Module): #vits2 class DurationDiscriminator(nn.Module): #vits2
# TODO : not using "spk conditioning" for now according to the paper.
# Can be a better discriminator if we use it.
def __init__(self, in_channels, filter_channels, kernel_size, p_dropout, gin_channels=0): def __init__(self, in_channels, filter_channels, kernel_size, p_dropout, gin_channels=0):
super().__init__() super().__init__()
@@ -34,11 +32,11 @@ class DurationDiscriminator(nn.Module): #vits2
self.dur_proj = nn.Conv1d(1, filter_channels, 1) self.dur_proj = nn.Conv1d(1, filter_channels, 1)
self.pre_out_conv_1 = nn.Conv1d(2*filter_channels, filter_channels, kernel_size, padding=kernel_size//2) self.pre_out_conv_1 = nn.Conv1d(2*filter_channels, filter_channels, kernel_size, padding=kernel_size//2)
self.pre_out_norm_1 = modules.LayerNorm(filter_channels) #self.pre_out_norm_1 = modules.LayerNorm(filter_channels)
self.pre_out_conv_2 = nn.Conv1d(filter_channels, filter_channels, kernel_size, padding=kernel_size//2) self.pre_out_conv_2 = nn.Conv1d(filter_channels, filter_channels, kernel_size, padding=kernel_size//2)
self.pre_out_norm_2 = modules.LayerNorm(filter_channels) #self.pre_out_norm_2 = modules.LayerNorm(filter_channels)
# if gin_channels != 0: #if gin_channels != 0:
# self.cond = nn.Conv1d(gin_channels, in_channels, 1) # self.cond = nn.Conv1d(gin_channels, in_channels, 1)
self.output_layer = nn.Sequential( self.output_layer = nn.Sequential(
@@ -64,7 +62,7 @@ class DurationDiscriminator(nn.Module): #vits2
def forward(self, x, x_mask, dur_r, dur_hat, g=None): def forward(self, x, x_mask, dur_r, dur_hat, g=None):
x = torch.detach(x) x = torch.detach(x)
# if g is not None: #if g is not None:
# g = torch.detach(g) # g = torch.detach(g)
# x = x + self.cond(g) # x = x + self.cond(g)
x = self.conv_1(x * x_mask) x = self.conv_1(x * x_mask)

View File

@@ -23,8 +23,8 @@ if 1 in stage:
f.write('{}|{}|{}|{}|{}|{}|{}\n'.format(utt, spk, language, norm_text, ' '.join(phones), f.write('{}|{}|{}|{}|{}|{}|{}\n'.format(utt, spk, language, norm_text, ' '.join(phones),
" ".join([str(i) for i in tones]), " ".join([str(i) for i in tones]),
" ".join([str(i) for i in word2ph]))) " ".join([str(i) for i in word2ph])))
except: except Exception as error :
print("err!", utt) print("err!", utt, error)
if 2 in stage: if 2 in stage:
spk_utt_map = defaultdict(list) spk_utt_map = defaultdict(list)

View File

@@ -78,7 +78,8 @@ def run(rank, n_gpus, hps):
shuffle=True) shuffle=True)
collate_fn = TextAudioSpeakerCollate() collate_fn = TextAudioSpeakerCollate()
train_loader = DataLoader(train_dataset, num_workers=24, shuffle=False, pin_memory=True, train_loader = DataLoader(train_dataset, num_workers=24, shuffle=False, pin_memory=True,
collate_fn=collate_fn, batch_sampler=train_sampler, persistent_workers=True,prefetch_factor=4) collate_fn=collate_fn, batch_sampler=train_sampler,
persistent_workers=True,prefetch_factor=4) #256G Memory suitable loader.
if rank == 0: if rank == 0:
eval_dataset = TextAudioSpeakerLoader(hps.data.validation_files, hps.data) eval_dataset = TextAudioSpeakerLoader(hps.data.validation_files, hps.data)
eval_loader = DataLoader(eval_dataset, num_workers=0, shuffle=False, eval_loader = DataLoader(eval_dataset, num_workers=0, shuffle=False,
@@ -146,8 +147,8 @@ def run(rank, n_gpus, hps):
eps=hps.train.eps) eps=hps.train.eps)
else: else:
optim_dur_disc = None optim_dur_disc = None
net_g = DDP(net_g, device_ids=[rank],find_unused_parameters=True) net_g = DDP(net_g, device_ids=[rank], find_unused_parameters=True)
net_d = DDP(net_d, device_ids=[rank],find_unused_parameters=True) net_d = DDP(net_d, device_ids=[rank], find_unused_parameters=True)
if net_dur_disc is not None: if net_dur_disc is not None:
net_dur_disc = DDP(net_dur_disc, device_ids=[rank], find_unused_parameters=True) net_dur_disc = DDP(net_dur_disc, device_ids=[rank], find_unused_parameters=True)