Skip to content

Commit

Permalink
整理: モーフィング許可を Enum から Literal へ変更 (VOICEVOX#1413)
Browse files Browse the repository at this point in the history
* refactor: モーフィング許可を Enum から Literal へ変更

* add: `permitted_synthesis_morphing` に `description` を追加

* fix: スナップショットを更新
  • Loading branch information
tarepan authored Jun 23, 2024
1 parent 066dcf0 commit 3c30f30
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions voicevox_engine/metas/Metas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""話者情報と話者メタ情報"""

from enum import Enum
from typing import Literal, NewType

from pydantic import BaseModel, Field
Expand Down Expand Up @@ -31,20 +30,15 @@ class SpeakerStyle(BaseModel):
)


class SpeakerSupportPermittedSynthesisMorphing(str, Enum):
ALL = "ALL" # 全て許可
SELF_ONLY = "SELF_ONLY" # 同じ話者内でのみ許可
NOTHING = "NOTHING" # 全て禁止


class SpeakerSupportedFeatures(BaseModel):
"""
話者の対応機能の情報
"""

permitted_synthesis_morphing: SpeakerSupportPermittedSynthesisMorphing = Field(
permitted_synthesis_morphing: Literal["ALL", "SELF_ONLY", "NOTHING"] = Field(
title="モーフィング機能への対応",
default=SpeakerSupportPermittedSynthesisMorphing.ALL,
description="'ALL' は「全て許可」、'SELF_ONLY' は「同じ話者内でのみ許可」、'NOTHING' は「全て禁止」",
default="ALL",
)


Expand Down
15 changes: 6 additions & 9 deletions voicevox_engine/morphing/morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from voicevox_engine.morphing.model import MorphableTargetInfo

from ..core.core_adapter import CoreAdapter
from ..metas.Metas import Speaker, SpeakerSupportPermittedSynthesisMorphing, StyleId
from ..metas.Metas import Speaker, StyleId
from ..model import AudioQuery
from ..tts_pipeline.tts_engine import TTSEngine

Expand Down Expand Up @@ -82,21 +82,18 @@ def is_morphable(
morphable_2 = character_2.supported_features.permitted_synthesis_morphing

# 禁止されている場合はFalse
if morphable_1 == SpeakerSupportPermittedSynthesisMorphing.NOTHING:
if morphable_1 == "NOTHING":
return False
elif morphable_2 == SpeakerSupportPermittedSynthesisMorphing.NOTHING:
elif morphable_2 == "NOTHING":
return False
# 同一話者のみの場合は同一話者判定
elif morphable_1 == SpeakerSupportPermittedSynthesisMorphing.SELF_ONLY:
elif morphable_1 == "SELF_ONLY":
return uuid_1 == uuid_2
elif morphable_2 == SpeakerSupportPermittedSynthesisMorphing.SELF_ONLY:
elif morphable_2 == "SELF_ONLY":
return uuid_1 == uuid_2

# 念のため許可されているかチェック
return (
morphable_1 == SpeakerSupportPermittedSynthesisMorphing.ALL
and morphable_2 == SpeakerSupportPermittedSynthesisMorphing.ALL
)
return morphable_1 == "ALL" and morphable_2 == "ALL"


def synthesis_morphing_parameter(
Expand Down

0 comments on commit 3c30f30

Please sign in to comment.