Skip to content

Commit

Permalink
Add test for full-context label and text analyzer (#750)
Browse files Browse the repository at this point in the history
* add test for full-context label and text analyzer

* reduce number of lines by wrapping MoraModel::new

* rename `mora_model` to `mora`
  • Loading branch information
phenylshima authored Feb 23, 2024
1 parent f9d956d commit ce6297b
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ rayon = "1.6.1"
regex = "1.10.0"
reqwest = { version = "0.11.13", default-features = false }
rstest = "0.15.0"
rstest_reuse = "0.6.0"
serde = "1.0.145"
serde_json = "1.0.85"
serde_with = "3.3.0"
Expand Down
1 change: 1 addition & 0 deletions crates/voicevox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ zip.workspace = true
heck.workspace = true
pretty_assertions.workspace = true
rstest.workspace = true
rstest_reuse.workspace = true
test_util.workspace = true
tokio = { workspace = true, features = ["rt", "macros"] }

Expand Down
263 changes: 263 additions & 0 deletions crates/voicevox_core/src/engine/full_context_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,266 @@ impl Utterance {
})
}
}

#[cfg(test)]
mod tests {
use rstest_reuse::*;

use ::test_util::OPEN_JTALK_DIC_DIR;
use rstest::rstest;

use crate::{
engine::{open_jtalk::FullcontextExtractor, MoraModel},
text_analyzer::{OpenJTalkAnalyzer, TextAnalyzer},
AccentPhraseModel,
};

fn mora(text: &str, consonant: Option<&str>, vowel: &str) -> MoraModel {
MoraModel::new(
text.into(),
consonant.map(|c| c.into()),
consonant.and(Some(0.0)),
vowel.into(),
0.0,
0.0,
)
}

#[template]
#[rstest]
#[case(
"いぇ",
&[
"xx^xx-sil+y=e/A:xx+xx+xx/B:xx-xx_xx/C:xx_xx+xx/D:xx+xx_xx/E:xx_xx!xx_xx-xx/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mora("コ", Some("k"), "o"),
mora("レ", Some("r"), "e"),
mora("ワ", Some("w"), "a"),
],
3,
None,
false,
),
AccentPhraseModel::new(
vec![
mora("テ", Some("t"), "e"),
mora("ス", Some("s"), "U"),
mora("ト", Some("t"), "o"),
mora("デ", Some("d"), "e"),
mora("ス", Some("s"), "U"),
],
1,
None,
false,
),
]
)]
#[case(
"1、1000、100万、1億?",
&[
"xx^xx-sil+i=ch/A:xx+xx+xx/B:xx-xx_xx/C:xx_xx+xx/D:05+xx_xx/E:xx_xx!xx_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:2_2%0_xx_xx/H:xx_xx/I:xx-xx@xx+xx&xx-xx|xx+xx/J:1_2/K:4+4-12",
"xx^sil-i+ch=i/A:-1+1+2/B:xx-xx_xx/C:05_xx+xx/D:05+xx_xx/E:xx_xx!xx_xx-xx/F:2_2#0_xx@1_1|1_2/G:2_1%0_xx_0/H:xx_xx/I:1-2@1+4&1-4|1+12/J:1_2/K:4+4-12",
"sil^i-ch+i=pau/A:0+2+1/B:xx-xx_xx/C:05_xx+xx/D:05+xx_xx/E:xx_xx!xx_xx-xx/F:2_2#0_xx@1_1|1_2/G:2_1%0_xx_0/H:xx_xx/I:1-2@1+4&1-4|1+12/J:1_2/K:4+4-12",
"i^ch-i+pau=s/A:0+2+1/B:xx-xx_xx/C:05_xx+xx/D:05+xx_xx/E:xx_xx!xx_xx-xx/F:2_2#0_xx@1_1|1_2/G:2_1%0_xx_0/H:xx_xx/I:1-2@1+4&1-4|1+12/J:1_2/K:4+4-12",
"ch^i-pau+s=e/A:xx+xx+xx/B:05-xx_xx/C:xx_xx+xx/D:05+xx_xx/E:2_2!0_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:2_1%0_xx_xx/H:1_2/I:xx-xx@xx+xx&xx-xx|xx+xx/J:1_2/K:4+4-12",
"i^pau-s+e=N/A:0+1+2/B:05-xx_xx/C:05_xx+xx/D:05+xx_xx/E:2_2!0_xx-0/F:2_1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x+xx/D:xx+xx_xx/E:4_3!0_xx-0/F:4_2#1_xx@1_1|1_4/G:xx_xx%xx_xx_xx/H:1_4/I:1-4@4+1&4-1|9+4/J:xx_xx/K:4+4-12",
"i^o-k+u=sil/A:2+4+1/B:05-xx_xx/C:05_xx+xx/D:xx+xx_xx/E:4_3!0_xx-0/F:4_2#1_xx@1_1|1_4/G:xx_xx%xx_xx_xx/H:1_4/I:1-4@4+1&4-1|9+4/J:xx_xx/K:4+4-12",
"o^k-u+sil=xx/A:2+4+1/B:05-xx_xx/C:05_xx+xx/D:xx+xx_xx/E:4_3!0_xx-0/F:4_2#1_xx@1_1|1_4/G:xx_xx%xx_xx_xx/H:1_4/I:1-4@4+1&4-1|9+4/J:xx_xx/K:4+4-12",
"k^u-sil+xx=xx/A:xx+xx+xx/B:05-xx_xx/C:xx_xx+xx/D:xx+xx_xx/E:4_2!1_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:xx_xx%xx_xx_xx/H:1_4/I:xx-xx@xx+xx&xx-xx|xx+xx/J:xx_xx/K:4+4-12",
],
&[
AccentPhraseModel::new(
vec![
mora("イ", None, "i"),
mora("チ", Some("ch"), "i"),
],
2,
Some(mora("、", None, "pau")),
false,
),
AccentPhraseModel::new(
vec![
mora("セ", Some("s"), "e"),
mora("ン", None, "N"),
],
1,
Some(mora("、", None, "pau")),
false,
),
AccentPhraseModel::new(
vec![
mora("ヒャ", Some("hy"), "a"),
mora("ク", Some("k"), "u"),
mora("マ", Some("m"), "a"),
mora("ン", None, "N"),
],
3,
Some(mora("、", None, "pau")),
false,
),
AccentPhraseModel::new(
vec![
mora("イ", None, "i"),
mora("チ", Some("ch"), "i"),
mora("オ", None, "o"),
mora("ク", Some("k"), "u"),
],
2,
None,
true,
),
]
)]
#[case(
"クヮルテット。あーあ、。",
&[
"xx^xx-sil+kw=a/A:xx+xx+xx/B:xx-xx_xx/C:xx_xx+xx/D:02+xx_xx/E:xx_xx!xx_xx-xx/F:xx_xx#xx_xx@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x@xx+xx&xx-xx|xx+xx/J:xx_xx/K:2+3-8",
],
&[
AccentPhraseModel::new(
vec![
mora("クヮ", Some("kw"), "a"),
mora("ル", Some("r"), "u"),
mora("テ", Some("t"), "e"),
mora("ッ", None, "cl"),
mora("ト", Some("t"), "o"),
],
3,
Some(mora("、", None, "pau")),
false,
),
AccentPhraseModel::new(
vec![
mora("ア", None, "a"),
mora("ア", None, "a"),
],
1,
None,
false,
),
AccentPhraseModel::new(
vec![mora("ア", None, "a")],
1,
None,
false,
),
]
)]
fn label_cases(
#[case] text: &str,
#[case] labels: &[&str],
#[case] accent_phrase: &[AccentPhraseModel],
) {
}

