Merge remote-tracking branch 'upstream/main' into chores

This commit is contained in:
XXXXRT666 2024-08-06 16:26:11 +08:00
commit 0508efbc4c
17 changed files with 45275 additions and 77 deletions

View File

@ -311,14 +311,14 @@ def get_phones_and_bert(text,language,version):
if language == "zh": if language == "zh":
if re.search(r'[A-Za-z]', formattext): if re.search(r'[A-Za-z]', formattext):
formattext = re.sub(r'[a-z]', lambda x: x.group(0).upper(), formattext) formattext = re.sub(r'[a-z]', lambda x: x.group(0).upper(), formattext)
formattext = chinese.text_normalize(formattext) formattext = chinese.mix_text_normalize(formattext)
return get_phones_and_bert(formattext,"zh",version) return get_phones_and_bert(formattext,"zh",version)
else: else:
phones, word2ph, norm_text = clean_text_inf(formattext, language, version) phones, word2ph, norm_text = clean_text_inf(formattext, language, version)
bert = get_bert_feature(norm_text, word2ph).to(device) bert = get_bert_feature(norm_text, word2ph).to(device)
elif language == "yue" and re.search(r'[A-Za-z]', formattext): elif language == "yue" and re.search(r'[A-Za-z]', formattext):
formattext = re.sub(r'[a-z]', lambda x: x.group(0).upper(), formattext) formattext = re.sub(r'[a-z]', lambda x: x.group(0).upper(), formattext)
formattext = chinese.text_normalize(formattext) formattext = chinese.mix_text_normalize(formattext)
return get_phones_and_bert(formattext,"yue",version) return get_phones_and_bert(formattext,"yue",version)
else: else:
phones, word2ph, norm_text = clean_text_inf(formattext, language, version) phones, word2ph, norm_text = clean_text_inf(formattext, language, version)

View File

