Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EngineManifestモデルの追加機能群をOptionalにする #704

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions voicevox_engine/downloadable_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ class LibraryManager:
def __init__(
self,
library_root_dir: Path,
supported_vvlib_version: str,
supported_vvlib_version: str | None,
brand_name: str,
engine_name: str,
engine_uuid: str,
):
self.library_root_dir = library_root_dir
self.library_root_dir.mkdir(exist_ok=True)
self.supported_vvlib_version = Version.parse(supported_vvlib_version)
if supported_vvlib_version is not None:
self.supported_vvlib_version = Version.parse(supported_vvlib_version)
else:
# supported_vvlib_versionがNoneの時は0.0.0として扱う
self.supported_vvlib_version = Version.parse("0.0.0")
self.engine_brand_name = brand_name
self.engine_name = engine_name
self.engine_uuid = engine_uuid
Expand Down
11 changes: 9 additions & 2 deletions voicevox_engine/engine_manifest/EngineManifest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# マルチエンジン環境下においては、エンジンのバージョンがエディタのバージョンより
# 古くなる可能性が十分に考えられる。その場合、エディタ側がEngineManifestの情報不足によって
# エラーを吐いて表示が崩壊する可能性がある。これを防止するため、EngineManifest関連の定義を
# 変更する際は、Optionalにする必要があることに留意しなければならない。

from typing import List, Optional

from pydantic import BaseModel, Field
Expand Down Expand Up @@ -37,7 +42,7 @@ class SupportedFeatures(BaseModel):
adjust_volume_scale: bool = Field(title="全体の音量の調整")
interrogative_upspeak: bool = Field(title="疑問文の自動調整")
synthesis_morphing: bool = Field(title="2人の話者でモーフィングした音声を合成")
manage_library: bool = Field(title="音声ライブラリのインストール・アンインストール")
manage_library: Optional[bool] = Field(title="音声ライブラリのインストール・アンインストール")


class EngineManifest(BaseModel):
Expand All @@ -55,5 +60,7 @@ class EngineManifest(BaseModel):
terms_of_service: str = Field(title="エンジンの利用規約")
update_infos: List[UpdateInfo] = Field(title="エンジンのアップデート情報")
dependency_licenses: List[LicenseInfo] = Field(title="依存関係のライセンス情報")
supported_vvlib_manifest_version: str = Field(title="エンジンが対応するvvlibのバージョン")
supported_vvlib_manifest_version: Optional[str] = Field(
title="エンジンが対応するvvlibのバージョン"
)
supported_features: SupportedFeatures = Field(title="エンジンが持つ機能")
6 changes: 4 additions & 2 deletions voicevox_engine/engine_manifest/EngineManifestLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def load_manifest(self) -> EngineManifest:
(self.root_dir / manifest["update_infos"]).read_text("utf-8")
)
],
supported_vvlib_manifest_version=manifest[
# supported_vvlib_manifest_versionを持たないengine_manifestのために
# キーが存在しない場合はNoneを返すgetを使う
supported_vvlib_manifest_version=manifest.get(
"supported_vvlib_manifest_version"
],
),
dependency_licenses=[
LicenseInfo(**license_info)
for license_info in json.loads(
Expand Down