Skip to content

Commit

Permalink
Improve: automatically generate configs/paths.yml by copying it from …
Browse files Browse the repository at this point in the history
…configs/default_paths.yml when running initialize.py

If configs/paths.yml itself is included in version control, differences will occur when it is changed in each environment, which is troublesome.
  • Loading branch information
tsukumijima committed May 6, 2024
1 parent b230832 commit 87144dd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ dist/
/bert/*/*.safetensors
/bert/*/*.msgpack

/configs/paths.yml

/pretrained/*.safetensors
/pretrained/*.pth

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions gradio_tabs/style_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from style_bert_vits2.constants import DEFAULT_STYLE, GRADIO_THEME
from style_bert_vits2.logging import logger


# Get path settings
with open(os.path.join("configs", "paths.yml"), "r", encoding="utf-8") as f:
path_config: dict[str, str] = yaml.safe_load(f.read())
Expand Down
8 changes: 7 additions & 1 deletion initialize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import json
import shutil
from pathlib import Path

import yaml
Expand Down Expand Up @@ -102,11 +103,16 @@ def main():
download_pretrained_models()
download_jp_extra_pretrained_models()

# If configs/paths.yml not exists, create it
default_paths_yml = Path("configs/default_paths.yml")
paths_yml = Path("configs/paths.yml")
if not paths_yml.exists():
shutil.copy(default_paths_yml, paths_yml)

if args.dataset_root is None and args.assets_root is None:
return

# Change default paths if necessary
paths_yml = Path("configs/paths.yml")
with open(paths_yml, "r", encoding="utf-8") as f:
yml_data = yaml.safe_load(f)
if args.assets_root is not None:
Expand Down
5 changes: 3 additions & 2 deletions style_bert_vits2/tts_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def __init__(
# ハイパーパラメータのパスが指定された
else:
self.config_path: Path = config_path
self.hyper_parameters: HyperParameters = \
HyperParameters.load_from_json(self.config_path)
self.hyper_parameters: HyperParameters = HyperParameters.load_from_json(
self.config_path
)

# スタイルベクトルの NDArray が直接指定された
if isinstance(style_vec_path, np.ndarray):
Expand Down

0 comments on commit 87144dd

Please sign in to comment.