From 740d91f7b99d5b8ab2a6f1f69dd69415a521bfa8 Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 21 May 2024 18:22:26 +0000 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20`engine=5Fmanifest.json`=20?= =?UTF-8?q?=E3=81=AE=E3=83=90=E3=83=AA=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine_manifest/EngineManifestLoader.py | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/voicevox_engine/engine_manifest/EngineManifestLoader.py b/voicevox_engine/engine_manifest/EngineManifestLoader.py index 8e5ce25b0..166d62a47 100644 --- a/voicevox_engine/engine_manifest/EngineManifestLoader.py +++ b/voicevox_engine/engine_manifest/EngineManifestLoader.py @@ -2,14 +2,56 @@ from base64 import b64encode from pathlib import Path +from pydantic import BaseModel + from .EngineManifest import EngineManifest, LicenseInfo, UpdateInfo +class FeatureSupportJson(BaseModel): + """`engine_manifest.json` の機能サポート状況""" + type: str + value: bool + name: str + + +class SupportedFeaturesJson(BaseModel): + """`engine_manifest.json` のサポート機能一覧""" + adjust_mora_pitch: FeatureSupportJson + adjust_phoneme_length: FeatureSupportJson + adjust_speed_scale: FeatureSupportJson + adjust_pitch_scale: FeatureSupportJson + adjust_intonation_scale: FeatureSupportJson + adjust_volume_scale: FeatureSupportJson + interrogative_upspeak: FeatureSupportJson + synthesis_morphing : FeatureSupportJson + sing : FeatureSupportJson + manage_library: FeatureSupportJson + + +class EngineManifestJson(BaseModel): + """`engine_manifest.json` のコンテンツ""" + manifest_version: str + name: str + brand_name: str + uuid: str + version: str + url: str + command: str + port: int + icon: str + default_sampling_rate: int + frame_rate: float + terms_of_service: str + update_infos: str + dependency_licenses: str + supported_features: SupportedFeaturesJson + + def load_manifest(manifest_path: Path) -> EngineManifest: """エンジンマニフェストを指定ファイルから読み込む。""" root_dir = manifest_path.parent - manifest = json.loads(manifest_path.read_text(encoding="utf-8")) + manifest = EngineManifestJson.parse_file(manifest_path).dict() return EngineManifest( manifest_version=manifest["manifest_version"], name=manifest["name"], From 0a8696bf672f55ee6ffa4be858cc6b84552ff6ab Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 21 May 2024 18:23:09 +0000 Subject: [PATCH 2/2] fix: lint --- voicevox_engine/engine_manifest/EngineManifestLoader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/voicevox_engine/engine_manifest/EngineManifestLoader.py b/voicevox_engine/engine_manifest/EngineManifestLoader.py index 166d62a47..0c4aa911d 100644 --- a/voicevox_engine/engine_manifest/EngineManifestLoader.py +++ b/voicevox_engine/engine_manifest/EngineManifestLoader.py @@ -9,6 +9,7 @@ class FeatureSupportJson(BaseModel): """`engine_manifest.json` の機能サポート状況""" + type: str value: bool name: str @@ -16,6 +17,7 @@ class FeatureSupportJson(BaseModel): class SupportedFeaturesJson(BaseModel): """`engine_manifest.json` のサポート機能一覧""" + adjust_mora_pitch: FeatureSupportJson adjust_phoneme_length: FeatureSupportJson adjust_speed_scale: FeatureSupportJson @@ -23,13 +25,14 @@ class SupportedFeaturesJson(BaseModel): adjust_intonation_scale: FeatureSupportJson adjust_volume_scale: FeatureSupportJson interrogative_upspeak: FeatureSupportJson - synthesis_morphing : FeatureSupportJson - sing : FeatureSupportJson + synthesis_morphing: FeatureSupportJson + sing: FeatureSupportJson manage_library: FeatureSupportJson class EngineManifestJson(BaseModel): """`engine_manifest.json` のコンテンツ""" + manifest_version: str name: str brand_name: str