diff --git a/crates/voicevox_core/src/metas.rs b/crates/voicevox_core/src/metas.rs index ae47e1803..78314d52a 100644 --- a/crates/voicevox_core/src/metas.rs +++ b/crates/voicevox_core/src/metas.rs @@ -2,20 +2,17 @@ use std::fmt::{Debug, Display}; use derive_getters::Getters; use derive_new::new; -use indexmap::{IndexMap, IndexSet}; +use indexmap::IndexMap; use itertools::Itertools as _; use serde::{Deserialize, Serialize}; use tracing::warn; /// [`speaker_uuid`]をキーとして複数の[`SpeakerMeta`]をマージする。 /// -/// マージする際話者は[`speaker_order`]、スタイルは[`style_order`]をもとに安定ソートされる。 -/// `speaker_order`が無い話者と`style_order`に属さないスタイルは、そうでないものよりも後ろに -/// 置かれる。 +/// マージする際話者は[`SpeakerMeta::order`]、スタイルは[`StyleMeta::order`]をもとに安定ソートされる。 +/// `order`が無い話者とスタイルは、そうでないものよりも後ろに置かれる。 /// /// [`speaker_uuid`]: SpeakerMeta::speaker_uuid -/// [`speaker_order`]: SpeakerMeta::speaker_order -/// [`style_order`]: SpeakerMeta::style_order pub fn merge<'a>(metas: impl IntoIterator) -> Vec { return metas .into_iter() @@ -27,14 +24,11 @@ pub fn merge<'a>(metas: impl IntoIterator) -> Vec) -> impl Ord { @@ -108,14 +102,7 @@ pub struct SpeakerMeta { /// 話者の順番。 /// /// `SpeakerMeta`の列は、この値に対して昇順に並んでいるべきである。 - speaker_order: Option, - /// 話者に属するスタイルの順番。 - /// - /// [`styles`]はこの並びに沿うべきである。 - /// - /// [`styles`]: Self::styles - #[serde(default)] - style_order: IndexSet, + order: Option, } impl SpeakerMeta { @@ -128,8 +115,7 @@ impl SpeakerMeta { styles: _, version: version1, speaker_uuid: speaker_uuid1, - speaker_order: speaker_order1, - style_order: style_order1, + order: order1, } = self; let Self { @@ -137,8 +123,7 @@ impl SpeakerMeta { styles: _, version: version2, speaker_uuid: speaker_uuid2, - speaker_order: speaker_order2, - style_order: style_order2, + order: order2, } = other; if speaker_uuid1 != speaker_uuid2 { @@ -147,13 +132,7 @@ impl SpeakerMeta { warn_diff(speaker_uuid1, "name", name1, name2); warn_diff(speaker_uuid1, "version", version1, version2); - warn_diff( - speaker_uuid1, - "speaker_order", - speaker_order1, - speaker_order2, - ); - warn_diff(speaker_uuid1, "style_order", style_order1, style_order2); + warn_diff(speaker_uuid1, "order", order1, order2); fn warn_diff( speaker_uuid: &str, @@ -175,6 +154,10 @@ pub struct StyleMeta { id: StyleId, /// スタイル名。 name: String, + /// スタイルの順番。 + /// + /// [`SpeakerMeta::styles`]は、この値に対して昇順に並んでいるべきである。 + order: Option, } #[cfg(test)] @@ -191,53 +174,44 @@ mod tests { "styles": [ { "id": 3, - "name": "B_1" + "name": "B_1", + "order": 0 } ], "version": "0.0.0", "speaker_uuid": "f34ab151-c0f5-4e0a-9ad2-51ce30dba24d", - "speaker_order": 1, - "style_order": [ - 3 - ] + "order": 1 }, { "name": "A", "styles": [ { "id": 2, - "name": "A_3" + "name": "A_3", + "order": 2 } ], "version": "0.0.0", "speaker_uuid": "d6fd707c-a451-48e9-8f00-fe9ee3bf6264", - "speaker_order": 0, - "style_order": [ - 1, - 0, - 2 - ] + "order": 0 }, { "name": "A", "styles": [ { "id": 1, - "name": "A_1" + "name": "A_1", + "order": 0 }, { "id": 0, - "name": "A_2" + "name": "A_2", + "order": 1 } ], "version": "0.0.0", "speaker_uuid": "d6fd707c-a451-48e9-8f00-fe9ee3bf6264", - "speaker_order": 0, - "style_order": [ - 1, - 0, - 2 - ] + "order": 0 } ]) }); @@ -249,46 +223,42 @@ mod tests { "styles": [ { "id": 1, - "name": "A_1" + "name": "A_1", + "order": 0 }, { "id": 0, - "name": "A_2" + "name": "A_2", + "order": 1 }, { "id": 2, - "name": "A_3" + "name": "A_3", + "order": 2 } ], "version": "0.0.0", "speaker_uuid": "d6fd707c-a451-48e9-8f00-fe9ee3bf6264", - "speaker_order": 0, - "style_order": [ - 1, - 0, - 2 - ] + "order": 0 }, { "name": "B", "styles": [ { "id": 3, - "name": "B_1" + "name": "B_1", + "order": 0 } ], "version": "0.0.0", "speaker_uuid": "f34ab151-c0f5-4e0a-9ad2-51ce30dba24d", - "speaker_order": 1, - "style_order": [ - 3 - ] + "order": 1 } ]) }); let input = &serde_json::from_value::>(INPUT.clone())?; - let actual = serde_json::to_value(&super::merge(input))?; + let actual = serde_json::to_value(super::merge(input))?; pretty_assertions::assert_eq!(*EXPECTED, actual); Ok(()) diff --git a/crates/voicevox_core_c_api/tests/e2e/snapshots.toml b/crates/voicevox_core_c_api/tests/e2e/snapshots.toml index d0e80f97f..25926487e 100644 --- a/crates/voicevox_core_c_api/tests/e2e/snapshots.toml +++ b/crates/voicevox_core_c_api/tests/e2e/snapshots.toml @@ -6,43 +6,44 @@ metas = ''' "styles": [ { "id": 0, - "name": "style1" + "name": "style1", + "order": null } ], "version": "0.0.1", "speaker_uuid": "574bc678-8370-44be-b941-08e46e7b47d7", - "speaker_order": null, - "style_order": [] + "order": null }, { "name": "dummy2", "styles": [ { "id": 1, - "name": "style2" + "name": "style2", + "order": null } ], "version": "0.0.1", "speaker_uuid": "dd9ccd75-75f6-40ce-a3db-960cbed2e905", - "speaker_order": null, - "style_order": [] + "order": null }, { "name": "dummy3", "styles": [ { "id": 302, - "name": "style3-1" + "name": "style3-1", + "order": null }, { "id": 303, - "name": "style3-2" + "name": "style3-2", + "order": null } ], "version": "0.0.1", "speaker_uuid": "5d3d9aa9-88e5-4a96-8ef7-f13a3cad1cb3", - "speaker_order": null, - "style_order": [] + "order": null } ]''' stderr.windows = ''' @@ -95,43 +96,44 @@ metas = ''' "styles": [ { "id": 0, - "name": "style1" + "name": "style1", + "order": null } ], "version": "0.0.1", "speaker_uuid": "574bc678-8370-44be-b941-08e46e7b47d7", - "speaker_order": null, - "style_order": [] + "order": null }, { "name": "dummy2", "styles": [ { "id": 1, - "name": "style2" + "name": "style2", + "order": null } ], "version": "0.0.1", "speaker_uuid": "dd9ccd75-75f6-40ce-a3db-960cbed2e905", - "speaker_order": null, - "style_order": [] + "order": null }, { "name": "dummy3", "styles": [ { "id": 302, - "name": "style3-1" + "name": "style3-1", + "order": null }, { "id": 303, - "name": "style3-2" + "name": "style3-2", + "order": null } ], "version": "0.0.1", "speaker_uuid": "5d3d9aa9-88e5-4a96-8ef7-f13a3cad1cb3", - "speaker_order": null, - "style_order": [] + "order": null } ]''' stderr.windows = ''' diff --git a/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/VoiceModel.java b/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/VoiceModel.java index 0e5715e09..ba4881566 100644 --- a/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/VoiceModel.java +++ b/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/VoiceModel.java @@ -5,7 +5,6 @@ import com.google.gson.annotations.SerializedName; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; -import java.util.LinkedHashSet; /** 音声モデル。 */ public class VoiceModel extends Dll { @@ -75,20 +74,10 @@ public static class SpeakerMeta { * *

