Skip to content

Commit

Permalink
<[[T; N]]>::as_flattened
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Aug 11, 2024
1 parent c195675 commit 21c23a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions crates/voicevox_core/src/engine/acoustic_feature_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ pub(crate) struct OjtPhoneme {
}

impl OjtPhoneme {
pub(crate) fn num_phoneme() -> usize {
PHONEME_MAP.len()
pub(crate) const fn num_phoneme() -> usize {
PHONEME_LIST.len() // == PHONEME_MAP.len()
}

fn space_phoneme() -> String {
Expand Down
9 changes: 3 additions & 6 deletions crates/voicevox_core/src/synthesizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ pub(crate) mod blocking {

let (_, _, vowel_indexes) = split_mora(&phoneme_data_list);

let mut phoneme: Vec<Vec<f32>> = Vec::new();
let mut phoneme = Vec::new();
let mut f0: Vec<f32> = Vec::new();
{
const RATE: f32 = 24000. / 256.;
Expand All @@ -335,7 +335,7 @@ pub(crate) mod blocking {
let phoneme_id = phoneme_data_list[i].phoneme_id();

for _ in 0..phoneme_length {
let mut phonemes_vec = vec![0.; OjtPhoneme::num_phoneme()];
let mut phonemes_vec = [0.; OjtPhoneme::num_phoneme()];
phonemes_vec[phoneme_id as usize] = 1.;
phoneme.push(phonemes_vec)
}
Expand All @@ -352,14 +352,11 @@ pub(crate) mod blocking {
}
}

// 2次元のvectorを1次元に変換し、アドレスを連続させる
let flatten_phoneme = phoneme.into_iter().flatten().collect::<Vec<_>>();

let wave = &self.decode(
f0.len(),
OjtPhoneme::num_phoneme(),
&f0,
&flatten_phoneme,
phoneme.as_flattened(),
style_id,
)?;
return Ok(to_wav(wave, audio_query));
Expand Down

0 comments on commit 21c23a5

Please sign in to comment.