From 7d24571f0c36bded324d0e7744f302ff92bab4ea Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 28 May 2024 13:57:50 +0000 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E3=83=9E=E3=83=8B=E3=83=95?= =?UTF-8?q?=E3=82=A7=E3=82=B9=E3=83=88=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build_util/make_docs.py | 2 +- run.py | 2 +- test/benchmark/engine_preparation.py | 2 +- test/e2e/conftest.py | 2 +- voicevox_engine/app/application.py | 2 +- voicevox_engine/app/routers/engine_info.py | 2 +- voicevox_engine/app/routers/library.py | 2 +- voicevox_engine/app/routers/portal_page.py | 2 +- voicevox_engine/app/routers/setting.py | 2 +- voicevox_engine/{ => engine_manifest}/engine_manifest.py | 0 10 files changed, 9 insertions(+), 9 deletions(-) rename voicevox_engine/{ => engine_manifest}/engine_manifest.py (100%) diff --git a/build_util/make_docs.py b/build_util/make_docs.py index 696a38041..d873ecdc6 100644 --- a/build_util/make_docs.py +++ b/build_util/make_docs.py @@ -6,7 +6,7 @@ from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.dev.core.mock import MockCoreWrapper from voicevox_engine.dev.tts_engine.mock import MockTTSEngine -from voicevox_engine.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest import load_manifest from voicevox_engine.preset.Preset import PresetManager from voicevox_engine.setting.Setting import USER_SETTING_PATH, SettingHandler from voicevox_engine.tts_pipeline.tts_engine import TTSEngineManager diff --git a/run.py b/run.py index dc34dbe32..9daeaee59 100644 --- a/run.py +++ b/run.py @@ -14,7 +14,7 @@ from voicevox_engine.app.application import generate_app from voicevox_engine.cancellable_engine import CancellableEngine from voicevox_engine.core.core_initializer import initialize_cores -from voicevox_engine.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest import load_manifest from voicevox_engine.preset.Preset import PresetManager from voicevox_engine.setting.Setting import ( USER_SETTING_PATH, diff --git a/test/benchmark/engine_preparation.py b/test/benchmark/engine_preparation.py index 059d2c791..6e30cd69f 100644 --- a/test/benchmark/engine_preparation.py +++ b/test/benchmark/engine_preparation.py @@ -9,7 +9,7 @@ from voicevox_engine.app.application import generate_app from voicevox_engine.core.core_initializer import initialize_cores -from voicevox_engine.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest import load_manifest from voicevox_engine.preset.PresetManager import PresetManager from voicevox_engine.setting.Setting import SettingHandler from voicevox_engine.tts_pipeline.tts_engine import make_tts_engines_from_cores diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index d755e54f0..35de89a84 100644 --- a/test/e2e/conftest.py +++ b/test/e2e/conftest.py @@ -8,7 +8,7 @@ from voicevox_engine.app.application import generate_app from voicevox_engine.core.core_initializer import initialize_cores -from voicevox_engine.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest import load_manifest from voicevox_engine.preset.Preset import PresetManager from voicevox_engine.setting.Setting import SettingHandler from voicevox_engine.tts_pipeline.tts_engine import make_tts_engines_from_cores diff --git a/voicevox_engine/app/application.py b/voicevox_engine/app/application.py index bbe435f1d..610540eca 100644 --- a/voicevox_engine/app/application.py +++ b/voicevox_engine/app/application.py @@ -17,7 +17,7 @@ from voicevox_engine.app.routers.user_dict import generate_user_dict_router from voicevox_engine.cancellable_engine import CancellableEngine from voicevox_engine.core.core_initializer import CoreManager -from voicevox_engine.engine_manifest import EngineManifest +from voicevox_engine.engine_manifest.engine_manifest import EngineManifest from voicevox_engine.library_manager import LibraryManager from voicevox_engine.metas.MetasStore import MetasStore from voicevox_engine.preset.Preset import PresetManager diff --git a/voicevox_engine/app/routers/engine_info.py b/voicevox_engine/app/routers/engine_info.py index 223e08858..cf1ffeb6e 100644 --- a/voicevox_engine/app/routers/engine_info.py +++ b/voicevox_engine/app/routers/engine_info.py @@ -9,7 +9,7 @@ from voicevox_engine import __version__ from voicevox_engine.core.core_adapter import DeviceSupport from voicevox_engine.core.core_initializer import CoreManager -from voicevox_engine.engine_manifest import EngineManifest +from voicevox_engine.engine_manifest.engine_manifest import EngineManifest class SupportedDevicesInfo(BaseModel): diff --git a/voicevox_engine/app/routers/library.py b/voicevox_engine/app/routers/library.py index 2393f8235..3558a9db8 100644 --- a/voicevox_engine/app/routers/library.py +++ b/voicevox_engine/app/routers/library.py @@ -6,7 +6,7 @@ from fastapi import APIRouter, Depends, HTTPException, Path, Request -from voicevox_engine.engine_manifest import EngineManifest +from voicevox_engine.engine_manifest.engine_manifest import EngineManifest from voicevox_engine.library_manager import LibraryManager from voicevox_engine.model import DownloadableLibraryInfo, InstalledLibraryInfo diff --git a/voicevox_engine/app/routers/portal_page.py b/voicevox_engine/app/routers/portal_page.py index 38902ee6b..477d75823 100644 --- a/voicevox_engine/app/routers/portal_page.py +++ b/voicevox_engine/app/routers/portal_page.py @@ -3,7 +3,7 @@ from fastapi import APIRouter from fastapi.responses import HTMLResponse -from voicevox_engine.engine_manifest import EngineName +from voicevox_engine.engine_manifest.engine_manifest import EngineName def generate_portal_page_router(engine_name: EngineName) -> APIRouter: diff --git a/voicevox_engine/app/routers/setting.py b/voicevox_engine/app/routers/setting.py index 94f50a86a..b23f309fb 100644 --- a/voicevox_engine/app/routers/setting.py +++ b/voicevox_engine/app/routers/setting.py @@ -5,7 +5,7 @@ from fastapi import APIRouter, Depends, Form, Request, Response from fastapi.templating import Jinja2Templates -from voicevox_engine.engine_manifest import BrandName +from voicevox_engine.engine_manifest.engine_manifest import BrandName from voicevox_engine.setting.Setting import CorsPolicyMode, Setting, SettingHandler from voicevox_engine.utility.path_utility import resource_root diff --git a/voicevox_engine/engine_manifest.py b/voicevox_engine/engine_manifest/engine_manifest.py similarity index 100% rename from voicevox_engine/engine_manifest.py rename to voicevox_engine/engine_manifest/engine_manifest.py From b3d7431348444986fb64941df62fe05b4f93aa37 Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 28 May 2024 14:03:45 +0000 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E3=82=A8=E3=83=B3=E3=82=B8?= =?UTF-8?q?=E3=83=B3=E3=83=9E=E3=83=8B=E3=83=95=E3=82=A7=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=AB=20`model`=20=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- voicevox_engine/app/application.py | 2 +- voicevox_engine/app/routers/engine_info.py | 2 +- voicevox_engine/app/routers/library.py | 2 +- voicevox_engine/app/routers/portal_page.py | 2 +- voicevox_engine/app/routers/setting.py | 2 +- .../engine_manifest/engine_manifest.py | 78 +----------------- voicevox_engine/engine_manifest/model.py | 81 +++++++++++++++++++ 7 files changed, 89 insertions(+), 80 deletions(-) create mode 100644 voicevox_engine/engine_manifest/model.py diff --git a/voicevox_engine/app/application.py b/voicevox_engine/app/application.py index 610540eca..92db47332 100644 --- a/voicevox_engine/app/application.py +++ b/voicevox_engine/app/application.py @@ -17,7 +17,7 @@ from voicevox_engine.app.routers.user_dict import generate_user_dict_router from voicevox_engine.cancellable_engine import CancellableEngine from voicevox_engine.core.core_initializer import CoreManager -from voicevox_engine.engine_manifest.engine_manifest import EngineManifest +from voicevox_engine.engine_manifest.model import EngineManifest from voicevox_engine.library_manager import LibraryManager from voicevox_engine.metas.MetasStore import MetasStore from voicevox_engine.preset.Preset import PresetManager diff --git a/voicevox_engine/app/routers/engine_info.py b/voicevox_engine/app/routers/engine_info.py index cf1ffeb6e..a192b168e 100644 --- a/voicevox_engine/app/routers/engine_info.py +++ b/voicevox_engine/app/routers/engine_info.py @@ -9,7 +9,7 @@ from voicevox_engine import __version__ from voicevox_engine.core.core_adapter import DeviceSupport from voicevox_engine.core.core_initializer import CoreManager -from voicevox_engine.engine_manifest.engine_manifest import EngineManifest +from voicevox_engine.engine_manifest.model import EngineManifest class SupportedDevicesInfo(BaseModel): diff --git a/voicevox_engine/app/routers/library.py b/voicevox_engine/app/routers/library.py index 3558a9db8..22d0ece83 100644 --- a/voicevox_engine/app/routers/library.py +++ b/voicevox_engine/app/routers/library.py @@ -6,7 +6,7 @@ from fastapi import APIRouter, Depends, HTTPException, Path, Request -from voicevox_engine.engine_manifest.engine_manifest import EngineManifest +from voicevox_engine.engine_manifest.model import EngineManifest from voicevox_engine.library_manager import LibraryManager from voicevox_engine.model import DownloadableLibraryInfo, InstalledLibraryInfo diff --git a/voicevox_engine/app/routers/portal_page.py b/voicevox_engine/app/routers/portal_page.py index 477d75823..4dbc3f3fe 100644 --- a/voicevox_engine/app/routers/portal_page.py +++ b/voicevox_engine/app/routers/portal_page.py @@ -3,7 +3,7 @@ from fastapi import APIRouter from fastapi.responses import HTMLResponse -from voicevox_engine.engine_manifest.engine_manifest import EngineName +from voicevox_engine.engine_manifest.model import EngineName def generate_portal_page_router(engine_name: EngineName) -> APIRouter: diff --git a/voicevox_engine/app/routers/setting.py b/voicevox_engine/app/routers/setting.py index b23f309fb..50527d0f3 100644 --- a/voicevox_engine/app/routers/setting.py +++ b/voicevox_engine/app/routers/setting.py @@ -5,7 +5,7 @@ from fastapi import APIRouter, Depends, Form, Request, Response from fastapi.templating import Jinja2Templates -from voicevox_engine.engine_manifest.engine_manifest import BrandName +from voicevox_engine.engine_manifest.model import BrandName from voicevox_engine.setting.Setting import CorsPolicyMode, Setting, SettingHandler from voicevox_engine.utility.path_utility import resource_root diff --git a/voicevox_engine/engine_manifest/engine_manifest.py b/voicevox_engine/engine_manifest/engine_manifest.py index 9c93a6a81..6bbfcf4bb 100644 --- a/voicevox_engine/engine_manifest/engine_manifest.py +++ b/voicevox_engine/engine_manifest/engine_manifest.py @@ -1,14 +1,10 @@ -# マルチエンジン環境下においては、エンジンのバージョンがエディタのバージョンより -# 古くなる可能性が十分に考えられる。その場合、エディタ側がEngineManifestの情報不足によって -# エラーを吐いて表示が崩壊する可能性がある。これを防止するため、EngineManifest関連の定義を -# 変更する際は、Optionalにする必要があることに留意しなければならない。 - import json from base64 import b64encode from pathlib import Path -from typing import TypeAlias -from pydantic import BaseModel, Field +from pydantic import BaseModel + +from .model import EngineManifest, LicenseInfo, UpdateInfo class FeatureSupportJson(BaseModel): @@ -54,74 +50,6 @@ class EngineManifestJson(BaseModel): supported_features: SupportedFeaturesJson -class UpdateInfo(BaseModel): - """ - エンジンのアップデート情報 - """ - - version: str = Field(title="エンジンのバージョン名") - descriptions: list[str] = Field(title="アップデートの詳細についての説明") - contributors: list[str] | None = Field(title="貢献者名") - - -class LicenseInfo(BaseModel): - """ - 依存ライブラリのライセンス情報 - """ - - name: str = Field(title="依存ライブラリ名") - version: str | None = Field(title="依存ライブラリのバージョン") - license: str | None = Field(title="依存ライブラリのライセンス名") - text: str = Field(title="依存ライブラリのライセンス本文") - - -class SupportedFeatures(BaseModel): - """ - エンジンが持つ機能の一覧 - """ - - adjust_mora_pitch: bool = Field(title="モーラごとの音高の調整") - adjust_phoneme_length: bool = Field(title="音素ごとの長さの調整") - adjust_speed_scale: bool = Field(title="全体の話速の調整") - adjust_pitch_scale: bool = Field(title="全体の音高の調整") - adjust_intonation_scale: bool = Field(title="全体の抑揚の調整") - adjust_volume_scale: bool = Field(title="全体の音量の調整") - interrogative_upspeak: bool = Field(title="疑問文の自動調整") - synthesis_morphing: bool = Field( - title="2種類のスタイルでモーフィングした音声を合成" - ) - sing: bool | None = Field(title="歌唱音声合成") - manage_library: bool | None = Field( - title="音声ライブラリのインストール・アンインストール" - ) - - -EngineName: TypeAlias = str -BrandName: TypeAlias = str - - -class EngineManifest(BaseModel): - """ - エンジン自体に関する情報 - """ - - manifest_version: str = Field(title="マニフェストのバージョン") - name: EngineName = Field(title="エンジン名") - brand_name: BrandName = Field(title="ブランド名") - uuid: str = Field(title="エンジンのUUID") - url: str = Field(title="エンジンのURL") - icon: str = Field(title="エンジンのアイコンをBASE64エンコードしたもの") - default_sampling_rate: int = Field(title="デフォルトのサンプリング周波数") - frame_rate: float = Field(title="エンジンのフレームレート") - terms_of_service: str = Field(title="エンジンの利用規約") - update_infos: list[UpdateInfo] = Field(title="エンジンのアップデート情報") - dependency_licenses: list[LicenseInfo] = Field(title="依存関係のライセンス情報") - supported_vvlib_manifest_version: str | None = Field( - title="エンジンが対応するvvlibのバージョン" - ) - supported_features: SupportedFeatures = Field(title="エンジンが持つ機能") - - def load_manifest(manifest_path: Path) -> EngineManifest: """エンジンマニフェストを指定ファイルから読み込む。""" diff --git a/voicevox_engine/engine_manifest/model.py b/voicevox_engine/engine_manifest/model.py new file mode 100644 index 000000000..7bd711e69 --- /dev/null +++ b/voicevox_engine/engine_manifest/model.py @@ -0,0 +1,81 @@ +""" +エンジンマニフェスト機能に関して API と ENGINE 内部実装が共有するモデル +「API と ENGINE 内部実装が共有するモデル」については `voicevox_engine/model.py` の module docstring を確認すること。 + +マルチエンジン環境下においては、エンジンのバージョンがエディタのバージョンより +古くなる可能性が十分に考えられる。その場合、エディタ側がEngineManifestの情報不足によって +エラーを吐いて表示が崩壊する可能性がある。これを防止するため、EngineManifest関連の定義を +変更する際は、Optionalにする必要があることに留意しなければならない。 +""" + +from typing import TypeAlias + +from pydantic import BaseModel, Field + + +class UpdateInfo(BaseModel): + """ + エンジンのアップデート情報 + """ + + version: str = Field(title="エンジンのバージョン名") + descriptions: list[str] = Field(title="アップデートの詳細についての説明") + contributors: list[str] | None = Field(title="貢献者名") + + +class LicenseInfo(BaseModel): + """ + 依存ライブラリのライセンス情報 + """ + + name: str = Field(title="依存ライブラリ名") + version: str | None = Field(title="依存ライブラリのバージョン") + license: str | None = Field(title="依存ライブラリのライセンス名") + text: str = Field(title="依存ライブラリのライセンス本文") + + +class SupportedFeatures(BaseModel): + """ + エンジンが持つ機能の一覧 + """ + + adjust_mora_pitch: bool = Field(title="モーラごとの音高の調整") + adjust_phoneme_length: bool = Field(title="音素ごとの長さの調整") + adjust_speed_scale: bool = Field(title="全体の話速の調整") + adjust_pitch_scale: bool = Field(title="全体の音高の調整") + adjust_intonation_scale: bool = Field(title="全体の抑揚の調整") + adjust_volume_scale: bool = Field(title="全体の音量の調整") + interrogative_upspeak: bool = Field(title="疑問文の自動調整") + synthesis_morphing: bool = Field( + title="2種類のスタイルでモーフィングした音声を合成" + ) + sing: bool | None = Field(title="歌唱音声合成") + manage_library: bool | None = Field( + title="音声ライブラリのインストール・アンインストール" + ) + + +EngineName: TypeAlias = str +BrandName: TypeAlias = str + + +class EngineManifest(BaseModel): + """ + エンジン自体に関する情報 + """ + + manifest_version: str = Field(title="マニフェストのバージョン") + name: EngineName = Field(title="エンジン名") + brand_name: BrandName = Field(title="ブランド名") + uuid: str = Field(title="エンジンのUUID") + url: str = Field(title="エンジンのURL") + icon: str = Field(title="エンジンのアイコンをBASE64エンコードしたもの") + default_sampling_rate: int = Field(title="デフォルトのサンプリング周波数") + frame_rate: float = Field(title="エンジンのフレームレート") + terms_of_service: str = Field(title="エンジンの利用規約") + update_infos: list[UpdateInfo] = Field(title="エンジンのアップデート情報") + dependency_licenses: list[LicenseInfo] = Field(title="依存関係のライセンス情報") + supported_vvlib_manifest_version: str | None = Field( + title="エンジンが対応するvvlibのバージョン" + ) + supported_features: SupportedFeatures = Field(title="エンジンが持つ機能") From 4cc4e3935d2c922aa79825de10d43fdd8a64ba8c Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 28 May 2024 14:06:36 +0000 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=E3=82=A8=E3=83=B3=E3=82=B8?= =?UTF-8?q?=E3=83=B3=E3=83=9E=E3=83=8B=E3=83=95=E3=82=A7=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=82=92=E3=83=AA?= =?UTF-8?q?=E3=83=8D=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build_util/make_docs.py | 2 +- run.py | 2 +- test/benchmark/engine_preparation.py | 2 +- test/e2e/conftest.py | 2 +- .../{engine_manifest.py => engine_manifest_loader.py} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename voicevox_engine/engine_manifest/{engine_manifest.py => engine_manifest_loader.py} (100%) diff --git a/build_util/make_docs.py b/build_util/make_docs.py index d873ecdc6..d8a451a94 100644 --- a/build_util/make_docs.py +++ b/build_util/make_docs.py @@ -6,7 +6,7 @@ from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.dev.core.mock import MockCoreWrapper from voicevox_engine.dev.tts_engine.mock import MockTTSEngine -from voicevox_engine.engine_manifest.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest_loader import load_manifest from voicevox_engine.preset.Preset import PresetManager from voicevox_engine.setting.Setting import USER_SETTING_PATH, SettingHandler from voicevox_engine.tts_pipeline.tts_engine import TTSEngineManager diff --git a/run.py b/run.py index 9daeaee59..a257ad774 100644 --- a/run.py +++ b/run.py @@ -14,7 +14,7 @@ from voicevox_engine.app.application import generate_app from voicevox_engine.cancellable_engine import CancellableEngine from voicevox_engine.core.core_initializer import initialize_cores -from voicevox_engine.engine_manifest.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest_loader import load_manifest from voicevox_engine.preset.Preset import PresetManager from voicevox_engine.setting.Setting import ( USER_SETTING_PATH, diff --git a/test/benchmark/engine_preparation.py b/test/benchmark/engine_preparation.py index 6e30cd69f..891a6669e 100644 --- a/test/benchmark/engine_preparation.py +++ b/test/benchmark/engine_preparation.py @@ -9,7 +9,7 @@ from voicevox_engine.app.application import generate_app from voicevox_engine.core.core_initializer import initialize_cores -from voicevox_engine.engine_manifest.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest_loader import load_manifest from voicevox_engine.preset.PresetManager import PresetManager from voicevox_engine.setting.Setting import SettingHandler from voicevox_engine.tts_pipeline.tts_engine import make_tts_engines_from_cores diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index 35de89a84..5ab55bfb2 100644 --- a/test/e2e/conftest.py +++ b/test/e2e/conftest.py @@ -8,7 +8,7 @@ from voicevox_engine.app.application import generate_app from voicevox_engine.core.core_initializer import initialize_cores -from voicevox_engine.engine_manifest.engine_manifest import load_manifest +from voicevox_engine.engine_manifest.engine_manifest_loader import load_manifest from voicevox_engine.preset.Preset import PresetManager from voicevox_engine.setting.Setting import SettingHandler from voicevox_engine.tts_pipeline.tts_engine import make_tts_engines_from_cores diff --git a/voicevox_engine/engine_manifest/engine_manifest.py b/voicevox_engine/engine_manifest/engine_manifest_loader.py similarity index 100% rename from voicevox_engine/engine_manifest/engine_manifest.py rename to voicevox_engine/engine_manifest/engine_manifest_loader.py