mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-04-06 03:57:44 +08:00
Merge branch 'main' into main
This commit is contained in:
commit
ff3b239fd9
@ -324,26 +324,28 @@ def get_first(text):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def get_cleaned_text_fianl(text,language):
|
def get_cleaned_text_final(text,language):
|
||||||
if language in {"en","all_zh","all_ja"}:
|
if language in {"en","all_zh","all_ja"}:
|
||||||
phones, word2ph, norm_text = clean_text_inf(text, language)
|
phones, word2ph, norm_text = clean_text_inf(text, language)
|
||||||
elif language in {"zh", "ja","auto"}:
|
elif language in {"zh", "ja","auto"}:
|
||||||
phones, word2ph, norm_text = nonen_clean_text_inf(text, language)
|
phones, word2ph, norm_text = nonen_clean_text_inf(text, language)
|
||||||
return phones, word2ph, norm_text
|
return phones, word2ph, norm_text
|
||||||
|
|
||||||
def get_bert_final(phones, word2ph, norm_text,language,device):
|
def get_bert_final(phones, word2ph, text,language,device):
|
||||||
if text_language == "en":
|
if language == "en":
|
||||||
bert = get_bert_inf(phones, word2ph, norm_text, text_language)
|
bert = get_bert_inf(phones, word2ph, text, language)
|
||||||
elif text_language in {"zh", "ja","auto"}:
|
elif language in {"zh", "ja","auto"}:
|
||||||
bert = nonen_get_bert_inf(text, text_language)
|
bert = nonen_get_bert_inf(text, language)
|
||||||
elif text_language == "all_zh":
|
elif language == "all_zh":
|
||||||
bert = get_bert_feature(norm_text, word2ph).to(device)
|
bert = get_bert_feature(text, word2ph).to(device)
|
||||||
else:
|
else:
|
||||||
bert = torch.zeros((1024, len(phones))).to(device)
|
bert = torch.zeros((1024, len(phones))).to(device)
|
||||||
return bert
|
return bert
|
||||||
|
|
||||||
def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language, how_to_cut=i18n("不切")):
|
def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language, how_to_cut=i18n("不切")):
|
||||||
t0 = ttime()
|
t0 = ttime()
|
||||||
|
prompt_language = dict_language[prompt_language]
|
||||||
|
text_language = dict_language[text_language]
|
||||||
prompt_text = prompt_text.strip("\n")
|
prompt_text = prompt_text.strip("\n")
|
||||||
if (prompt_text[-1] not in splits): prompt_text += "。" if prompt_language != "en" else "."
|
if (prompt_text[-1] not in splits): prompt_text += "。" if prompt_language != "en" else "."
|
||||||
text = text.strip("\n")
|
text = text.strip("\n")
|
||||||
@ -375,10 +377,8 @@ def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language,
|
|||||||
codes = vq_model.extract_latent(ssl_content)
|
codes = vq_model.extract_latent(ssl_content)
|
||||||
prompt_semantic = codes[0, 0]
|
prompt_semantic = codes[0, 0]
|
||||||
t1 = ttime()
|
t1 = ttime()
|
||||||
prompt_language = dict_language[prompt_language]
|
|
||||||
text_language = dict_language[text_language]
|
|
||||||
|
|
||||||
phones1, word2ph1, norm_text1=get_cleaned_text_fianl(prompt_text, prompt_language)
|
phones1, word2ph1, norm_text1=get_cleaned_text_final(prompt_text, prompt_language)
|
||||||
|
|
||||||
if (how_to_cut == i18n("凑四句一切")):
|
if (how_to_cut == i18n("凑四句一切")):
|
||||||
text = cut1(text)
|
text = cut1(text)
|
||||||
@ -402,9 +402,8 @@ def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language,
|
|||||||
continue
|
continue
|
||||||
if (text[-1] not in splits): text += "。" if text_language != "en" else "."
|
if (text[-1] not in splits): text += "。" if text_language != "en" else "."
|
||||||
print(i18n("实际输入的目标文本(每句):"), text)
|
print(i18n("实际输入的目标文本(每句):"), text)
|
||||||
phones2, word2ph2, norm_text2 = get_cleaned_text_fianl(text, text_language)
|
phones2, word2ph2, norm_text2 = get_cleaned_text_final(text, text_language)
|
||||||
bert2 = get_bert_final(phones2, word2ph2, norm_text2, text_language, device).to(dtype)
|
bert2 = get_bert_final(phones2, word2ph2, norm_text2, text_language, device).to(dtype)
|
||||||
|
|
||||||
bert = torch.cat([bert1, bert2], 1)
|
bert = torch.cat([bert1, bert2], 1)
|
||||||
|
|
||||||
all_phoneme_ids = torch.LongTensor(phones1 + phones2).to(device).unsqueeze(0)
|
all_phoneme_ids = torch.LongTensor(phones1 + phones2).to(device).unsqueeze(0)
|
||||||
@ -583,7 +582,7 @@ with gr.Blocks(title="GPT-SoVITS WebUI") as app:
|
|||||||
inp_ref = gr.Audio(label=i18n("请上传3~10秒内参考音频,超过会报错!"), type="filepath")
|
inp_ref = gr.Audio(label=i18n("请上传3~10秒内参考音频,超过会报错!"), type="filepath")
|
||||||
prompt_text = gr.Textbox(label=i18n("参考音频的文本"), value="")
|
prompt_text = gr.Textbox(label=i18n("参考音频的文本"), value="")
|
||||||
prompt_language = gr.Dropdown(
|
prompt_language = gr.Dropdown(
|
||||||
label=i18n("参考音频的语种"), choices=[i18n("中文"), i18n("英文"), i18n("日文")], value=i18n("中文")
|
label=i18n("参考音频的语种"), choices=[i18n("中文"), i18n("英文"), i18n("日文"), i18n("中英混合"), i18n("日英混合"), i18n("多语种混合")], value=i18n("中文")
|
||||||
)
|
)
|
||||||
gr.Markdown(value=i18n("*请填写需要合成的目标文本。中英混合选中文,日英混合选日文,中日混合暂不支持,非目标语言文本自动遗弃。"))
|
gr.Markdown(value=i18n("*请填写需要合成的目标文本。中英混合选中文,日英混合选日文,中日混合暂不支持,非目标语言文本自动遗弃。"))
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
|
@ -87,8 +87,18 @@
|
|||||||
|
|
||||||
2-引入paddlespeech的Normalizer https://github.com/RVC-Boss/GPT-SoVITS/pull/377 修复一些问题,例如:xx.xx%(带百分号类),元/吨 会读成 元吨 而不是元每吨,下划线不再会报错
|
2-引入paddlespeech的Normalizer https://github.com/RVC-Boss/GPT-SoVITS/pull/377 修复一些问题,例如:xx.xx%(带百分号类),元/吨 会读成 元吨 而不是元每吨,下划线不再会报错
|
||||||
|
|
||||||
|
### 20240207更新
|
||||||
|
|
||||||
|
1-修正语种传参混乱导致中文推理效果下降 https://github.com/RVC-Boss/GPT-SoVITS/issues/391
|
||||||
|
|
||||||
|
2-uvr5适配高版本librosa https://github.com/RVC-Boss/GPT-SoVITS/pull/403
|
||||||
|
|
||||||
|
3-修复uvr5 inf everywhere报错的问题(is_half传参未转换bool导致恒定半精度推理,16系显卡会inf) https://github.com/RVC-Boss/GPT-SoVITS/commit/14a285109a521679f8846589c22da8f656a46ad8
|
||||||
|
|
||||||
|
|
||||||
todolist:
|
todolist:
|
||||||
|
|
||||||
1-中文多音字推理优化
|
1-中文多音字推理优化
|
||||||
|
|
||||||
|
2-测试集成faster whisper ASR日文英文
|
||||||
|
|
||||||
|
@ -5,10 +5,11 @@ librosa==0.9.2
|
|||||||
numba==0.56.4
|
numba==0.56.4
|
||||||
pytorch-lightning
|
pytorch-lightning
|
||||||
gradio==3.38.0
|
gradio==3.38.0
|
||||||
|
gradio_client==0.8.1
|
||||||
ffmpeg-python
|
ffmpeg-python
|
||||||
onnxruntime
|
onnxruntime
|
||||||
tqdm
|
tqdm
|
||||||
funasr>=1.0.0
|
funasr==1.0.0
|
||||||
cn2an
|
cn2an
|
||||||
pypinyin
|
pypinyin
|
||||||
pyopenjtalk
|
pyopenjtalk
|
||||||
|
@ -43,8 +43,8 @@ def wave_to_spectrogram(
|
|||||||
wave_left = np.asfortranarray(wave[0])
|
wave_left = np.asfortranarray(wave[0])
|
||||||
wave_right = np.asfortranarray(wave[1])
|
wave_right = np.asfortranarray(wave[1])
|
||||||
|
|
||||||
spec_left = librosa.stft(wave_left, n_fft, hop_length=hop_length)
|
spec_left = librosa.stft(wave_left, n_fft=n_fft, hop_length=hop_length)
|
||||||
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
|
spec_right = librosa.stft(wave_right, n_fft=n_fft, hop_length=hop_length)
|
||||||
|
|
||||||
spec = np.asfortranarray([spec_left, spec_right])
|
spec = np.asfortranarray([spec_left, spec_right])
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ def wave_to_spectrogram_mt(
|
|||||||
kwargs={"y": wave_left, "n_fft": n_fft, "hop_length": hop_length},
|
kwargs={"y": wave_left, "n_fft": n_fft, "hop_length": hop_length},
|
||||||
)
|
)
|
||||||
thread.start()
|
thread.start()
|
||||||
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
|
spec_right = librosa.stft(wave_right, n_fft=n_fft, hop_length=hop_length)
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
spec = np.asfortranarray([spec_left, spec_right])
|
spec = np.asfortranarray([spec_left, spec_right])
|
||||||
@ -230,27 +230,31 @@ def cache_or_load(mix_path, inst_path, mp):
|
|||||||
|
|
||||||
if d == len(mp.param["band"]): # high-end band
|
if d == len(mp.param["band"]): # high-end band
|
||||||
X_wave[d], _ = librosa.load(
|
X_wave[d], _ = librosa.load(
|
||||||
mix_path, bp["sr"], False, dtype=np.float32, res_type=bp["res_type"]
|
mix_path,
|
||||||
|
sr = bp["sr"],
|
||||||
|
mono = False,
|
||||||
|
dtype = np.float32,
|
||||||
|
res_type = bp["res_type"]
|
||||||
)
|
)
|
||||||
y_wave[d], _ = librosa.load(
|
y_wave[d], _ = librosa.load(
|
||||||
inst_path,
|
inst_path,
|
||||||
bp["sr"],
|
sr = bp["sr"],
|
||||||
False,
|
mono = False,
|
||||||
dtype=np.float32,
|
dtype = np.float32,
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
else: # lower bands
|
else: # lower bands
|
||||||
X_wave[d] = librosa.resample(
|
X_wave[d] = librosa.resample(
|
||||||
X_wave[d + 1],
|
X_wave[d + 1],
|
||||||
mp.param["band"][d + 1]["sr"],
|
orig_sr = mp.param["band"][d + 1]["sr"],
|
||||||
bp["sr"],
|
target_sr = bp["sr"],
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
y_wave[d] = librosa.resample(
|
y_wave[d] = librosa.resample(
|
||||||
y_wave[d + 1],
|
y_wave[d + 1],
|
||||||
mp.param["band"][d + 1]["sr"],
|
orig_sr = mp.param["band"][d + 1]["sr"],
|
||||||
bp["sr"],
|
target_sr = bp["sr"],
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
|
|
||||||
X_wave[d], y_wave[d] = align_wave_head_and_tail(X_wave[d], y_wave[d])
|
X_wave[d], y_wave[d] = align_wave_head_and_tail(X_wave[d], y_wave[d])
|
||||||
@ -401,9 +405,9 @@ def cmb_spectrogram_to_wave(spec_m, mp, extra_bins_h=None, extra_bins=None):
|
|||||||
mp.param["mid_side_b2"],
|
mp.param["mid_side_b2"],
|
||||||
mp.param["reverse"],
|
mp.param["reverse"],
|
||||||
),
|
),
|
||||||
bp["sr"],
|
orig_sr = bp["sr"],
|
||||||
sr,
|
target_sr = sr,
|
||||||
res_type="sinc_fastest",
|
res_type = "sinc_fastest",
|
||||||
)
|
)
|
||||||
else: # mid
|
else: # mid
|
||||||
spec_s = fft_hp_filter(spec_s, bp["hpf_start"], bp["hpf_stop"] - 1)
|
spec_s = fft_hp_filter(spec_s, bp["hpf_start"], bp["hpf_stop"] - 1)
|
||||||
@ -418,8 +422,8 @@ def cmb_spectrogram_to_wave(spec_m, mp, extra_bins_h=None, extra_bins=None):
|
|||||||
mp.param["reverse"],
|
mp.param["reverse"],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
# wave = librosa.core.resample(wave2, bp['sr'], sr, res_type="sinc_fastest")
|
# wave = librosa.core.resample(wave2, orig_sr=bp['sr'], target_sr=sr, res_type="sinc_fastest")
|
||||||
wave = librosa.core.resample(wave2, bp["sr"], sr, res_type="scipy")
|
wave = librosa.core.resample(wave2, orig_sr=bp["sr"], target_sr=sr, res_type="scipy")
|
||||||
|
|
||||||
return wave.T
|
return wave.T
|
||||||
|
|
||||||
@ -506,8 +510,8 @@ def ensembling(a, specs):
|
|||||||
def stft(wave, nfft, hl):
|
def stft(wave, nfft, hl):
|
||||||
wave_left = np.asfortranarray(wave[0])
|
wave_left = np.asfortranarray(wave[0])
|
||||||
wave_right = np.asfortranarray(wave[1])
|
wave_right = np.asfortranarray(wave[1])
|
||||||
spec_left = librosa.stft(wave_left, nfft, hop_length=hl)
|
spec_left = librosa.stft(wave_left, n_fft=nfft, hop_length=hl)
|
||||||
spec_right = librosa.stft(wave_right, nfft, hop_length=hl)
|
spec_right = librosa.stft(wave_right, n_fft=nfft, hop_length=hl)
|
||||||
spec = np.asfortranarray([spec_left, spec_right])
|
spec = np.asfortranarray([spec_left, spec_right])
|
||||||
|
|
||||||
return spec
|
return spec
|
||||||
@ -569,10 +573,10 @@ if __name__ == "__main__":
|
|||||||
if d == len(mp.param["band"]): # high-end band
|
if d == len(mp.param["band"]): # high-end band
|
||||||
wave[d], _ = librosa.load(
|
wave[d], _ = librosa.load(
|
||||||
args.input[i],
|
args.input[i],
|
||||||
bp["sr"],
|
sr = bp["sr"],
|
||||||
False,
|
mono = False,
|
||||||
dtype=np.float32,
|
dtype = np.float32,
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(wave[d].shape) == 1: # mono to stereo
|
if len(wave[d].shape) == 1: # mono to stereo
|
||||||
@ -580,9 +584,9 @@ if __name__ == "__main__":
|
|||||||
else: # lower bands
|
else: # lower bands
|
||||||
wave[d] = librosa.resample(
|
wave[d] = librosa.resample(
|
||||||
wave[d + 1],
|
wave[d + 1],
|
||||||
mp.param["band"][d + 1]["sr"],
|
orig_sr = mp.param["band"][d + 1]["sr"],
|
||||||
bp["sr"],
|
target_sr = bp["sr"],
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
|
|
||||||
spec[d] = wave_to_spectrogram(
|
spec[d] = wave_to_spectrogram(
|
||||||
|
@ -61,19 +61,19 @@ class AudioPre:
|
|||||||
_,
|
_,
|
||||||
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
|
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
|
||||||
music_file,
|
music_file,
|
||||||
bp["sr"],
|
sr = bp["sr"],
|
||||||
False,
|
mono = False,
|
||||||
dtype=np.float32,
|
dtype = np.float32,
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
if X_wave[d].ndim == 1:
|
if X_wave[d].ndim == 1:
|
||||||
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
|
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
|
||||||
else: # lower bands
|
else: # lower bands
|
||||||
X_wave[d] = librosa.core.resample(
|
X_wave[d] = librosa.core.resample(
|
||||||
X_wave[d + 1],
|
X_wave[d + 1],
|
||||||
self.mp.param["band"][d + 1]["sr"],
|
orig_sr = self.mp.param["band"][d + 1]["sr"],
|
||||||
bp["sr"],
|
target_sr = bp["sr"],
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
# Stft of wave source
|
# Stft of wave source
|
||||||
X_spec_s[d] = spec_utils.wave_to_spectrogram_mt(
|
X_spec_s[d] = spec_utils.wave_to_spectrogram_mt(
|
||||||
@ -245,19 +245,19 @@ class AudioPreDeEcho:
|
|||||||
_,
|
_,
|
||||||
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
|
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
|
||||||
music_file,
|
music_file,
|
||||||
bp["sr"],
|
sr = bp["sr"],
|
||||||
False,
|
mono = False,
|
||||||
dtype=np.float32,
|
dtype = np.float32,
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
if X_wave[d].ndim == 1:
|
if X_wave[d].ndim == 1:
|
||||||
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
|
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
|
||||||
else: # lower bands
|
else: # lower bands
|
||||||
X_wave[d] = librosa.core.resample(
|
X_wave[d] = librosa.core.resample(
|
||||||
X_wave[d + 1],
|
X_wave[d + 1],
|
||||||
self.mp.param["band"][d + 1]["sr"],
|
orig_sr = self.mp.param["band"][d + 1]["sr"],
|
||||||
bp["sr"],
|
target_sr = bp["sr"],
|
||||||
res_type=bp["res_type"],
|
res_type = bp["res_type"],
|
||||||
)
|
)
|
||||||
# Stft of wave source
|
# Stft of wave source
|
||||||
X_spec_s[d] = spec_utils.wave_to_spectrogram_mt(
|
X_spec_s[d] = spec_utils.wave_to_spectrogram_mt(
|
||||||
|
@ -19,7 +19,7 @@ for name in os.listdir(weight_uvr5_root):
|
|||||||
uvr5_names.append(name.replace(".pth", ""))
|
uvr5_names.append(name.replace(".pth", ""))
|
||||||
|
|
||||||
device=sys.argv[1]
|
device=sys.argv[1]
|
||||||
is_half=sys.argv[2]
|
is_half=eval(sys.argv[2])
|
||||||
webui_port_uvr5=int(sys.argv[3])
|
webui_port_uvr5=int(sys.argv[3])
|
||||||
is_share=eval(sys.argv[4])
|
is_share=eval(sys.argv[4])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user