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:
@@ -1,7 +1,9 @@
|
|||||||
# Bert-VITS2
|
# Bert-VITS2
|
||||||
|
|
||||||
VITS2 Backbone with bert
|
VITS2 Backbone with bert
|
||||||
|
# 紧急通知
|
||||||
|
我们在2.0版本中发现了重大bug,该bug导致日文和英文bert被置0后训练,即失去bert效果。
|
||||||
|
我们将重炼2.0版本底模,已经开炉的建议关炉静候。
|
||||||
## 请注意,本项目核心思路来源于[anyvoiceai/MassTTS](https://github.com/anyvoiceai/MassTTS) 一个非常好的tts项目
|
## 请注意,本项目核心思路来源于[anyvoiceai/MassTTS](https://github.com/anyvoiceai/MassTTS) 一个非常好的tts项目
|
||||||
## MassTTS的演示demo为[ai版峰哥锐评峰哥本人,并找回了在金三角失落的腰子](https://www.bilibili.com/video/BV1w24y1c7z9)
|
## MassTTS的演示demo为[ai版峰哥锐评峰哥本人,并找回了在金三角失落的腰子](https://www.bilibili.com/video/BV1w24y1c7z9)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"deberta-v2-large-japanese": {
|
"deberta-v2-large-japanese": {
|
||||||
"repo_id": "ku-nlp/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": {
|
"chinese-roberta-wwm-ext-large": {
|
||||||
"repo_id": "hfl/chinese-roberta-wwm-ext-large",
|
"repo_id": "hfl/chinese-roberta-wwm-ext-large",
|
||||||
|
|||||||
@@ -145,38 +145,24 @@ class TextAudioSpeakerLoader(torch.utils.data.Dataset):
|
|||||||
word2ph[0] += 1
|
word2ph[0] += 1
|
||||||
bert_path = wav_path.replace(".wav", ".bert.pt")
|
bert_path = wav_path.replace(".wav", ".bert.pt")
|
||||||
try:
|
try:
|
||||||
bert = torch.load(bert_path)
|
bert_ori = torch.load(bert_path)
|
||||||
assert bert.shape[-1] == len(phone)
|
assert bert_ori.shape[-1] == len(phone)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn("Bert load Failed")
|
logger.warn("Bert load Failed")
|
||||||
logger.warn(e)
|
logger.warn(e)
|
||||||
|
|
||||||
if language_str == "ZH":
|
if language_str == "ZH":
|
||||||
bert = bert
|
bert = bert_ori
|
||||||
ja_bert = torch.zeros(1024, len(phone))
|
ja_bert = torch.zeros(1024, len(phone))
|
||||||
en_bert = torch.zeros(1024, len(phone))
|
en_bert = torch.zeros(1024, len(phone))
|
||||||
elif language_str == "JP":
|
elif language_str == "JP":
|
||||||
bert = torch.zeros(1024, len(phone))
|
bert = torch.zeros(1024, len(phone))
|
||||||
ja_bert = bert
|
ja_bert = bert_ori
|
||||||
en_bert = torch.zeros(1024, len(phone))
|
en_bert = torch.zeros(1024, len(phone))
|
||||||
elif language_str == "EN":
|
elif language_str == "EN":
|
||||||
bert = torch.zeros(1024, len(phone))
|
bert = torch.zeros(1024, len(phone))
|
||||||
ja_bert = torch.zeros(1024, len(phone))
|
ja_bert = torch.zeros(1024, len(phone))
|
||||||
en_bert = bert
|
en_bert = bert_ori
|
||||||
assert bert.shape[-1] == len(phone), (
|
|
||||||
bert.shape,
|
|
||||||
len(phone),
|
|
||||||
sum(word2ph),
|
|
||||||
p1,
|
|
||||||
p2,
|
|
||||||
t1,
|
|
||||||
t2,
|
|
||||||
pold,
|
|
||||||
pold2,
|
|
||||||
word2ph,
|
|
||||||
text,
|
|
||||||
w2pho,
|
|
||||||
)
|
|
||||||
phone = torch.LongTensor(phone)
|
phone = torch.LongTensor(phone)
|
||||||
tone = torch.LongTensor(tone)
|
tone = torch.LongTensor(tone)
|
||||||
language = torch.LongTensor(language)
|
language = torch.LongTensor(language)
|
||||||
|
|||||||
10
infer.py
10
infer.py
@@ -85,22 +85,22 @@ def get_text(text, language_str, hps, device):
|
|||||||
for i in range(len(word2ph)):
|
for i in range(len(word2ph)):
|
||||||
word2ph[i] = word2ph[i] * 2
|
word2ph[i] = word2ph[i] * 2
|
||||||
word2ph[0] += 1
|
word2ph[0] += 1
|
||||||
bert = get_bert(norm_text, word2ph, language_str, device)
|
bert_ori = get_bert(norm_text, word2ph, language_str, device)
|
||||||
del word2ph
|
del word2ph
|
||||||
assert bert.shape[-1] == len(phone), phone
|
assert bert_ori.shape[-1] == len(phone), phone
|
||||||
|
|
||||||
if language_str == "ZH":
|
if language_str == "ZH":
|
||||||
bert = bert
|
bert = bert_ori
|
||||||
ja_bert = torch.zeros(1024, len(phone))
|
ja_bert = torch.zeros(1024, len(phone))
|
||||||
en_bert = torch.zeros(1024, len(phone))
|
en_bert = torch.zeros(1024, len(phone))
|
||||||
elif language_str == "JP":
|
elif language_str == "JP":
|
||||||
bert = torch.zeros(1024, len(phone))
|
bert = torch.zeros(1024, len(phone))
|
||||||
ja_bert = bert
|
ja_bert = bert_ori
|
||||||
en_bert = torch.zeros(1024, len(phone))
|
en_bert = torch.zeros(1024, len(phone))
|
||||||
elif language_str == "EN":
|
elif language_str == "EN":
|
||||||
bert = torch.zeros(1024, len(phone))
|
bert = torch.zeros(1024, len(phone))
|
||||||
ja_bert = torch.zeros(1024, len(phone))
|
ja_bert = torch.zeros(1024, len(phone))
|
||||||
en_bert = bert
|
en_bert = bert_ori
|
||||||
else:
|
else:
|
||||||
raise ValueError("language_str should be ZH, JP or EN")
|
raise ValueError("language_str should be ZH, JP or EN")
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import logging
|
|||||||
import gc
|
import gc
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
import gradio
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import utils
|
import utils
|
||||||
from fastapi import FastAPI, Query, Request
|
from fastapi import FastAPI, Query, Request
|
||||||
@@ -245,6 +246,7 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
audios.append(np.zeros((int)(44100 * 0.3)))
|
audios.append(np.zeros((int)(44100 * 0.3)))
|
||||||
audio = np.concatenate(audios)
|
audio = np.concatenate(audios)
|
||||||
|
audio = gradio.processing_utils.convert_to_16_bit_wav(audio)
|
||||||
wavContent = BytesIO()
|
wavContent = BytesIO()
|
||||||
wavfile.write(
|
wavfile.write(
|
||||||
wavContent, loaded_models.models[model_id].hps.data.sampling_rate, audio
|
wavContent, loaded_models.models[model_id].hps.data.sampling_rate, audio
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import sys
|
|||||||
logger.remove()
|
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)
|
logger.add(sys.stdout, format=log_format)
|
||||||
|
|||||||
@@ -206,8 +206,8 @@ def run():
|
|||||||
)
|
)
|
||||||
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])
|
||||||
net_d = DDP(net_d, device_ids=[rank], find_unused_parameters=True)
|
net_d = DDP(net_d, device_ids=[rank])
|
||||||
dur_resume_lr = None
|
dur_resume_lr = None
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user