Remove warnings and add some warnings (#1408)

This commit is contained in:
XXXXRT666
2024-08-06 18:37:55 +08:00
committed by GitHub
parent 2196b2bfc6
commit 805dbd7ff2
5 changed files with 61 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import librosa
import torch
import torch.nn.functional as F
import soundfile as sf
import os
from transformers import logging as tf_logging
tf_logging.set_verbosity_error()
@@ -24,9 +25,11 @@ cnhubert_base_path = None
class CNHubert(nn.Module):
def __init__(self):
super().__init__()
self.model = HubertModel.from_pretrained(cnhubert_base_path)
if os.path.exists(cnhubert_base_path):...
else:raise FileNotFoundError(cnhubert_base_path)
self.model = HubertModel.from_pretrained(cnhubert_base_path, local_files_only=True)
self.feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(
cnhubert_base_path
cnhubert_base_path, local_files_only=True
)
def forward(self, x):

View File

@@ -389,6 +389,10 @@ def merge_short_text_in_array(texts, threshold):
cache= {}
def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language, how_to_cut=i18n("不切"), top_k=20, top_p=0.6, temperature=0.6, ref_free = False,speed=1,if_freeze=False):
global cache
if ref_wav_path:pass
else:gr.Warning(i18n('请上传参考音频'))
if text:pass
else:gr.Warning(i18n('请填入推理文本'))
t = []
if prompt_text is None or len(prompt_text) == 0:
ref_free = True
@@ -413,6 +417,7 @@ def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language,
with torch.no_grad():
wav16k, sr = librosa.load(ref_wav_path, sr=16000)
if (wav16k.shape[0] > 160000 or wav16k.shape[0] < 48000):
gr.Warning(i18n("参考音频在3~10秒范围外请更换"))
raise OSError(i18n("参考音频在3~10秒范围外请更换"))
wav16k = torch.from_numpy(wav16k)
zero_wav_torch = torch.from_numpy(zero_wav)

View File

@@ -54,6 +54,8 @@ if os.path.exists(txt_path) == False:
# device = "mps"
else:
device = "cpu"
if os.path.exists(bert_pretrained_dir):...
else:raise FileNotFoundError(bert_pretrained_dir)
tokenizer = AutoTokenizer.from_pretrained(bert_pretrained_dir)
bert_model = AutoModelForMaskedLM.from_pretrained(bert_pretrained_dir)
if is_half == True:

View File

@@ -34,6 +34,8 @@ logging.getLogger("numba").setLevel(logging.WARNING)
# os.environ["CUDA_VISIBLE_DEVICES"]=sys.argv[5]
# opt_dir="/data/docker/liujing04/gpt-vits/fine_tune_dataset/%s"%exp_name
if os.path.exists(pretrained_s2G):...
else:raise FileNotFoundError(pretrained_s2G)
hubert_dir = "%s/4-cnhubert" % (opt_dir)
semantic_path = "%s/6-name2semantic-%s.tsv" % (opt_dir, i_part)