#[apply(label_cases)]
#[tokio::test]
async fn open_jtalk(text: &str, labels: &[&str], _accent_phrase: &[AccentPhraseModel]) {
let open_jtalk = crate::tokio::OpenJtalk::new(OPEN_JTALK_DIC_DIR)
.await
.unwrap();
assert_eq!(&open_jtalk.extract_fullcontext(text).unwrap(), labels);
}

#[apply(label_cases)]
#[tokio::test]
async fn extract_fullcontext(
text: &str,
_labels: &[&str],
accent_phrase: &[AccentPhraseModel],
) {
let open_jtalk = crate::tokio::OpenJtalk::new(OPEN_JTALK_DIC_DIR)
.await
.unwrap();
let analyzer = OpenJTalkAnalyzer::new(open_jtalk);
assert_eq!(analyzer.analyze(text).unwrap(), accent_phrase);
}
}
4 changes: 2 additions & 2 deletions crates/voicevox_core/src/engine/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
/* 各フィールドのjsonフィールド名はsnake_caseとする*/

/// モーラ(子音+母音)ごとの情報。
#[derive(Clone, Debug, new, Getters, Deserialize, Serialize)]
#[derive(Clone, Debug, new, Getters, Deserialize, Serialize, PartialEq)]
pub struct MoraModel {
/// 文字。
text: String,
Expand All @@ -22,7 +22,7 @@ pub struct MoraModel {
}

/// AccentPhrase (アクセント句ごとの情報)。
#[derive(Clone, Debug, new, Getters, Deserialize, Serialize)]
#[derive(Clone, Debug, new, Getters, Deserialize, Serialize, PartialEq)]
pub struct AccentPhraseModel {
/// モーラの配列。
moras: Vec<MoraModel>,
Expand Down
5 changes: 5 additions & 0 deletions crates/voicevox_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ pub mod tokio;
#[cfg(test)]
mod test_util;

// https://crates.io/crates/rstest_reuse#use-rstest_resuse-at-the-top-of-your-crate
#[allow(clippy::single_component_path_imports)]
#[cfg(test)]
use rstest_reuse;

pub use self::{
devices::SupportedDevices,
engine::{AccentPhraseModel, AudioQueryModel, FullcontextExtractor},
Expand Down

0 comments on commit ce6297b

Please sign in to comment.