Skip to content

Commit

Permalink
feat: metasにsupported_featuresだけ追加
Browse files Browse the repository at this point in the history
Co-authored-by: Segu <[email protected]>
Co-authored-by: Hiroshiba <[email protected]>
  • Loading branch information
3 people committed Dec 21, 2024
1 parent bf7448d commit 1223a09
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 2 deletions.
49 changes: 49 additions & 0 deletions crates/voicevox_core/src/metas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ pub struct SpeakerMeta {
pub version: StyleVersion,
/// 話者のUUID。
pub speaker_uuid: String,
/// 話者の対応機能。
#[serde(default)]
pub supported_features: SpeakerSupportedFeatures,
/// 話者の順番。
///
/// `SpeakerMeta`の列は、この値に対して昇順に並んでいるべきである。
Expand All @@ -127,6 +130,7 @@ impl SpeakerMeta {
styles: _,
version: version1,
speaker_uuid: speaker_uuid1,
supported_features: supported_features1,
order: order1,
} = self;

Expand All @@ -135,6 +139,7 @@ impl SpeakerMeta {
styles: _,
version: version2,
speaker_uuid: speaker_uuid2,
supported_features: supported_features2,
order: order2,
} = other;

Expand All @@ -144,6 +149,12 @@ impl SpeakerMeta {

warn_diff(speaker_uuid1, "name", name1, name2);
warn_diff(speaker_uuid1, "version", version1, version2);
warn_diff(
speaker_uuid1,
"supported_features",
supported_features1,
supported_features2,
);
warn_diff(speaker_uuid1, "order", order1, order2);

fn warn_diff<T: PartialEq + Debug>(
Expand Down Expand Up @@ -207,6 +218,29 @@ pub enum StyleType {
Sing,
}

/// 話者の対応機能。
#[derive(Default, Deserialize, Serialize, Clone, PartialEq, Debug)]
pub struct SpeakerSupportedFeatures {
/// モーフィング機能への対応。
#[serde(default)]
pub permitted_synthesis_morphing: SpeakerSupportPermittedSynthesisMorphing,
}

/// モーフィング機能への対応。
#[derive(Deserialize, Serialize, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum SpeakerSupportPermittedSynthesisMorphing {
/// 全て許可。
All,

/// 同じ話者内でのみ許可。
SelfOnly,

/// 全て禁止。
#[default]
Nothing,
}

#[cfg(test)]
mod tests {
use std::sync::LazyLock;
Expand All @@ -229,6 +263,9 @@ mod tests {
],
"version": "0.0.0",
"speaker_uuid": "f34ab151-c0f5-4e0a-9ad2-51ce30dba24d",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
},
"order": 1
},
{
Expand All @@ -243,6 +280,9 @@ mod tests {
],
"version": "0.0.0",
"speaker_uuid": "d6fd707c-a451-48e9-8f00-fe9ee3bf6264",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
},
"order": 0
},
{
Expand All @@ -263,6 +303,9 @@ mod tests {
],
"version": "0.0.0",
"speaker_uuid": "d6fd707c-a451-48e9-8f00-fe9ee3bf6264",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
},
"order": 0
}
])
Expand Down Expand Up @@ -294,6 +337,9 @@ mod tests {
],
"version": "0.0.0",
"speaker_uuid": "d6fd707c-a451-48e9-8f00-fe9ee3bf6264",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
},
"order": 0
},
{
Expand All @@ -308,6 +354,9 @@ mod tests {
],
"version": "0.0.0",
"speaker_uuid": "f34ab151-c0f5-4e0a-9ad2-51ce30dba24d",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
},
"order": 1
}
])
Expand Down
24 changes: 24 additions & 0 deletions crates/voicevox_core_c_api/tests/e2e/snapshots.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "574bc678-8370-44be-b941-08e46e7b47d7",
"supported_features": {
"permitted_synthesis_morphing": "NOTHING"
},
"order": null
},
{
Expand All @@ -27,6 +30,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "dd9ccd75-75f6-40ce-a3db-960cbed2e905",
"supported_features": {
"permitted_synthesis_morphing": "ALL"
},
"order": null
},
{
Expand All @@ -47,6 +53,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "5d3d9aa9-88e5-4a96-8ef7-f13a3cad1cb3",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
},
"order": null
},
{
Expand All @@ -67,6 +76,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "32478dc2-4c8b-44f7-b041-c836e0df6d56",
"supported_features": {
"permitted_synthesis_morphing": "NOTHING"
},
"order": null
}
]'''
Expand Down Expand Up @@ -159,6 +171,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "574bc678-8370-44be-b941-08e46e7b47d7",
"supported_features": {
"permitted_synthesis_morphing": "NOTHING"
},
"order": null
},
{
Expand All @@ -173,6 +188,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "dd9ccd75-75f6-40ce-a3db-960cbed2e905",
"supported_features": {
"permitted_synthesis_morphing": "ALL"
},
"order": null
},
{
Expand All @@ -193,6 +211,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "5d3d9aa9-88e5-4a96-8ef7-f13a3cad1cb3",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
},
"order": null
},
{
Expand All @@ -213,6 +234,9 @@ metas = '''
],
"version": "0.0.1",
"speaker_uuid": "32478dc2-4c8b-44f7-b041-c836e0df6d56",
"supported_features": {
"permitted_synthesis_morphing": "NOTHING"
},
"order": null
}
]'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public class SpeakerMeta {
@Nonnull
public final String version;

