sync emo branch (#159)

* Update README.md

* 更新 bert_models.json

* fix

* Update data_utils.py

* Update infer.py

* performance improve

* Feat: support auto split in webui (#158)

* Feat: support auto split in webui

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

---------

Co-authored-by: Sora <atri@suzakuintsubaki.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Stardust·减
2023-11-08 17:09:15 +08:00
committed by GitHub
parent 9616b7b4b5
commit 33d153505a
7 changed files with 21 additions and 29 deletions

View File

@@ -1,7 +1,9 @@
# Bert-VITS2
VITS2 Backbone with bert
# 紧急通知
我们在2.0版本中发现了重大bug该bug导致日文和英文bert被置0后训练即失去bert效果。
我们将重炼2.0版本底模,已经开炉的建议关炉静候。
## 请注意,本项目核心思路来源于[anyvoiceai/MassTTS](https://github.com/anyvoiceai/MassTTS) 一个非常好的tts项目
## MassTTS的演示demo为[ai版峰哥锐评峰哥本人,并找回了在金三角失落的腰子](https://www.bilibili.com/video/BV1w24y1c7z9)

View File

@@ -1,7 +1,7 @@
{
"deberta-v2-large-japanese": {
"repo_id": "ku-nlp/deberta-v2-large-japanese",
"files": ["spm.model", "pytorch_model.bin"]
"files": ["pytorch_model.bin"]
},
"chinese-roberta-wwm-ext-large": {
"repo_id": "hfl/chinese-roberta-wwm-ext-large",

View File

@@ -145,38 +145,24 @@ class TextAudioSpeakerLoader(torch.utils.data.Dataset):
word2ph[0] += 1
bert_path = wav_path.replace(".wav", ".bert.pt")
try:
bert = torch.load(bert_path)
assert bert.shape[-1] == len(phone)
bert_ori = torch.load(bert_path)
assert bert_ori.shape[-1] == len(phone)
except Exception as e:
logger.warn("Bert load Failed")
logger.warn(e)
if language_str == "ZH":
bert = bert
bert = bert_ori
ja_bert = torch.zeros(1024, len(phone))
en_bert = torch.zeros(1024, len(phone))
elif language_str == "JP":
bert = torch.zeros(1024, len(phone))
ja_bert = bert
ja_bert = bert_ori
en_bert = torch.zeros(1024, len(phone))
elif language_str == "EN":
bert = torch.zeros(1024, len(phone))
ja_bert = torch.zeros(1024, len(phone))
en_bert = bert
assert bert.shape[-1] == len(phone), (
bert.shape,
len(phone),
sum(word2ph),
p1,
p2,
t1,
t2,
pold,
pold2,
word2ph,
text,
w2pho,
)
en_bert = bert_ori
phone = torch.LongTensor(phone)
tone = torch.LongTensor(tone)
language = torch.LongTensor(language)

View File

@@ -85,22 +85,22 @@ def get_text(text, language_str, hps, device):
for i in range(len(word2ph)):
word2ph[i] = word2ph[i] * 2
word2ph[0] += 1
bert = get_bert(norm_text, word2ph, language_str, device)
bert_ori = get_bert(norm_text, word2ph, language_str, device)
del word2ph
assert bert.shape[-1] == len(phone), phone
assert bert_ori.shape[-1] == len(phone), phone
if language_str == "ZH":
bert = bert
bert = bert_ori
ja_bert = torch.zeros(1024, len(phone))
en_bert = torch.zeros(1024, len(phone))
elif language_str == "JP":
bert = torch.zeros(1024, len(phone))
ja_bert = bert
ja_bert = bert_ori
en_bert = torch.zeros(1024, len(phone))
elif language_str == "EN":
bert = torch.zeros(1024, len(phone))
ja_bert = torch.zeros(1024, len(phone))
en_bert = bert
en_bert = bert_ori
else:
raise ValueError("language_str should be ZH, JP or EN")

View File

@@ -5,6 +5,7 @@ import logging
import gc
import random
import gradio
import numpy as np
import utils
from fastapi import FastAPI, Query, Request
@@ -245,6 +246,7 @@ if __name__ == "__main__":
)
audios.append(np.zeros((int)(44100 * 0.3)))
audio = np.concatenate(audios)
audio = gradio.processing_utils.convert_to_16_bit_wav(audio)
wavContent = BytesIO()
wavfile.write(
wavContent, loaded_models.models[model_id].hps.data.sampling_rate, audio

View File

@@ -9,6 +9,8 @@ import sys
logger.remove()
# 自定义格式并添加到标准输出
log_format = "<g>{time:MM-DD HH:mm:ss}</g> [<lvl>{level}</lvl>] | {message}"
log_format = (
"<g>{time:MM-DD HH:mm:ss}</g> [<lvl>{level}</lvl>] | {file}:{line} | {message}"
)
logger.add(sys.stdout, format=log_format)

View File

@@ -206,8 +206,8 @@ def run():
)
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])
net_d = DDP(net_d, device_ids=[rank])
dur_resume_lr = None
if net_dur_disc is not None:
net_dur_disc = DDP(net_dur_disc, device_ids=[rank], find_unused_parameters=True)