Refactor: rename Model / ModelHolder to TTSModel / TTSModelHolder for clarification and add comments to each method

This commit is contained in:
tsukumi
2024-03-10 03:47:17 +00:00
parent b7d7c78203
commit d2fd378b56
7 changed files with 133 additions and 56 deletions

View File

@@ -11,7 +11,7 @@ from safetensors.torch import save_file
from style_bert_vits2.constants import DEFAULT_STYLE, GRADIO_THEME
from style_bert_vits2.logging import logger
from style_bert_vits2.tts_model import Model, ModelHolder
from style_bert_vits2.tts_model import TTSModel, TTSModelHolder
voice_keys = ["dec"]
@@ -250,11 +250,11 @@ def simple_tts(model_name, text, style=DEFAULT_STYLE, style_weight=1.0):
config_path = os.path.join(assets_root, model_name, "config.json")
style_vec_path = os.path.join(assets_root, model_name, "style_vectors.npy")
model = Model(Path(model_path), Path(config_path), Path(style_vec_path), device)
model = TTSModel(Path(model_path), Path(config_path), Path(style_vec_path), device)
return model.infer(text, style=style, style_weight=style_weight)
def update_two_model_names_dropdown(model_holder: ModelHolder):
def update_two_model_names_dropdown(model_holder: TTSModelHolder):
new_names, new_files, _ = model_holder.update_model_names_for_gradio()
return new_names, new_files, new_names, new_files
@@ -328,7 +328,7 @@ Happy, Surprise, HappySurprise
"""
def create_merge_app(model_holder: ModelHolder) -> gr.Blocks:
def create_merge_app(model_holder: TTSModelHolder) -> gr.Blocks:
model_names = model_holder.model_names
if len(model_names) == 0:
logger.error(