{@code SpeakerMeta}の列は、この値に対して昇順に並んでいるべきである。 */ - @SerializedName("speaker_order") + @SerializedName("order") @Expose @Nullable - public final Integer speakerOrder; - - /** - * 話者に属するスタイルの順番。 - * - *

{@link #styles}はこの並びに沿うべきである。 - */ - @SerializedName("style_order") - @Expose - @Nonnull - public final LinkedHashSet styleOrder; + public final Integer order; private SpeakerMeta() { // GSONからコンストラクトするため、このメソッドは呼ばれることは無い。 @@ -97,8 +86,7 @@ private SpeakerMeta() { this.styles = new StyleMeta[0]; this.speakerUuid = ""; this.version = ""; - this.speakerOrder = null; - this.styleOrder = new LinkedHashSet<>(); + this.order = null; } } @@ -115,9 +103,20 @@ public static class StyleMeta { @Expose public final int id; + /** + * 話者の順番。 + * + *

{@link SpeakerMeta#styles}の列は、この値に対して昇順に並んでいるべきである。 + */ + @SerializedName("order") + @Expose + @Nullable + public final Integer order; + private StyleMeta() { this.name = ""; this.id = 0; + this.order = null; } } } diff --git a/crates/voicevox_core_python_api/python/voicevox_core/_models.py b/crates/voicevox_core_python_api/python/voicevox_core/_models.py index 9e11e8bd8..c72bbcbf0 100644 --- a/crates/voicevox_core_python_api/python/voicevox_core/_models.py +++ b/crates/voicevox_core_python_api/python/voicevox_core/_models.py @@ -1,6 +1,6 @@ import dataclasses from enum import Enum -from typing import Dict, List, NewType, Optional +from typing import List, NewType, Optional import pydantic @@ -44,6 +44,13 @@ class StyleMeta: id: StyleId """スタイルID。""" + order: Optional[int] = None + """ + 話者の順番。 + + :attr:`SpeakerMeta.styles` は、この値に対して昇順に並んでいるべきである。 + """ + @pydantic.dataclasses.dataclass class SpeakerMeta: @@ -61,20 +68,13 @@ class SpeakerMeta: version: StyleVersion """話者のUUID。""" - speaker_order: Optional[int] = None + order: Optional[int] = None """ 話者の順番。 ``SpeakerMeta`` の列は、この値に対して昇順に並んでいるべきである。 """ - style_order: List[StyleId] = dataclasses.field(default_factory=list) - """ - 話者に属するスタイルの順番。 - - :attr:`styles` はこの並びに沿うべきである。 - """ - @pydantic.dataclasses.dataclass class SupportedDevices: