Merge branch 'dev'

This commit is contained in:
litagin02
2024-02-07 17:54:10 +09:00
3 changed files with 75 additions and 4 deletions

View File

@@ -7,9 +7,11 @@
- 学習の際のメモリ使用量を削減しようと頑張った - 学習の際のメモリ使用量を削減しようと頑張った
### バグ修正や改善 ### バグ修正や改善
- 学習WebUIからTensorboardのログを見れるように
- 音声合成やそのAPIにおいて、同時に別の話者が選択され音声合成がリクエストされた場合に発生するエラーを修正 - 音声合成やそのAPIにおいて、同時に別の話者が選択され音声合成がリクエストされた場合に発生するエラーを修正
- モデルマージ時に、そのレシピを`recipe.json`ファイルへ保存するように変更 - モデルマージ時に、そのレシピを`recipe.json`ファイルへ保存するように変更
- 「改行で分けて生成」がより感情が乗る旨の明記等、軽微な説明文の改善 - 「改行で分けて生成」がより感情が乗る旨の明記等、軽微な説明文の改善
-`ーーそれは面白い`」や「`なるほど。ーーーそういうことか。`」等、長音記号の前が母音でない場合、長音記号`ー`でなくダッシュ`―`の勘違いだと思われるので、ダッシュ記号として処理するように変更
## v2.0.1 (2024-02-05) ## v2.0.1 (2024-02-05)

View File

@@ -485,9 +485,26 @@ def distribute_phone(n_phone: int, n_word: int) -> list[int]:
def handle_long(sep_phonemes: list[list[str]]) -> list[list[str]]: def handle_long(sep_phonemes: list[list[str]]) -> list[list[str]]:
"""
フレーズごとに分かれた音素(長音記号がそのまま)のリストのリスト`sep_phonemes`を受け取り、
その長音記号を処理して、音素のリストのリストを返す。
基本的には直前の音素を伸ばすが、直前の音素が母音でない場合もしくは冒頭の場合は、
おそらく長音記号とダッシュを勘違いしていると思われるので、ダッシュに対応する音素`-`に変換する。
"""
for i in range(len(sep_phonemes)): for i in range(len(sep_phonemes)):
if sep_phonemes[i][0] == "": if sep_phonemes[i][0] == "":
sep_phonemes[i][0] = sep_phonemes[i - 1][-1] if i != 0:
prev_phoneme = sep_phonemes[i - 1][-1]
if prev_phoneme in VOWELS:
# 母音と「ん」のあとの伸ばし棒なので、その母音に変換
sep_phonemes[i][0] = sep_phonemes[i - 1][-1]
else:
# 「。ーー」等おそらく予期しない長音記号
# ダッシュの勘違いだと思われる
sep_phonemes[i][0] = "-"
else:
# 冒頭に長音記号が来ていおり、これはダッシュの勘違いと思われる
sep_phonemes[i][0] = "-"
if "" in sep_phonemes[i]: if "" in sep_phonemes[i]:
for j in range(len(sep_phonemes[i])): for j in range(len(sep_phonemes[i])):
if sep_phonemes[i][j] == "": if sep_phonemes[i][j] == "":

View File

@@ -2,6 +2,11 @@ import argparse
import json import json
import os import os
import shutil import shutil
import subprocess
import socket
import sys
import time
import webbrowser
from datetime import datetime from datetime import datetime
from multiprocessing import cpu_count from multiprocessing import cpu_count
@@ -10,9 +15,11 @@ import yaml
from common.constants import LATEST_VERSION from common.constants import LATEST_VERSION
from common.log import logger from common.log import logger
from common.stdout_wrapper import SAFE_STDOUT
from common.subprocess_utils import run_script_with_log, second_elem_of from common.subprocess_utils import run_script_with_log, second_elem_of
logger_handler = None logger_handler = None
tensorboard_executed = False
# Get path settings # Get path settings
with open(os.path.join("configs", "paths.yml"), "r", encoding="utf-8") as f: with open(os.path.join("configs", "paths.yml"), "r", encoding="utf-8") as f:
@@ -316,6 +323,46 @@ def train(model_name, skip_style=False, use_jp_extra=True, speedup=False):
return True, "Success: 学習が完了しました" return True, "Success: 学習が完了しました"
def wait_for_tensorboard(port=6006, timeout=10):
start_time = time.time()
while True:
try:
with socket.create_connection(("localhost", port), timeout=1):
return True # ポートが開いている場合
except OSError:
pass # ポートがまだ開いていない場合
if time.time() - start_time > timeout:
return False # タイムアウト
time.sleep(0.1)
def run_tensorboard(model_name):
global tensorboard_executed
if not tensorboard_executed:
python = sys.executable
tensorboard_cmd = [
python,
"-m",
"tensorboard.main",
"--logdir",
f"Data/{model_name}/models",
]
subprocess.Popen(
tensorboard_cmd,
stdout=SAFE_STDOUT, # type: ignore
stderr=SAFE_STDOUT, # type: ignore
)
yield gr.Button("起動中…")
if wait_for_tensorboard():
tensorboard_executed = True
else:
logger.error("Tensorboard did not start in the expected time.")
webbrowser.open("http://localhost:6006")
yield gr.Button("Tensorboardを開く")
initial_md = f""" initial_md = f"""
# Style-Bert-VITS2 ver {LATEST_VERSION} 学習用WebUI # Style-Bert-VITS2 ver {LATEST_VERSION} 学習用WebUI
@@ -369,7 +416,7 @@ english_teacher.wav|Mary|EN|How are you? I'm fine, thank you, and you?
""" """
if __name__ == "__main__": if __name__ == "__main__":
with gr.Blocks(theme="NoCrypt/miku") as app: with gr.Blocks(theme="NoCrypt/miku").queue() as app:
gr.Markdown(initial_md) gr.Markdown(initial_md)
with gr.Accordion(label="データの前準備", open=False): with gr.Accordion(label="データの前準備", open=False):
gr.Markdown(prepare_md) gr.Markdown(prepare_md)
@@ -548,7 +595,7 @@ if __name__ == "__main__":
style_gen_btn = gr.Button(value="実行", variant="primary") style_gen_btn = gr.Button(value="実行", variant="primary")
info_style = gr.Textbox(label="状況") info_style = gr.Textbox(label="状況")
gr.Markdown("## 学習") gr.Markdown("## 学習")
with gr.Row(variant="panel"): with gr.Row():
skip_style = gr.Checkbox( skip_style = gr.Checkbox(
label="スタイルファイルの生成をスキップする", label="スタイルファイルの生成をスキップする",
info="学習再開の場合の場合はチェックしてください", info="学習再開の場合の場合はチェックしてください",
@@ -564,7 +611,8 @@ if __name__ == "__main__":
visible=False, # Experimental visible=False, # Experimental
) )
train_btn = gr.Button(value="学習を開始する", variant="primary") train_btn = gr.Button(value="学習を開始する", variant="primary")
info_train = gr.Textbox(label="状況") tensorboard_btn = gr.Button(value="Tensorboardを開く")
info_train = gr.Textbox(label="状況")
preprocess_button.click( preprocess_button.click(
second_elem_of(preprocess_all), second_elem_of(preprocess_all),
@@ -635,6 +683,10 @@ if __name__ == "__main__":
inputs=[model_name, skip_style, use_jp_extra_train, speedup], inputs=[model_name, skip_style, use_jp_extra_train, speedup],
outputs=[info_train], outputs=[info_train],
) )
tensorboard_btn.click(
run_tensorboard, inputs=[model_name], outputs=[tensorboard_btn]
)
use_jp_extra.change( use_jp_extra.change(
lambda x: gr.Checkbox(value=x), lambda x: gr.Checkbox(value=x),
inputs=[use_jp_extra], inputs=[use_jp_extra],