@ -1,5 +1,6 @@
import warnings
warnings.filterwarnings("ignore")
import utils, os import utils, os
hps = utils.get_hparams(stage=2) hps = utils.get_hparams(stage=2)
os.environ["CUDA_VISIBLE_DEVICES"] = hps.train.gpu_numbers.replace("-", ",") os.environ["CUDA_VISIBLE_DEVICES"] = hps.train.gpu_numbers.replace("-", ",")
import torch import torch
@ -119,7 +120,7 @@ def run(rank, n_gpus, hps):
collate_fn=collate_fn, collate_fn=collate_fn,
batch_sampler=train_sampler, batch_sampler=train_sampler,
persistent_workers=True, persistent_workers=True,
prefetch_factor=16, prefetch_factor=4,
) )
# if rank == 0: # if rank == 0:
# eval_dataset = TextAudioSpeakerLoader(hps.data.validation_files, hps.data, val=True) # eval_dataset = TextAudioSpeakerLoader(hps.data.validation_files, hps.data, val=True)
@ -211,7 +212,7 @@ def run(rank, n_gpus, hps):
# traceback.print_exc() # traceback.print_exc()
epoch_str = 1 epoch_str = 1
global_step = 0 global_step = 0
if hps.train.pretrained_s2G != "": if hps.train.pretrained_s2G != ""and hps.train.pretrained_s2G != None and os.path.exists(hps.train.pretrained_s2G):
if rank == 0: if rank == 0:
logger.info("loaded pretrained %s" % hps.train.pretrained_s2G) logger.info("loaded pretrained %s" % hps.train.pretrained_s2G)
print( print(
@ -223,7 +224,7 @@ def run(rank, n_gpus, hps):
strict=False, strict=False,
) )
) ##测试不加载优化器 ) ##测试不加载优化器
if hps.train.pretrained_s2D != "": if hps.train.pretrained_s2D != ""and hps.train.pretrained_s2D != None and os.path.exists(hps.train.pretrained_s2D):
if rank == 0: if rank == 0:
logger.info("loaded pretrained %s" % hps.train.pretrained_s2D) logger.info("loaded pretrained %s" % hps.train.pretrained_s2D)
print( print(

View File

@ -1,6 +1,6 @@
# reference: https://huggingface.co/spaces/Naozumi0512/Bert-VITS2-Cantonese-Yue/blob/main/text/chinese.py
import sys import sys
# sys.path.append("/data/docker/liujing04/gpt-vits/mq-vits-s1bert_no_bert-kv_cache-new_text-emo")
sys.path.append("/data/docker/liujing04/gpt-vits/mq-vits-s1bert_no_bert-kv_cache-new_text-emo2v2")
import re import re
import cn2an import cn2an

View File

@ -47,6 +47,19 @@ def replace_punctuation(text):
replaced_text = pattern.sub(lambda x: rep_map[x.group()], text) replaced_text = pattern.sub(lambda x: rep_map[x.group()], text)
replaced_text = re.sub(
r"[^\u4e00-\u9fa5" + "".join(punctuation) + r"]+", "", replaced_text
)
return replaced_text
def replace_punctuation_with_en(text):
text = text.replace("", "").replace("", "")
pattern = re.compile("|".join(re.escape(p) for p in rep_map.keys()))
replaced_text = pattern.sub(lambda x: rep_map[x.group()], text)
replaced_text = re.sub( replaced_text = re.sub(
r"[^\u4e00-\u9fa5A-Za-z" + "".join(punctuation) + r"]+", "", replaced_text r"[^\u4e00-\u9fa5A-Za-z" + "".join(punctuation) + r"]+", "", replaced_text
) )
@ -171,6 +184,20 @@ def text_normalize(text):
return dest_text return dest_text
# 不排除英文的文本格式化
def mix_text_normalize(text):
# https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/paddlespeech/t2s/frontend/zh_normalization
tx = TextNormalizer()
sentences = tx.normalize(text)
dest_text = ""
for sentence in sentences:
dest_text += replace_punctuation_with_en(sentence)
# 避免重复标点引起的参考泄露
dest_text = replace_consecutive_punctuation(dest_text)
return dest_text
if __name__ == "__main__": if __name__ == "__main__":
text = "啊——但是《原神》是由,米哈\游自主,研发的一款全.新开放世界.冒险游戏" text = "啊——但是《原神》是由,米哈\游自主,研发的一款全.新开放世界.冒险游戏"
text = "呣呣呣~就是…大人的鼹鼠党吧?" text = "呣呣呣~就是…大人的鼹鼠党吧?"

View File

@ -4,6 +4,7 @@ import re
import cn2an import cn2an
from pypinyin import lazy_pinyin, Style from pypinyin import lazy_pinyin, Style
from pypinyin.contrib.tone_convert import to_normal, to_finals_tone3, to_initials, to_finals
from text.symbols import punctuation from text.symbols import punctuation
from text.tone_sandhi import ToneSandhi from text.tone_sandhi import ToneSandhi
@ -24,7 +25,7 @@ import jieba_fast.posseg as psg
is_g2pw = True#True if is_g2pw_str.lower() == 'true' else False is_g2pw = True#True if is_g2pw_str.lower() == 'true' else False
if is_g2pw: if is_g2pw:
print("当前使用g2pw进行拼音推理") print("当前使用g2pw进行拼音推理")
from text.g2pw import G2PWPinyin from text.g2pw import G2PWPinyin, correct_pronunciation
parent_directory = os.path.dirname(current_file_path) parent_directory = os.path.dirname(current_file_path)
g2pw = G2PWPinyin(model_dir="GPT_SoVITS/text/G2PWModel",model_source="GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large",v_to_u=False, neutral_tone_with_five=True) g2pw = G2PWPinyin(model_dir="GPT_SoVITS/text/G2PWModel",model_source="GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large",v_to_u=False, neutral_tone_with_five=True)
@ -42,6 +43,8 @@ rep_map = {
"$": ".", "$": ".",
"/": ",", "/": ",",
"": "-", "": "-",
"~": "",
"":"",
} }
tone_modifier = ToneSandhi() tone_modifier = ToneSandhi()
@ -71,16 +74,10 @@ def _get_initials_finals(word):
initials = [] initials = []
finals = [] finals = []
if not is_g2pw: orig_initials = lazy_pinyin(word, neutral_tone_with_five=True, style=Style.INITIALS)
orig_initials = lazy_pinyin(word, neutral_tone_with_five=True, style=Style.INITIALS) orig_finals = lazy_pinyin(
orig_finals = lazy_pinyin( word, neutral_tone_with_five=True, style=Style.FINALS_TONE3
word, neutral_tone_with_five=True, style=Style.FINALS_TONE3 )
)
else:
orig_initials = g2pw.lazy_pinyin(word, neutral_tone_with_five=True, style=Style.INITIALS)
orig_finals = g2pw.lazy_pinyin(
word, neutral_tone_with_five=True, style=Style.FINALS_TONE3
)
for c, v in zip(orig_initials, orig_finals): for c, v in zip(orig_initials, orig_finals):
initials.append(c) initials.append(c)
@ -88,6 +85,54 @@ def _get_initials_finals(word):
return initials, finals return initials, finals
must_erhua = {
"小院儿", "胡同儿", "范儿", "老汉儿", "撒欢儿", "寻老礼儿", "妥妥儿", "媳妇儿"
}
not_erhua = {
"虐儿", "为儿", "护儿", "瞒儿", "救儿", "替儿", "有儿", "一儿", "我儿", "俺儿", "妻儿",
"拐儿", "聋儿", "乞儿", "患儿", "幼儿", "孤儿", "婴儿", "婴幼儿", "连体儿", "脑瘫儿",
"流浪儿", "体弱儿", "混血儿", "蜜雪儿", "舫儿", "祖儿", "美儿", "应采儿", "可儿", "侄儿",
"孙儿", "侄孙儿", "女儿", "男儿", "红孩儿", "花儿", "虫儿", "马儿", "鸟儿", "猪儿", "猫儿",
"狗儿", "少儿"
}
def _merge_erhua(initials: list[str],
finals: list[str],
word: str,
pos: str) -> list[list[str]]:
"""
Do erhub.
"""
# fix er1
for i, phn in enumerate(finals):
if i == len(finals) - 1 and word[i] == "" and phn == 'er1':
finals[i] = 'er2'
# 发音
if word not in must_erhua and (word in not_erhua or
pos in {"a", "j", "nr"}):
return initials, finals
# "……" 等情况直接返回
if len(finals) != len(word):
return initials, finals
assert len(finals) == len(word)
# 与前一个字发同音
new_initials = []
new_finals = []
for i, phn in enumerate(finals):
if i == len(finals) - 1 and word[i] == "" and phn in {
"er2", "er5"
} and word[-2:] not in not_erhua and new_finals:
phn = "er" + new_finals[-1][-1]
new_initials.append(initials[i])
new_finals.append(phn)
return new_initials, new_finals
def _g2p(segments): def _g2p(segments):
phones_list = [] phones_list = []
word2ph = [] word2ph = []
@ -96,20 +141,62 @@ def _g2p(segments):
# Replace all English words in the sentence # Replace all English words in the sentence
seg = re.sub("[a-zA-Z]+", "", seg) seg = re.sub("[a-zA-Z]+", "", seg)
seg_cut = psg.lcut(seg) seg_cut = psg.lcut(seg)
seg_cut = tone_modifier.pre_merge_for_modify(seg_cut)
initials = [] initials = []
finals = [] finals = []
seg_cut = tone_modifier.pre_merge_for_modify(seg_cut)
for word, pos in seg_cut: if not is_g2pw:
if pos == "eng": for word, pos in seg_cut:
continue if pos == "eng":
sub_initials, sub_finals = _get_initials_finals(word) continue
sub_finals = tone_modifier.modified_tone(word, pos, sub_finals) sub_initials, sub_finals = _get_initials_finals(word)
initials.append(sub_initials) sub_finals = tone_modifier.modified_tone(word, pos, sub_finals)
finals.append(sub_finals) # 儿化
# assert len(sub_initials) == len(sub_finals) == len(word) sub_initials, sub_finals = _merge_erhua(sub_initials, sub_finals, word, pos)
initials = sum(initials, []) initials.append(sub_initials)
finals = sum(finals, []) finals.append(sub_finals)
# # assert len(sub_initials) == len(sub_finals) == len(word)
initials = sum(initials, [])
finals = sum(finals, [])
print("pypinyin结果",initials,finals)
else:
# g2pw采用整句推理
pinyins = g2pw.lazy_pinyin(seg, neutral_tone_with_five=True, style=Style.TONE3)
pre_word_length = 0
for word, pos in seg_cut:
sub_initials = []
sub_finals = []
now_word_length = pre_word_length + len(word)
if pos == 'eng':
pre_word_length = now_word_length
continue
word_pinyins = pinyins[pre_word_length:now_word_length]
# 多音字消歧
word_pinyins = correct_pronunciation(word,word_pinyins)
for pinyin in word_pinyins:
if pinyin[0].isalpha():
sub_initials.append(to_initials(pinyin))
sub_finals.append(to_finals_tone3(pinyin,neutral_tone_with_five=True))
else:
sub_initials.append(pinyin)
sub_finals.append(pinyin)
pre_word_length = now_word_length
sub_finals = tone_modifier.modified_tone(word, pos, sub_finals)
# 儿化
sub_initials, sub_finals = _merge_erhua(sub_initials, sub_finals, word, pos)
initials.append(sub_initials)
finals.append(sub_finals)
initials = sum(initials, [])
finals = sum(finals, [])
# print("g2pw结果",initials,finals)
for c, v in zip(initials, finals): for c, v in zip(initials, finals):
raw_pinyin = c + v raw_pinyin = c + v
# NOTE: post process for pypinyin outputs # NOTE: post process for pypinyin outputs
@ -164,6 +251,24 @@ def _g2p(segments):
return phones_list, word2ph return phones_list, word2ph
def replace_punctuation_with_en(text):
text = text.replace("", "").replace("", "")
pattern = re.compile("|".join(re.escape(p) for p in rep_map.keys()))
replaced_text = pattern.sub(lambda x: rep_map[x.group()], text)
replaced_text = re.sub(
r"[^\u4e00-\u9fa5A-Za-z" + "".join(punctuation) + r"]+", "", replaced_text
)
return replaced_text
def replace_consecutive_punctuation(text):
punctuations = ''.join(re.escape(p) for p in punctuation)
pattern = f'([{punctuations}])([{punctuations}])+'
result = re.sub(pattern, r'\1', text)
return result
def text_normalize(text): def text_normalize(text):
# https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/paddlespeech/t2s/frontend/zh_normalization # https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/paddlespeech/t2s/frontend/zh_normalization
tx = TextNormalizer() tx = TextNormalizer()
@ -171,6 +276,22 @@ def text_normalize(text):
dest_text = "" dest_text = ""
for sentence in sentences: for sentence in sentences:
dest_text += replace_punctuation(sentence) dest_text += replace_punctuation(sentence)
# 避免重复标点引起的参考泄露
dest_text = replace_consecutive_punctuation(dest_text)
return dest_text
# 不排除英文的文本格式化
def mix_text_normalize(text):
# https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/paddlespeech/t2s/frontend/zh_normalization
tx = TextNormalizer()
sentences = tx.normalize(text)
dest_text = ""
for sentence in sentences:
dest_text += replace_punctuation_with_en(sentence)
# 避免重复标点引起的参考泄露
dest_text = replace_consecutive_punctuation(dest_text)
return dest_text return dest_text

View File

@ -1 +1 @@
from text.g2pw.g2pw import * from text.g2pw.g2pw import *

View File

@ -13,6 +13,7 @@ from .onnx_api import G2PWOnnxConverter
current_file_path = os.path.dirname(__file__) current_file_path = os.path.dirname(__file__)
CACHE_PATH = os.path.join(current_file_path, "polyphonic.pickle") CACHE_PATH = os.path.join(current_file_path, "polyphonic.pickle")
PP_DICT_PATH = os.path.join(current_file_path, "polyphonic.rep") PP_DICT_PATH = os.path.join(current_file_path, "polyphonic.rep")
PP_FIX_DICT_PATH = os.path.join(current_file_path, "polyphonic-fix.rep")
class G2PWPinyin(Pinyin): class G2PWPinyin(Pinyin):
@ -69,12 +70,6 @@ class Converter(UltimateConverter):
def _to_pinyin(self, han, style, heteronym, errors, strict, **kwargs): def _to_pinyin(self, han, style, heteronym, errors, strict, **kwargs):
pinyins = [] pinyins = []
if han in pp_dict:
phns = pp_dict[han]
for ph in phns:
pinyins.append([ph])
return pinyins
g2pw_pinyin = self._g2pw(han) g2pw_pinyin = self._g2pw(han)
if not g2pw_pinyin: # g2pw 不支持的汉字改为使用 pypinyin 原有逻辑 if not g2pw_pinyin: # g2pw 不支持的汉字改为使用 pypinyin 原有逻辑
@ -139,7 +134,21 @@ def read_dict():
value = eval(value_str.strip()) value = eval(value_str.strip())
polyphonic_dict[key.strip()] = value polyphonic_dict[key.strip()] = value
line = f.readline() line = f.readline()
with open(PP_FIX_DICT_PATH) as f:
line = f.readline()
while line:
key, value_str = line.split(':')
value = eval(value_str.strip())
polyphonic_dict[key.strip()] = value
line = f.readline()
return polyphonic_dict return polyphonic_dict
def correct_pronunciation(word,word_pinyins):
if word in pp_dict:
word_pinyins = pp_dict[word]
return word_pinyins
pp_dict = get_dict() pp_dict = get_dict()

View File

@ -1,6 +1,8 @@
# This code is modified from https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/paddlespeech/t2s/frontend/g2pw # This code is modified from https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/paddlespeech/t2s/frontend/g2pw
# This code is modified from https://github.com/GitYCC/g2pW # This code is modified from https://github.com/GitYCC/g2pW
import warnings
warnings.filterwarnings("ignore")
import json import json
import os import os
import zipfile,requests import zipfile,requests

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
# reference: https://github.com/ORI-Muchim/MB-iSTFT-VITS-Korean/blob/main/text/korean.py
import re import re
from jamo import h2j, j2hcj from jamo import h2j, j2hcj
import ko_pron import ko_pron
@ -260,4 +262,4 @@ def g2p(text):
text = re.sub(r'([\u3131-\u3163])$', r'\1.', text) text = re.sub(r'([\u3131-\u3163])$', r'\1.', text)
# text = "".join([post_replace_ph(i) for i in text]) # text = "".join([post_replace_ph(i) for i in text])
text = [post_replace_ph(i) for i in text] text = [post_replace_ph(i) for i in text]
return text return text

View File

@ -28,7 +28,7 @@ UNITS = OrderedDict({
8: '亿', 8: '亿',
}) })
COM_QUANTIFIERS = '(封|艘|把|目|套|段|人|所|朵|匹|张|座|回|场|尾|条|个|首|阙|阵|网|炮|顶|丘|棵|只|支|袭|辆|挑|担|颗|壳|窠|曲|墙|群|腔|砣|座|客|贯|扎|捆|刀|令|打|手|罗|坡|山|岭|江|溪|钟|队|单|双|对|出|口|头|脚|板|跳|枝|件|贴|针|线|管|名|位|身|堂|课|本|页|家|户|层|丝|毫|厘|分|钱|两|斤|担|铢|石|钧|锱|忽|(千|毫|微)克|毫|厘|(公)分|分|寸|尺|丈|里|寻|常|铺|程|(千|分|厘|毫|微)米|米|撮|勺|合|升|斗|石|盘|碗|碟|叠|桶|笼|盆|盒|杯|钟|斛|锅|簋|篮|盘|桶|罐|瓶|壶|卮|盏|箩|箱|煲|啖|袋|钵|年|月|日|季|刻|时|周|天|秒|分|小时|旬|纪|岁|世|更|夜|春|夏|秋|冬|代|伏|辈|丸|泡|粒|颗|幢|堆|条|根|支|道|面|片|张|颗|块|元|(亿|千万|百万|万|千|百)|(亿|千万|百万|万|千|百|美|)元|(亿|千万|百万|万|千|百|十|)吨|(亿|千万|百万|万|千|百|)块|角|毛|分)' COM_QUANTIFIERS = '(处|台|架|枚|趟|幅|平|方|堵|间|床|株|批|项|例|列|篇|栋|注|亩|封|艘|把|目|套|段|人|所|朵|匹|张|座|回|场|尾|条|个|首|阙|阵|网|炮|顶|丘|棵|只|支|袭|辆|挑|担|颗|壳|窠|曲|墙|群|腔|砣|座|客|贯|扎|捆|刀|令|打|手|罗|坡|山|岭|江|溪|钟|队|单|双|对|出|口|头|脚|板|跳|枝|件|贴|针|线|管|名|位|身|堂|课|本|页|家|户|层|丝|毫|厘|分|钱|两|斤|担|铢|石|钧|锱|忽|(千|毫|微)克|毫|厘|(公)分|分|寸|尺|丈|里|寻|常|铺|程|(千|分|厘|毫|微)米|米|撮|勺|合|升|斗|石|盘|碗|碟|叠|桶|笼|盆|盒|杯|钟|斛|锅|簋|篮|盘|桶|罐|瓶|壶|卮|盏|箩|箱|煲|啖|袋|钵|年|月|日|季|刻|时|周|天|秒|分|小时|旬|纪|岁|世|更|夜|春|夏|秋|冬|代|伏|辈|丸|泡|粒|颗|幢|堆|条|根|支|道|面|片|张|颗|块|元|(亿|千万|百万|万|千|百)|(亿|千万|百万|万|千|百|美|)元|(亿|千万|百万|万|千|百|十|)吨|(亿|千万|百万|万|千|百|)块|角|毛|分)'
# 分数表达式 # 分数表达式
RE_FRAC = re.compile(r'(-?)(\d+)/(\d+)') RE_FRAC = re.compile(r'(-?)(\d+)/(\d+)')

