Skip to content

Commit

Permalink
typo permited permitted (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
Segu-g authored Jan 19, 2023
1 parent c6f5174 commit 87136f4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"supported_features": { "permited_synthesis_morphing": "NOTHING" }
"supported_features": { "permitted_synthesis_morphing": "NOTHING" }
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"supported_features": { "permited_synthesis_morphing": "SELF_ONLY" }
"supported_features": { "permitted_synthesis_morphing": "SELF_ONLY" }
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"supported_features": { "permited_synthesis_morphing": "ALL" }
"supported_features": { "permitted_synthesis_morphing": "ALL" }
}
12 changes: 6 additions & 6 deletions voicevox_engine/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,25 @@ class SpeakerStyle(BaseModel):
id: int = Field(title="スタイルID")


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

@classmethod
def _missing_(cls, value: object) -> "SpeakerSupportPermitedSynthesisMorphing":
return SpeakerSupportPermitedSynthesisMorphing.ALL
def _missing_(cls, value: object) -> "SpeakerSupportPermittedSynthesisMorphing":
return SpeakerSupportPermittedSynthesisMorphing.ALL


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

permited_synthesis_morphing: Optional[
SpeakerSupportPermitedSynthesisMorphing
permitted_synthesis_morphing: Optional[
SpeakerSupportPermittedSynthesisMorphing
] = Field(
title="モーフィング機能への対応", default=SpeakerSupportPermitedSynthesisMorphing(None)
title="モーフィング機能への対応", default=SpeakerSupportPermittedSynthesisMorphing(None)
)


Expand Down
24 changes: 13 additions & 11 deletions voicevox_engine/morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .model import (
AudioQuery,
SpeakerNotFoundError,
SpeakerSupportPermitedSynthesisMorphing,
SpeakerSupportPermittedSynthesisMorphing,
)
from .synthesis_engine import SynthesisEngine

Expand Down Expand Up @@ -92,36 +92,38 @@ def is_synthesis_morphing_permitted(
)

# FIXME: 他にsupported_featuresができたら共通化する
base_speaker_morphing_info: SpeakerSupportPermitedSynthesisMorphing = (
base_speaker_morphing_info: SpeakerSupportPermittedSynthesisMorphing = (
base_speaker_engine_info.get("supported_features", dict()).get(
"permited_synthesis_morphing", SpeakerSupportPermitedSynthesisMorphing(None)
"permitted_synthesis_morphing",
SpeakerSupportPermittedSynthesisMorphing(None),
)
)

target_speaker_morphing_info: SpeakerSupportPermitedSynthesisMorphing = (
target_speaker_morphing_info: SpeakerSupportPermittedSynthesisMorphing = (
target_speaker_engine_info.get("supported_features", dict()).get(
"permited_synthesis_morphing", SpeakerSupportPermitedSynthesisMorphing(None)
"permitted_synthesis_morphing",
SpeakerSupportPermittedSynthesisMorphing(None),
)
)

# 禁止されている場合はFalse
if (
base_speaker_morphing_info == SpeakerSupportPermitedSynthesisMorphing.NOTHING
base_speaker_morphing_info == SpeakerSupportPermittedSynthesisMorphing.NOTHING
or target_speaker_morphing_info
== SpeakerSupportPermitedSynthesisMorphing.NOTHING
== SpeakerSupportPermittedSynthesisMorphing.NOTHING
):
return False
# 同一話者のみの場合は同一話者判定
if (
base_speaker_morphing_info == SpeakerSupportPermitedSynthesisMorphing.SELF_ONLY
base_speaker_morphing_info == SpeakerSupportPermittedSynthesisMorphing.SELF_ONLY
or target_speaker_morphing_info
== SpeakerSupportPermitedSynthesisMorphing.SELF_ONLY
== SpeakerSupportPermittedSynthesisMorphing.SELF_ONLY
):
return base_speaker_uuid == target_speaker_uuid
# 念のため許可されているかチェック
return (
base_speaker_morphing_info == SpeakerSupportPermitedSynthesisMorphing.ALL
and target_speaker_morphing_info == SpeakerSupportPermitedSynthesisMorphing.ALL
base_speaker_morphing_info == SpeakerSupportPermittedSynthesisMorphing.ALL
and target_speaker_morphing_info == SpeakerSupportPermittedSynthesisMorphing.ALL
)


Expand Down

0 comments on commit 87136f4

Please sign in to comment.