/** 話者の対応機能。 */
@SerializedName("supported_features")
@Expose
@Nonnull
public final SpeakerSupportedFeatures supportedFeatures;

/**
* 話者の順番。
*
Expand All @@ -48,6 +54,7 @@ private SpeakerMeta() {
this.styles = new StyleMeta[0];
this.speakerUuid = "";
this.version = "";
this.supportedFeatures = new SpeakerSupportedFeatures();
this.order = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package jp.hiroshiba.voicevoxcore;

import com.google.gson.annotations.Expose;

/** モーフィング機能への対応。 */
public enum SpeakerSupportPermittedSynthesisMorphing {
/** 全て許可。 */
@Expose
ALL,

/** 同じ話者内でのみ許可。 */
@Expose
SELF_ONLY,

/** 全て禁止。 */
@Expose
NOTHING,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package jp.hiroshiba.voicevoxcore;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import jakarta.annotation.Nonnull;

/** 話者の対応機能。 */
public class SpeakerSupportedFeatures {
/** モーフィング機能への対応。 */
@SerializedName("permitted_synthesis_morphing")
@Expose
@Nonnull
SpeakerSupportPermittedSynthesisMorphing permittedSynthesisMorphing;

SpeakerSupportedFeatures() {
this.permittedSynthesisMorphing = SpeakerSupportPermittedSynthesisMorphing.NOTHING;
}
}
28 changes: 28 additions & 0 deletions crates/voicevox_core_python_api/python/voicevox_core/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ class StyleMeta:
"""


class SpeakerSupportPermittedSynthesisMorphing(str, Enum):
"""モーフィング機能への対応。"""

ALL = "ALL"
"""全て許可。"""

SELF_ONLY = "SELF_ONLY"
"""同じ話者内でのみ許可。"""

NOTHING = "NOTHING"
"""全て禁止。"""


@pydantic.dataclasses.dataclass
class SpeakerSupportedFeatures:
"""話者の対応機能。"""

permitted_synthesis_morphing: SpeakerSupportPermittedSynthesisMorphing = (
SpeakerSupportPermittedSynthesisMorphing.NOTHING
)
"""モーフィング機能への対応。"""


@pydantic.dataclasses.dataclass
class SpeakerMeta:
"""**話者** (*speaker*)のメタ情報。"""
Expand All @@ -88,6 +111,11 @@ class SpeakerMeta:
version: StyleVersion
"""話者のUUID。"""

supported_features: SpeakerSupportedFeatures = dataclasses.field(
default_factory=SpeakerSupportedFeatures,
)
"""話者の対応機能。"""

order: Optional[int] = None
"""
話者の順番。
Expand Down
10 changes: 8 additions & 2 deletions model/sample.vvm/metas.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
}
],
"speaker_uuid": "dd9ccd75-75f6-40ce-a3db-960cbed2e905",
"version": "0.0.1"
"version": "0.0.1",
"supported_features": {
"permitted_synthesis_morphing": "ALL"
}
},
{
"name": "dummy3",
Expand All @@ -34,7 +37,10 @@
}
],
"speaker_uuid": "5d3d9aa9-88e5-4a96-8ef7-f13a3cad1cb3",
"version": "0.0.1"
"version": "0.0.1",
"supported_features": {
"permitted_synthesis_morphing": "SELF_ONLY"
}
},
{
"name": "dummy4",
Expand Down

0 comments on commit 1223a09

Please sign in to comment.