* Fix inputs of duration discriminator * Add LSTM * Update models.py * Update tensorboard scalar * Noise injection for minimizing modality gap * Update infer.py * support bf16 run * del unused_para flag * support bf16 config * add grad clip * fix(logger and grad):add dur grad,fix grad clip * Update webui_preprocess.py * Fix English G2P * fix(bert_gen):add pass * Pass SDP to DD * Update webui_preprocess.py * Update config.json * Update webui.py * Update chinese_bert.py * Upload webui for deploy * Update webui.py * torch.save as pt not npy * Update config.json * add freeze emo vq * Update webui_preprocess.py * Fix tone_sandhi.py * Comment up grad clip * Fix in-place addition * Add SLM discriminator * Add DDP for WD * Feat: Style text: make emotions and style similar to the style text by mixing bert (#240) (#241) * fix:(oldVersion210) Load on demand Emotion model * feat: update fastapi.py. 添加更多错误日志信息 * Switch pyopenjtalk to pyopenjtalk-prebuilt * fix: update fastapi.py. 2.2 reference适配 * Update resample.py * 修复Onnx导出的BUG (#237) * Add files via upload * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add files via upload * Add files via upload * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Delete attentions_onnx.py * Delete models_onnx.py * Add files via upload * Add files via upload * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update __init__.py * Update __init__.py * Update __init__.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- * Fix onnx * Format export * Feat: style-text and bert mixing (JA only) * Ensure the same tensor shape * Update * update gradio version * Fix * Style text for chinese and english (ver 2.2) * Style text for chinese and english (ver 2.1) * Style text in FastAPI * Translate style text desc in chinese --------- Co-authored-by: litagin02 <139731664+litagin02@users.noreply.github.com> Co-authored-by: Sora <654163754@qq.com> Co-authored-by: Sihan Wang <wangsihan1995@gmail.com> Co-authored-by: Ναρουσέ·μ·γιουμεμί·Χινακάννα <40709280+NaruseMioShirakana@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Remove CLAP * Revert "Remove CLAP" This reverts commit 62fd59bc837c580239840a2bc84b15e0663730fc. Revert * Remove CLAP * bf16 audo grad cilp * Update webui and infer utils * Update webui.py * Update webui.py * Update webui-preprocess.py * Update webui_preprocess.py --------- Co-authored-by: Sihan Wang <wangsihan1995@gmail.com> Co-authored-by: OedoSoldier <31711261+OedoSoldier@users.noreply.github.com> Co-authored-by: litagin02 <139731664+litagin02@users.noreply.github.com> Co-authored-by: Sora <654163754@qq.com> Co-authored-by: Ναρουσέ·μ·γιουμεμί·Χινακάννα <40709280+NaruseMioShirakana@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
82 lines
2.7 KiB
Python
82 lines
2.7 KiB
Python
import torch
|
|
from multiprocessing import Pool
|
|
import commons
|
|
import utils
|
|
from tqdm import tqdm
|
|
from text import check_bert_models, cleaned_text_to_sequence, get_bert
|
|
import argparse
|
|
import torch.multiprocessing as mp
|
|
from config import config
|
|
|
|
|
|
def process_line(x):
|
|
line, add_blank = x
|
|
device = config.bert_gen_config.device
|
|
if config.bert_gen_config.use_multi_device:
|
|
rank = mp.current_process()._identity
|
|
rank = rank[0] if len(rank) > 0 else 0
|
|
if torch.cuda.is_available():
|
|
gpu_id = rank % torch.cuda.device_count()
|
|
device = torch.device(f"cuda:{gpu_id}")
|
|
else:
|
|
device = torch.device("cpu")
|
|
wav_path, _, language_str, text, phones, tone, word2ph = line.strip().split("|")
|
|
phone = phones.split(" ")
|
|
tone = [int(i) for i in tone.split(" ")]
|
|
word2ph = [int(i) for i in word2ph.split(" ")]
|
|
word2ph = [i for i in word2ph]
|
|
phone, tone, language = cleaned_text_to_sequence(phone, tone, language_str)
|
|
|
|
if add_blank:
|
|
phone = commons.intersperse(phone, 0)
|
|
tone = commons.intersperse(tone, 0)
|
|
language = commons.intersperse(language, 0)
|
|
for i in range(len(word2ph)):
|
|
word2ph[i] = word2ph[i] * 2
|
|
word2ph[0] += 1
|
|
|
|
bert_path = wav_path.replace(".WAV", ".wav").replace(".wav", ".bert.pt")
|
|
|
|
try:
|
|
bert = torch.load(bert_path)
|
|
assert bert.shape[-1] == len(phone)
|
|
except Exception:
|
|
bert = get_bert(text, word2ph, language_str, device)
|
|
assert bert.shape[-1] == len(phone)
|
|
torch.save(bert, bert_path)
|
|
|
|
|
|
preprocess_text_config = config.preprocess_text_config
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
"-c", "--config", type=str, default=config.bert_gen_config.config_path
|
|
)
|
|
parser.add_argument(
|
|
"--num_processes", type=int, default=config.bert_gen_config.num_processes
|
|
)
|
|
args, _ = parser.parse_known_args()
|
|
config_path = args.config
|
|
hps = utils.get_hparams_from_file(config_path)
|
|
check_bert_models()
|
|
lines = []
|
|
with open(hps.data.training_files, encoding="utf-8") as f:
|
|
lines.extend(f.readlines())
|
|
|
|
with open(hps.data.validation_files, encoding="utf-8") as f:
|
|
lines.extend(f.readlines())
|
|
add_blank = [hps.data.add_blank] * len(lines)
|
|
|
|
if len(lines) != 0:
|
|
num_processes = args.num_processes
|
|
with Pool(processes=num_processes) as pool:
|
|
for _ in tqdm(
|
|
pool.imap_unordered(process_line, zip(lines, add_blank)),
|
|
total=len(lines),
|
|
):
|
|
# 这里是缩进的代码块,表示循环体
|
|
pass # 使用pass语句作为占位符
|
|
|
|
print(f"bert生成完毕!, 共有{len(lines)}个bert.pt生成!")
|