Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project-s] project-s用のテストを作成(モデルがないのでコメントアウト中) #734

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions crates/voicevox_core/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,114 @@ mod tests {
assert_eq!(result.unwrap().len(), F0_LENGTH * 256);
}

// #[rstest]
// fn predict_sing_f0_works() {
// let internal = VoicevoxCore::new_with_mutex();
// internal
// .lock()
// .unwrap()
// .initialize(InitializeOptions {
// load_all_models: true,
// acceleration_mode: AccelerationMode::Cpu,
// ..Default::default()
// })
// .unwrap();

// // 「テスト」という文章に対応する入力
// let phoneme_vector = [0, 37, 14, 35, 6, 37, 30, 0];
// let note_vector = [0, 30, 30, 40, 40, 50, 50, 0];

// let sing_teacher_speaker_id = 6000;
// let result = internal.lock().unwrap().predict_sing_f0(
// &phoneme_vector,
// &note_vector,
// sing_teacher_speaker_id,
// );

// assert!(result.is_ok(), "{result:?}");
// assert_eq!(result.unwrap().len(), phoneme_vector.len());
// }

// #[rstest]
// fn predict_sing_volume_works() {
// let internal = VoicevoxCore::new_with_mutex();
// internal
// .lock()
// .unwrap()
// .initialize(InitializeOptions {
// load_all_models: true,
// acceleration_mode: AccelerationMode::Cpu,
// ..Default::default()
// })
// .unwrap();

// // 「テスト」という文章に対応する入力
// let phoneme_vector = [0, 37, 14, 35, 6, 37, 30, 0];
// let note_vector = [0, 30, 30, 40, 40, 50, 50, 0];
// let f0_vector = [0., 5.905218, 5.905218, 0., 0., 5.565851, 5.565851, 0.];

// let sing_teacher_speaker_id = 6000;
// let result = internal.lock().unwrap().predict_sing_volume(
// &phoneme_vector,
// &note_vector,
// &f0_vector,
// sing_teacher_speaker_id,
// );

// assert!(result.is_ok(), "{result:?}");
// assert_eq!(result.unwrap().len(), phoneme_vector.len());
// }

// #[rstest]
// fn sf_decode_works() {
// let internal = VoicevoxCore::new_with_mutex();
// internal
// .lock()
// .unwrap()
// .initialize(InitializeOptions {
// acceleration_mode: AccelerationMode::Cpu,
// load_all_models: true,
// ..Default::default()
// })
// .unwrap();

// // 「テスト」という文章に対応する入力
// const F0_LENGTH: usize = 69;
// let mut f0 = [0.; F0_LENGTH];
// f0[9..24].fill(5.905218);
// f0[37..60].fill(5.565851);

// let mut volume = [0.; F0_LENGTH];
// volume[9..24].fill(0.5);
// volume[24..37].fill(0.2);
// volume[37..60].fill(1.0);

// let mut phoneme = [0; F0_LENGTH];
// let mut set_one = |index, range| {
// for i in range {
// phoneme[i] = index;
// }
// };
// set_one(0, 0..9);
// set_one(37, 9..13);
// set_one(14, 13..24);
// set_one(35, 24..30);
// set_one(6, 30..37);
// set_one(37, 37..45);
// set_one(30, 45..60);
// set_one(0, 60..69);

// let sf_decoder_speaker_id = 3000;
// let result =
// internal
// .lock()
// .unwrap()
// .sf_decode(&phoneme, &f0, &volume, sf_decoder_speaker_id);

// assert!(result.is_ok(), "{result:?}");
// assert_eq!(result.unwrap().len(), F0_LENGTH * 256);
// }

type TextConsonantVowelData =
[(&'static [(&'static str, &'static str, &'static str)], usize)];

Expand Down
2 changes: 1 addition & 1 deletion crates/voicevox_core/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ mod tests {
let mut status = Status::new(true, 0);
let result = status.load_metas();
assert_debug_fmt_eq!(Ok(()), result);
let expected = BTreeSet::from([0, 1, 2, 3]);
let expected = BTreeSet::from([0, 1, 2, 3, 3000, 6000]);
assert_eq!(expected, status.supported_styles);
}

Expand Down
8 changes: 6 additions & 2 deletions crates/voicevox_core/src/status/model_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ pub(super) const TALK_MODEL_FILE_NAMES: &[TalkModelFileNames] = &[TalkModelFileN
}];

// TODO: 変更する
pub(super) const SING_TEACHER_SPEAKER_ID_MAP: &[(u32, (usize, u32))] = &[(0, (0, 0)), (1, (0, 1))];
pub(super) const SING_TEACHER_SPEAKER_ID_MAP: &[(u32, (usize, u32))] = &[(6000, (0, 0))];

pub(super) const SING_TEACHER_MODEL_FILE_NAMES: &[SingTeacherModelFileNames] =
&[SingTeacherModelFileNames {
predict_sing_consonant_length_model: "predict_duration-1.onnx",
predict_sing_f0_model: "predict_intonation-1.onnx",
predict_sing_volume_model: "predict_intonation-1.onnx",
// predict_sing_consonant_length_model: "predict_sing_consonant_length-0.onnx",
// predict_sing_f0_model: "predict_sing_f0-0.onnx",
// predict_sing_volume_model: "predict_sing_volume-0.onnx",
}];

pub(super) const SF_DECODE_SPEAKER_ID_MAP: &[(u32, (usize, u32))] = &[(0, (0, 0)), (1, (0, 1))];
pub(super) const SF_DECODE_SPEAKER_ID_MAP: &[(u32, (usize, u32))] = &[(3000, (0, 0))];

pub(super) const SF_DECODE_MODEL_FILE_NAMES: &[SfDecodeModelFileNames] =
&[SfDecodeModelFileNames {
sf_decode_model: "decode-1.onnx",
// sf_decode_model: "sf_decoder-0.onnx",
}];
9 changes: 9 additions & 0 deletions model/metas.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,14 @@
],
"speaker_uuid": "5d3d9aa9-88e5-4a96-8ef7-f13a3cad1cb3",
"version": "0.0.1"
},
{
"name": "dummy4",
"styles": [
{ "name": "style4-1", "id": 3000, "type": "sf_decoder" },
{ "name": "style4-2", "id": 6000, "type": "sing_teacher" }
],
"speaker_uuid": "32478dc2-4c8b-44f7-b041-c836e0df6d56",
"version": "0.0.1"
}
]
Loading