整理: モーフィング許可を Enum から Literal へ変更 #1413
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
内容
概要: モーフィング許可を Enum から Literal へ変更してリファクタリング
現在の ENGINE はモーフィング許可を
SpeakerSupportPermittedSynthesisMorphing(str, Enum)
型で表現している。この Enum は literal と同じ役割のみをしており、literal での置き換えが可能である。literal はより単機能・単純であり、置き換えれば Enum の振る舞いを理解するコストを不要にできる。現在も Enum を使っているのは恐らく Python の言語機能や型推論が貧弱だった頃の名残である。
SpeakerSupportPermittedSynthesisMorphing
クラスを定義しているため、OpenAPI schema にもこのクラスが含まれている。#1411 で整理された通り、クラス名変更でも配慮が必要である。VOICEVOX editor を確認した限り、
SpeakerSupportPermittedSynthesisMorphing
の literal 化は人によって書かれたコードへ影響しない模様である。自動生成部に変更は発生する。このような背景から、モーフィング許可を Enum から Literal へ変更するリファクタリングを提案します。
スクリーンショット・動画など
description
を追加したため、ドキュメントが充実しています。関連 Issue
無し