Improve log and webui

This commit is contained in:
litagin02
2024-03-14 15:19:09 +09:00
parent b1972a3d3d
commit b65d1d4755
3 changed files with 11 additions and 13 deletions

View File

@@ -61,9 +61,7 @@ def transcribe_files_with_hf_whisper(
generate_kwargs: dict[str, Any] = { generate_kwargs: dict[str, Any] = {
"language": language, "language": language,
"do_sample": False, "do_sample": False,
"num_beams": 5, "num_beams": num_beams,
"early_stopping": True,
"num_return_sequences": 5,
} }
if initial_prompt is not None: if initial_prompt is not None:
prompt_ids: torch.Tensor = processor.get_prompt_ids( prompt_ids: torch.Tensor = processor.get_prompt_ids(
@@ -72,6 +70,7 @@ def transcribe_files_with_hf_whisper(
prompt_ids = prompt_ids.to(device) prompt_ids = prompt_ids.to(device)
generate_kwargs["prompt_ids"] = prompt_ids generate_kwargs["prompt_ids"] = prompt_ids
logger.info(f"generate_kwargs: {generate_kwargs}")
pipe = pipeline( pipe = pipeline(
model=model_id, model=model_id,
max_new_tokens=128, max_new_tokens=128,
@@ -162,12 +161,12 @@ if __name__ == "__main__":
else: else:
raise ValueError(f"{language} is not supported.") raise ValueError(f"{language} is not supported.")
logger.info(
f"Loading Whisper model ({args.model}) with compute_type={compute_type}"
)
if not args.use_hf_whisper: if not args.use_hf_whisper:
from faster_whisper import WhisperModel from faster_whisper import WhisperModel
logger.info(
f"Loading Whisper model ({args.model}) with compute_type={compute_type}"
)
try: try:
model = WhisperModel(args.model, device=device, compute_type=compute_type) model = WhisperModel(args.model, device=device, compute_type=compute_type)
except ValueError as e: except ValueError as e:
@@ -185,6 +184,7 @@ if __name__ == "__main__":
f.write(f"{wav_file.name}|{model_name}|{language_id}|{text}\n") f.write(f"{wav_file.name}|{model_name}|{language_id}|{text}\n")
else: else:
model_id = f"openai/whisper-{args.model}" model_id = f"openai/whisper-{args.model}"
logger.info(f"Loading HF Whisper model ({model_id})")
pbar = tqdm(total=len(wav_files), file=SAFE_STDOUT) pbar = tqdm(total=len(wav_files), file=SAFE_STDOUT)
results = transcribe_files_with_hf_whisper( results = transcribe_files_with_hf_whisper(
audio_files=wav_files, audio_files=wav_files,

View File

@@ -249,9 +249,9 @@ def create_dataset_app() -> gr.Blocks:
outputs=[result2], outputs=[result2],
) )
use_hf_whisper.change( use_hf_whisper.change(
lambda x: gr.update(visible=x), lambda x: (gr.update(visible=x), gr.update(visible=not x)),
inputs=[use_hf_whisper], inputs=[use_hf_whisper],
outputs=[batch_size], outputs=[batch_size, compute_type],
) )
return app return app

View File

@@ -286,10 +286,6 @@ def load_styles_gr(model_name_a, model_name_b):
initial_md = """ initial_md = """
# Style-Bert-VITS2 モデルマージツール
2つのStyle-Bert-VITS2モデルから、声質・話し方・話す速さを取り替えたり混ぜたりできます。
## 使い方 ## 使い方
1. マージしたい2つのモデルを選択してください`model_assets`フォルダの中から選ばれます)。 1. マージしたい2つのモデルを選択してください`model_assets`フォルダの中から選ばれます)。
@@ -343,7 +339,9 @@ def create_merge_app(model_holder: TTSModelHolder) -> gr.Blocks:
initial_model_files = model_holder.model_files_dict[model_names[initial_id]] initial_model_files = model_holder.model_files_dict[model_names[initial_id]]
with gr.Blocks(theme=GRADIO_THEME) as app: with gr.Blocks(theme=GRADIO_THEME) as app:
gr.Markdown(initial_md) gr.Markdown(
"2つのStyle-Bert-VITS2モデルから、声質・話し方・話す速さを取り替えたり混ぜたりできます。"
)
with gr.Accordion(label="使い方", open=False): with gr.Accordion(label="使い方", open=False):
gr.Markdown(initial_md) gr.Markdown(initial_md)
with gr.Row(): with gr.Row():