diff --git a/README.md b/README.md index 2d2c104..2083ee4 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,6 @@ VITS2 Backbone with bert ## 成熟的旅行者/开拓者/舰长/博士/sensei/猎魔人/喵喵露/V应该参阅代码自己学习如何训练。 -### 严禁将此项目用于一切违反《中华人民共和国宪法》,《中华人民共和国刑法》,《中华人民共和国治安管理处罚法》和《中华人民共和国民法典》之用途。 \ No newline at end of file +### 严禁将此项目用于一切违反《中华人民共和国宪法》,《中华人民共和国刑法》,《中华人民共和国治安管理处罚法》和《中华人民共和国民法典》之用途。 +#### Video:https://www.bilibili.com/video/BV1hp4y1K78E +#### Demo:https://www.bilibili.com/video/BV1TF411k78w diff --git a/attentions.py b/attentions.py index ecbdbc8..b5f2fec 100644 --- a/attentions.py +++ b/attentions.py @@ -43,11 +43,11 @@ class Encoder(nn.Module): self.kernel_size = kernel_size self.p_dropout = p_dropout self.window_size = window_size - if isflow: - 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_layer = weight_norm(cond_layer, name='weight') - self.gin_channels = 256 + #if isflow: + # 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_layer = weight_norm(cond_layer, name='weight') + # self.gin_channels = 256 self.cond_layer_idx = self.n_layers if 'gin_channels' in kwargs: self.gin_channels = kwargs['gin_channels'] diff --git a/bert_gen.py b/bert_gen.py index d873223..4481471 100644 --- a/bert_gen.py +++ b/bert_gen.py @@ -1,11 +1,11 @@ import torch from torch.utils.data import DataLoader - +from multiprocessing import Pool import commons import utils from data_utils import TextAudioSpeakerLoader, TextAudioSpeakerCollate from tqdm import tqdm -from multiprocessing import Pool +import warnings from text import cleaned_text_to_sequence, get_bert @@ -40,14 +40,14 @@ def process_line(line): torch.save(bert, bert_path) -lines = [] -with open(hps.data.training_files) as f: - lines.extend(f.readlines()) +if __name__ == '__main__': + lines = [] + with open(hps.data.training_files, encoding='utf-8' ) as f: + lines.extend(f.readlines()) -with open(hps.data.validation_files) as f: - lines.extend(f.readlines()) + with open(hps.data.validation_files, encoding='utf-8' ) as f: + lines.extend(f.readlines()) - -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)): - pass + with Pool(processes=12) as pool: #A100 40GB suitable config,if coom,please decrease the processess number. + for _ in tqdm(pool.imap_unordered(process_line, lines)): + pass diff --git a/models.py b/models.py index 9951bf6..5248dcc 100644 --- a/models.py +++ b/models.py @@ -15,8 +15,6 @@ from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm from commons import init_weights, get_padding from text import symbols, num_tones, num_languages 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): super().__init__() @@ -34,11 +32,11 @@ class DurationDiscriminator(nn.Module): #vits2 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_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_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.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): x = torch.detach(x) - # if g is not None: + #if g is not None: # g = torch.detach(g) # x = x + self.cond(g) x = self.conv_1(x * x_mask) diff --git a/preprocess_text.py b/preprocess_text.py index ca3a934..d517548 100644 --- a/preprocess_text.py +++ b/preprocess_text.py @@ -23,8 +23,8 @@ if 1 in stage: f.write('{}|{}|{}|{}|{}|{}|{}\n'.format(utt, spk, language, norm_text, ' '.join(phones), " ".join([str(i) for i in tones]), " ".join([str(i) for i in word2ph]))) - except: - print("err!", utt) + except Exception as error : + print("err!", utt, error) if 2 in stage: spk_utt_map = defaultdict(list) diff --git a/train_ms.py b/train_ms.py index 93846c2..55f2bb5 100644 --- a/train_ms.py +++ b/train_ms.py @@ -78,7 +78,8 @@ def run(rank, n_gpus, hps): shuffle=True) collate_fn = TextAudioSpeakerCollate() 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: eval_dataset = TextAudioSpeakerLoader(hps.data.validation_files, hps.data) eval_loader = DataLoader(eval_dataset, num_workers=0, shuffle=False, @@ -146,8 +147,8 @@ def run(rank, n_gpus, hps): eps=hps.train.eps) else: optim_dur_disc = None - 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_g = DDP(net_g, 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: net_dur_disc = DDP(net_dur_disc, device_ids=[rank], find_unused_parameters=True)