From a79b1910fb1945151903458e4ddca938d008d096 Mon Sep 17 00:00:00 2001 From: tsukumi Date: Sat, 9 Mar 2024 18:38:16 +0000 Subject: [PATCH] Add: use hatch to build style-bert-vits2 as a library --- .gitignore | 1 + app.py | 4 +- pyproject.toml | 92 +++++++++++++++++++++++++++++++++++ server_editor.py | 4 +- style_bert_vits2/constants.py | 2 +- tests/__init__.py | 0 6 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml create mode 100644 tests/__init__.py diff --git a/.gitignore b/.gitignore index 88048d7..b8a19a4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ venv/ .venv/ +dist/ .ipynb_checkpoints/ /*.yml diff --git a/app.py b/app.py index f0f94d0..eaf07b7 100644 --- a/app.py +++ b/app.py @@ -5,7 +5,7 @@ import gradio as gr import torch import yaml -from style_bert_vits2.constants import GRADIO_THEME, LATEST_VERSION +from style_bert_vits2.constants import GRADIO_THEME, VERSION from style_bert_vits2.tts_model import ModelHolder from webui import ( create_dataset_app, @@ -37,7 +37,7 @@ if device == "cuda" and not torch.cuda.is_available(): model_holder = ModelHolder(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) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4db5fe9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,92 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "style-bert-vits2" +dynamic = ["version"] +description = 'Style-Bert-VITS2: Bert-VITS2 with more controllable voice styles.' +readme = "README.md" +requires-python = ">=3.9" +license = "AGPL-3.0" +keywords = [] +authors = [ + { name = "litagin02", email = "139731664+litagin02@users.noreply.github.com" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", +] +dependencies = [ + 'cmudict', + 'cn2an', + 'g2p_en', + 'gradio', + 'jieba', + 'librosa==0.9.2', + 'loguru', + 'num2words', + 'numba', + 'numpy', + 'pyannote.audio>=3.1.0', + 'pydantic', + 'pyopenjtalk-dict', + 'pypinyin', + 'pyworld', + 'safetensors', + 'scipy', + 'torch>=2.1,<2.2', + 'transformers', +] + +[project.urls] +Documentation = "https://github.com/litagin02/Style-Bert-VITS2#readme" +Issues = "https://github.com/litagin02/Style-Bert-VITS2/issues" +Source = "https://github.com/litagin02/Style-Bert-VITS2" + +[tool.hatch.version] +path = "style_bert_vits2/constants.py" + +[tool.hatch.envs.default] +dependencies = [ + "coverage[toml]>=6.5", + "pytest", +] +[tool.hatch.envs.default.scripts] +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" +cov-report = [ + "- coverage combine", + "coverage report", +] +cov = [ + "test-cov", + "cov-report", +] + +[[tool.hatch.envs.all.matrix]] +python = ["3.9", "3.10", "3.11", "3.12"] + +[tool.coverage.run] +source_pkgs = ["style_bert_vits2", "tests"] +branch = true +parallel = true +omit = [ + "style_bert_vits2/constants.py", +] + +[tool.coverage.paths] +style_bert_vits2 = ["style_bert_vits2", "*/style-bert-vits2/style_bert_vits2"] +tests = ["tests", "*/style-bert-vits2/tests"] + +[tool.coverage.report] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] diff --git a/server_editor.py b/server_editor.py index 9a6a08a..b12f304 100644 --- a/server_editor.py +++ b/server_editor.py @@ -37,7 +37,7 @@ from style_bert_vits2.constants import ( DEFAULT_SDP_RATIO, DEFAULT_STYLE, DEFAULT_STYLE_WEIGHT, - LATEST_VERSION, + VERSION, Languages, ) from style_bert_vits2.logging import logger @@ -219,7 +219,7 @@ router = APIRouter() @router.get("/version") def version() -> str: - return LATEST_VERSION + return VERSION class MoraTone(BaseModel): diff --git a/style_bert_vits2/constants.py b/style_bert_vits2/constants.py index 5f32a15..735aebc 100644 --- a/style_bert_vits2/constants.py +++ b/style_bert_vits2/constants.py @@ -4,7 +4,7 @@ from style_bert_vits2.utils.strenum import StrEnum # Style-Bert-VITS2 のバージョン -LATEST_VERSION = "2.4" +VERSION = "2.4" # Style-Bert-VITS2 のベースディレクトリ BASE_DIR = Path(__file__).parent.parent diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29