Skip to content

Commit

Permalink
Merge pull request #92 from zunan-islands/dev
Browse files Browse the repository at this point in the history
コードベースを大規模にリファクタリングし、ライブラリ (Python パッケージ) としてほかの Python コードから利用できるように改善
  • Loading branch information
litagin02 committed Mar 11, 2024
2 parents 7046f89 + 7f02b0f commit 03d4b4c
Show file tree
Hide file tree
Showing 106 changed files with 5,332 additions and 4,877 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.vscode/

__pycache__/
venv/
.venv/
dist/
.coverage
.ipynb_checkpoints/

/*.yml
Expand Down
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance"
]
}
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Pylance の Type Checking を有効化
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "strict",
// Pylance の Type Checking のうち、いくつかのエラー報告を抑制する
"python.analysis.diagnosticSeverityOverrides": {
"reportConstantRedefinition": "none",
"reportGeneralTypeIssues": "warning",
"reportMissingParameterType": "warning",
"reportMissingTypeStubs": "none",
"reportPrivateImportUsage": "none",
"reportPrivateUsage": "warning",
"reportShadowedImports": "none",
"reportUnnecessaryComparison": "none",
"reportUnknownArgumentType": "none",
"reportUnknownMemberType": "none",
"reportUnknownParameterType": "warning",
"reportUnknownVariableType": "none",
"reportUnusedFunction": "none",
"reportUnusedVariable": "information",
},
}
13 changes: 8 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import torch
import yaml

from common.constants import GRADIO_THEME, LATEST_VERSION
from common.tts_model import ModelHolder
from style_bert_vits2.constants import GRADIO_THEME, VERSION
from style_bert_vits2.tts_model import TTSModelHolder
from webui import (
create_dataset_app,
create_inference_app,
Expand All @@ -15,6 +15,7 @@
create_train_app,
)


# Get path settings
with Path("configs/paths.yml").open("r", encoding="utf-8") as f:
path_config: dict[str, str] = yaml.safe_load(f.read())
Expand All @@ -23,6 +24,8 @@

parser = argparse.ArgumentParser()
parser.add_argument("--device", type=str, default="cuda")
parser.add_argument("--host", type=str, default="127.0.0.1")
parser.add_argument("--port", type=int, default=7860)
parser.add_argument("--no_autolaunch", action="store_true")
parser.add_argument("--share", action="store_true")

Expand All @@ -31,10 +34,10 @@
if device == "cuda" and not torch.cuda.is_available():
device = "cpu"

model_holder = ModelHolder(Path(assets_root), device)
model_holder = TTSModelHolder(Path(assets_root), device)

with gr.Blocks(theme=GRADIO_THEME) as app:
gr.Markdown(f"# Style-Bert-VITS2 WebUI (version {LATEST_VERSION})")
gr.Markdown(f"# Style-Bert-VITS2 WebUI (version {VERSION})")
with gr.Tabs():
with gr.Tab("音声合成"):
create_inference_app(model_holder=model_holder)
Expand All @@ -48,4 +51,4 @@
create_merge_app(model_holder=model_holder)


app.launch(inbrowser=not args.no_autolaunch, share=args.share)
app.launch(server_name=args.host, server_port=args.port, inbrowser=not args.no_autolaunch, share=args.share)
16 changes: 7 additions & 9 deletions bert_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import torch.multiprocessing as mp
from tqdm import tqdm

import commons
from text.get_bert import get_bert
import text.pyopenjtalk_worker as pyopenjtalk
import utils
from common.log import logger
from common.stdout_wrapper import SAFE_STDOUT
from config import config
from text import cleaned_text_to_sequence
from style_bert_vits2.logging import logger
from style_bert_vits2.models import commons
from style_bert_vits2.models.hyper_parameters import HyperParameters
from style_bert_vits2.nlp import cleaned_text_to_sequence, extract_bert_feature
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT


def process_line(x):
Expand Down Expand Up @@ -47,7 +45,7 @@ def process_line(x):
bert = torch.load(bert_path)
assert bert.shape[-1] == len(phone)
except Exception:
bert = get_bert(text, word2ph, language_str, device)
bert = extract_bert_feature(text, word2ph, language_str, device)
assert bert.shape[-1] == len(phone)
torch.save(bert, bert_path)

Expand All @@ -64,7 +62,7 @@ def process_line(x):
)
args, _ = parser.parse_known_args()
config_path = args.config
hps = utils.get_hparams_from_file(config_path)
hps = HyperParameters.load_from_json(config_path)
lines = []
with open(hps.data.training_files, encoding="utf-8") as f:
lines.extend(f.readlines())
Expand Down
28 changes: 0 additions & 28 deletions common/constants.py

This file was deleted.

18 changes: 0 additions & 18 deletions common/log.py

This file was deleted.

33 changes: 0 additions & 33 deletions common/subprocess_utils.py

This file was deleted.

0 comments on commit 03d4b4c

Please sign in to comment.