View File

@ -213,16 +213,24 @@
重点: 重点:
4-[支持合成语速调节。支持冻结随机性只调节语速](https://github.com/RVC-Boss/GPT-SoVITS/commit/9588a3c52d9ebdb20b3c5d74f647d12e7c1171c2) 4-[支持合成语速调节。支持冻结随机性只调节语速](https://github.com/RVC-Boss/GPT-SoVITS/commit/9588a3c52d9ebdb20b3c5d74f647d12e7c1171c2)并将其更新到api.py上https://github.com/RVC-Boss/GPT-SoVITS/pull/1340
todolist ### 20240806
1-中文多音字推理优化(有没有人来测试的欢迎把测试结果写在pr评论区里) https://github.com/RVC-Boss/GPT-SoVITS/pull/488 1-增加bs-roformer人声伴奏分离模型支持。 https://github.com/RVC-Boss/GPT-SoVITS/pull/1306 https://github.com/RVC-Boss/GPT-SoVITS/pull/1356 [支持fp16推理。](https://github.com/RVC-Boss/GPT-SoVITS/commit/e62e965323a60a76a025bcaa45268c1ddcbcf05c)
v2底模训练已经合了下个版本发布就要合了
2-正在尝试解决低音质参考音频导致音质较差的问题(202407:已经解决了)节点暂定8月吧
2-更好的中文文本前端。 https://github.com/RVC-Boss/GPT-SoVITS/pull/987 https://github.com/RVC-Boss/GPT-SoVITS/pull/1351 https://github.com/RVC-Boss/GPT-SoVITS/pull/1404 优化多音字逻辑v2版本特供。 https://github.com/RVC-Boss/GPT-SoVITS/pull/488
3-自动填充下一步的文件路径 https://github.com/RVC-Boss/GPT-SoVITS/pull/1356
4-增加喂饭逻辑,用户瞎写显卡序号也可以正常运作 [#bce451a](https://github.com/RVC-Boss/GPT-SoVITS/commit/bce451a2d1641e581e200297d01f219aeaaf7299) [4c8b761](https://github.com/RVC-Boss/GPT-SoVITS/commit/4c8b7612206536b8b4435997acb69b25d93acb78)
5-增加粤语ASR支持
6-GPT-SoVITS-v2支持
7-计时逻辑优化 https://github.com/RVC-Boss/GPT-SoVITS/pull/1387

2
go-webui-v1.bat Normal file
View File

@ -0,0 +1,2 @@
runtime\python.exe webui.py v1 zh_CN
pause

View File

@ -1,4 +1,4 @@
$ErrorActionPreference = "SilentlyContinue" $ErrorActionPreference = "SilentlyContinue"
chcp 65001 chcp 65001
& "$PSScriptRoot\runtime\python.exe" "$PSScriptRoot\webui.py v2 zh_CN" & "$PSScriptRoot\runtime\python.exe" "$PSScriptRoot\webui.py v1 zh_CN"
pause pause

View File

@ -1,2 +0,0 @@
runtime\python.exe webui.py v2 zh_CN
pause

View File

@ -1,15 +1,15 @@
import os,shutil,sys,pdb,re import os,sys
if len(sys.argv)==1:sys.argv.append('v2') if len(sys.argv)==1:sys.argv.append('v2')
version="v1"if sys.argv[1]=="v1" else"v2" version="v1"if sys.argv[1]=="v1" else"v2"
os.environ["version"]=version os.environ["version"]=version
now_dir = os.getcwd() now_dir = os.getcwd()
sys.path.insert(0, now_dir) sys.path.insert(0, now_dir)
import json,yaml,warnings,torch import warnings
warnings.filterwarnings("ignore")
import json,yaml,torch,pdb,re,shutil
import platform import platform
import psutil import psutil
import signal import signal
warnings.filterwarnings("ignore")
torch.manual_seed(233333) torch.manual_seed(233333)
tmp = os.path.join(now_dir, "TEMP") tmp = os.path.join(now_dir, "TEMP")
os.makedirs(tmp, exist_ok=True) os.makedirs(tmp, exist_ok=True)
@ -112,17 +112,6 @@ def fix_gpu_numbers(inputs):
except: except:
return inputs return inputs
def get_weights_names(GPT_weight_root, SoVITS_weight_root):
SoVITS_names = [i for i in pretrained_sovits_name]
for path in SoVITS_weight_root:
for name in os.listdir(path):
if name.endswith(".pth"): SoVITS_names.append("%s/%s" % (path, name))
GPT_names = [i for i in pretrained_gpt_name]
for path in GPT_weight_root:
for name in os.listdir(path):
if name.endswith(".ckpt"): GPT_names.append("%s/%s" % (path, name))
return SoVITS_names, GPT_names
pretrained_sovits_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth", "GPT_SoVITS/pretrained_models/s2G488k.pth"] pretrained_sovits_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth", "GPT_SoVITS/pretrained_models/s2G488k.pth"]
pretrained_gpt_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt", "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"] pretrained_gpt_name=["GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt", "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt"]
@ -132,19 +121,33 @@ _=''
for i in pretrained_model_list: for i in pretrained_model_list:
if os.path.exists(i):... if os.path.exists(i):...
else:_+=f'\n {i}' else:_+=f'\n {i}'
if _:raise FileExistsError(i18n('以下模型不存在:')+_) if _:
print("warning:",i18n('以下模型不存在:')+_)
_ =[[],[]] _ =[[],[]]
for i in range(2): for i in range(2):
if os.path.exists(pretrained_gpt_name[i]): if os.path.exists(pretrained_gpt_name[i]):_[0].append(pretrained_gpt_name[i])
_[0].append(pretrained_gpt_name[i]) else:_[0].append("")##没有下pretrained模型的说不定他们是想自己从零训底模呢
if os.path.exists(pretrained_sovits_name[i]): if os.path.exists(pretrained_sovits_name[i]):_[-1].append(pretrained_sovits_name[i])
_[-1].append(pretrained_sovits_name[i]) else:_[-1].append("")
pretrained_gpt_name,pretrained_sovits_name = _ pretrained_gpt_name,pretrained_sovits_name = _
SoVITS_weight_root=["SoVITS_weights_v2","SoVITS_weights"] SoVITS_weight_root=["SoVITS_weights_v2","SoVITS_weights"]
GPT_weight_root=["GPT_weights_v2","GPT_weights"] GPT_weight_root=["GPT_weights_v2","GPT_weights"]
SoVITS_names,GPT_names = get_weights_names(GPT_weight_root, SoVITS_weight_root) for root in SoVITS_weight_root+GPT_weight_root:
os.makedirs(root,exist_ok=True)
def get_weights_names():
SoVITS_names = [name for name in pretrained_sovits_name if name!=""]
for path in SoVITS_weight_root:
for name in os.listdir(path):
if name.endswith(".pth"): SoVITS_names.append("%s/%s" % (path, name))
GPT_names = [name for name in pretrained_gpt_name if name!=""]
for path in GPT_weight_root:
for name in os.listdir(path):
if name.endswith(".ckpt"): GPT_names.append("%s/%s" % (path, name))
return SoVITS_names, GPT_names
SoVITS_names,GPT_names = get_weights_names()
for path in SoVITS_weight_root+GPT_weight_root: for path in SoVITS_weight_root+GPT_weight_root:
os.makedirs(path,exist_ok=True) os.makedirs(path,exist_ok=True)
@ -315,8 +318,9 @@ def open1Ba(batch_size,total_epoch,exp_name,text_low_lr_rate,if_save_latest,if_s
data["train"]["if_save_every_weights"]=if_save_every_weights data["train"]["if_save_every_weights"]=if_save_every_weights
data["train"]["save_every_epoch"]=save_every_epoch data["train"]["save_every_epoch"]=save_every_epoch
data["train"]["gpu_numbers"]=gpu_numbers1Ba data["train"]["gpu_numbers"]=gpu_numbers1Ba
data["model"]["version"]=version
data["data"]["exp_dir"]=data["s2_ckpt_dir"]=s2_dir data["data"]["exp_dir"]=data["s2_ckpt_dir"]=s2_dir
data["save_weight_dir"]=SoVITS_weight_root data["save_weight_dir"]=SoVITS_weight_root[-int(version[-1])+2]
data["name"]=exp_name data["name"]=exp_name
data["version"]=version data["version"]=version
tmp_config_path="%s/tmp_s2.json"%tmp tmp_config_path="%s/tmp_s2.json"%tmp
@ -358,12 +362,12 @@ def open1Bb(batch_size,total_epoch,exp_name,if_dpo,if_save_latest,if_save_every_
data["train"]["if_save_every_weights"]=if_save_every_weights data["train"]["if_save_every_weights"]=if_save_every_weights
data["train"]["if_save_latest"]=if_save_latest data["train"]["if_save_latest"]=if_save_latest
data["train"]["if_dpo"]=if_dpo data["train"]["if_dpo"]=if_dpo
data["train"]["half_weights_save_dir"]=GPT_weight_root data["train"]["half_weights_save_dir"]=GPT_weight_root[-int(version[-1])+2]
data["train"]["exp_name"]=exp_name data["train"]["exp_name"]=exp_name
data["train_semantic_path"]="%s/6-name2semantic.tsv"%s1_dir data["train_semantic_path"]="%s/6-name2semantic.tsv"%s1_dir
data["train_phoneme_path"]="%s/2-name2text.txt"%s1_dir data["train_phoneme_path"]="%s/2-name2text.txt"%s1_dir
data["output_dir"]="%s/logs_s1"%s1_dir data["output_dir"]="%s/logs_s1"%s1_dir
data["version"]=version # data["version"]=version
os.environ["_CUDA_VISIBLE_DEVICES"]=fix_gpu_numbers(gpu_numbers.replace("-",",")) os.environ["_CUDA_VISIBLE_DEVICES"]=fix_gpu_numbers(gpu_numbers.replace("-",","))
os.environ["hz"]="25hz" os.environ["hz"]="25hz"
@ -866,10 +870,10 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
with gr.Row(): with gr.Row():
exp_name = gr.Textbox(label=i18n("*实验/模型名"), value="xxx", interactive=True) exp_name = gr.Textbox(label=i18n("*实验/模型名"), value="xxx", interactive=True)
gpu_info = gr.Textbox(label=i18n("显卡信息"), value=gpu_info, visible=True, interactive=False) gpu_info = gr.Textbox(label=i18n("显卡信息"), value=gpu_info, visible=True, interactive=False)
version_checkbox = gr.Radio(label=i18n("版本"),value='v2',choices=['v1','v2']) version_checkbox = gr.Radio(label=i18n("版本"),value=version,choices=['v1','v2'])
pretrained_s2G = gr.Textbox(label=i18n("预训练的SoVITS-G模型路径"), value=pretrained_sovits_name[0], interactive=True) pretrained_s2G = gr.Textbox(label=i18n("预训练的SoVITS-G模型路径"), value=pretrained_sovits_name[-int(version[-1])+2], interactive=True)
pretrained_s2D = gr.Textbox(label=i18n("预训练的SoVITS-D模型路径"), value=pretrained_sovits_name[0].replace("s2G","s2D"), interactive=True) pretrained_s2D = gr.Textbox(label=i18n("预训练的SoVITS-D模型路径"), value=pretrained_sovits_name[-int(version[-1])+2].replace("s2G","s2D"), interactive=True)
pretrained_s1 = gr.Textbox(label=i18n("预训练的GPT模型路径"), value=pretrained_gpt_name[0], interactive=True) pretrained_s1 = gr.Textbox(label=i18n("预训练的GPT模型路径"), value=pretrained_gpt_name[-int(version[-1])+2], interactive=True)
with gr.TabItem(i18n("1A-训练集格式化工具")): with gr.TabItem(i18n("1A-训练集格式化工具")):
gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹")) gr.Markdown(value=i18n("输出logs/实验名目录下应有23456开头的文件和文件夹"))
with gr.Row(): with gr.Row():