From b41e6216b7a642679db13ef655283da0bbd6b5fa Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 6 Jul 2024 21:57:09 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20Rust=20API=E3=81=AEAudioQuery?= =?UTF-8?q?=E7=B3=BB=E3=81=AE=E5=9E=8B=E5=90=8D=E3=81=8B=E3=82=89=E6=8E=A5?= =?UTF-8?q?=E5=B0=BE=E8=BE=9E"Model"=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/engine/full_context_label.rs | 64 +++++---- .../voicevox_core/src/engine/kana_parser.rs | 25 ++-- crates/voicevox_core/src/engine/mod.rs | 2 +- crates/voicevox_core/src/engine/model.rs | 24 ++-- crates/voicevox_core/src/lib.rs | 2 +- crates/voicevox_core/src/synthesizer.rs | 121 +++++++++--------- crates/voicevox_core/src/text_analyzer.rs | 8 +- crates/voicevox_core_c_api/src/helpers.rs | 8 +- crates/voicevox_core_c_api/src/lib.rs | 10 +- .../voicevox_core_java_api/src/synthesizer.rs | 8 +- .../voicevox_core_python_api/src/convert.rs | 17 +-- crates/voicevox_core_python_api/src/lib.rs | 12 +- 12 files changed, 140 insertions(+), 161 deletions(-) diff --git a/crates/voicevox_core/src/engine/full_context_label.rs b/crates/voicevox_core/src/engine/full_context_label.rs index 8b87048e5..4f95abbf2 100644 --- a/crates/voicevox_core/src/engine/full_context_label.rs +++ b/crates/voicevox_core/src/engine/full_context_label.rs @@ -1,10 +1,10 @@ use std::str::FromStr; use crate::{ - engine::{self, open_jtalk::FullcontextExtractor, MoraModel}, - AccentPhraseModel, + engine::{self, open_jtalk::FullcontextExtractor}, + AccentPhrase, }; -use jlabel::{Label, Mora}; +use jlabel::Label; use smallvec::SmallVec; // FIXME: 入力テキストをここで持って、メッセージに含む @@ -33,7 +33,7 @@ type Result = std::result::Result; pub(crate) fn extract_full_context_label( open_jtalk: &impl FullcontextExtractor, text: impl AsRef, -) -> Result> { +) -> Result> { let labels = open_jtalk .extract_fullcontext(text.as_ref()) .map_err(|source| FullContextLabelError { @@ -58,7 +58,7 @@ pub(crate) fn extract_full_context_label( fn generate_accent_phrases( utterance: &[Label], -) -> std::result::Result, ErrorKind> { +) -> std::result::Result, ErrorKind> { let mut accent_phrases = Vec::with_capacity( utterance .first() @@ -88,7 +88,7 @@ fn generate_accent_phrases( let pause_mora = if ap_curr.accent_phrase_position_backward == 1 && bg_curr.breath_group_position_backward != 1 { - Some(MoraModel::new( + Some(crate::Mora::new( "、".into(), None, None, @@ -103,7 +103,7 @@ fn generate_accent_phrases( // workaround for VOICEVOX/voicevox_engine#55 let accent = usize::from(ap_curr.accent_position).min(moras.len()); - accent_phrases.push(AccentPhraseModel::new( + accent_phrases.push(AccentPhrase::new( moras, accent, pause_mora, @@ -113,7 +113,7 @@ fn generate_accent_phrases( Ok(accent_phrases) } -fn generate_moras(accent_phrase: &[Label]) -> std::result::Result, ErrorKind> { +fn generate_moras(accent_phrase: &[Label]) -> std::result::Result, ErrorKind> { let mut moras = Vec::with_capacity(accent_phrase.len()); let split = accent_phrase.chunk_by(|a, b| a.mora == b.mora); @@ -136,7 +136,7 @@ fn generate_moras(accent_phrase: &[Label]) -> std::result::Result // position_forwardとposition_backwardが飽和している場合は無視する [Label { mora: - Some(Mora { + Some(jlabel::Mora { position_forward: 49, position_backward: 49, .. @@ -151,10 +151,10 @@ fn generate_moras(accent_phrase: &[Label]) -> std::result::Result Ok(moras) } -fn generate_mora(consonant: Option<&Label>, vowel: &Label) -> MoraModel { +fn generate_mora(consonant: Option<&Label>, vowel: &Label) -> crate::Mora { let consonant_phoneme = consonant.and_then(|c| c.phoneme.c.to_owned()); let vowel_phoneme = vowel.phoneme.c.as_deref().unwrap(); - MoraModel::new( + crate::Mora::new( mora_to_text(consonant_phoneme.as_deref(), vowel_phoneme), consonant_phoneme, consonant.and(Some(0.0)), @@ -190,14 +190,14 @@ mod tests { engine::{ full_context_label::{extract_full_context_label, generate_accent_phrases}, open_jtalk::FullcontextExtractor, - MoraModel, + Mora, }, - AccentPhraseModel, + AccentPhrase, }; use jlabel::Label; - fn mora(text: &str, consonant: Option<&str>, vowel: &str) -> MoraModel { - MoraModel::new( + fn mora(text: &str, consonant: Option<&str>, vowel: &str) -> Mora { + Mora::new( text.into(), consonant.map(|c| c.into()), consonant.and(Some(0.0)), @@ -218,7 +218,7 @@ mod tests { "y^e-sil+xx=xx/A:xx+xx+xx/B:xx-xx_xx/C:xx_xx+xx/D:xx+xx_xx/E:1_1!0_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:xx_xx%xx_xx_xx/H:1_1/I:xx-xx@xx+xx&xx-xx|xx+xx/J:xx_xx/K:1+1-1", ], &[ - AccentPhraseModel::new( + AccentPhrase::new( vec![mora("イェ", Some("y"), "e")], 1, None, @@ -236,7 +236,7 @@ mod tests { "N^cl-sil+xx=xx/A:xx+xx+xx/B:09-xx_xx/C:xx_xx+xx/D:xx+xx_xx/E:3_3!0_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:xx_xx%xx_xx_xx/H:1_3/I:xx-xx@xx+xx&xx-xx|xx+xx/J:xx_xx/K:1+1-3", ], &[ - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("ン", None, "N"), mora("ン", None, "N"), @@ -271,7 +271,7 @@ mod tests { "s^U-sil+xx=xx/A:xx+xx+xx/B:10-7_2/C:xx_xx+xx/D:xx+xx_xx/E:5_1!0_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:xx_xx%xx_xx_xx/H:2_8/I:xx-xx@xx+xx&xx-xx|xx+xx/J:xx_xx/K:1+2-8", ], &[ - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("コ", Some("k"), "o"), mora("レ", Some("r"), "e"), @@ -281,7 +281,7 @@ mod tests { None, false, ), - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("テ", Some("t"), "e"), mora("ス", Some("s"), "U"), @@ -324,7 +324,7 @@ mod tests { "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( + AccentPhrase::new( vec![ mora("イ", None, "i"), mora("チ", Some("ch"), "i"), @@ -333,7 +333,7 @@ mod tests { Some(mora("、", None, "pau")), false, ), - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("セ", Some("s"), "e"), mora("ン", None, "N"), @@ -342,7 +342,7 @@ mod tests { Some(mora("、", None, "pau")), false, ), - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("ヒャ", Some("hy"), "a"), mora("ク", Some("k"), "u"), @@ -353,7 +353,7 @@ mod tests { Some(mora("、", None, "pau")), false, ), - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("イ", None, "i"), mora("チ", Some("ch"), "i"), @@ -386,7 +386,7 @@ mod tests { "a^a-sil+xx=xx/A:xx+xx+xx/B:09-xx_xx/C:xx_xx+xx/D:xx+xx_xx/E:1_1!0_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:xx_xx%xx_xx_xx/H:2_3/I:xx-xx@xx+xx&xx-xx|xx+xx/J:xx_xx/K:2+3-8", ], &[ - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("クヮ", Some("kw"), "a"), mora("ル", Some("r"), "u"), @@ -398,7 +398,7 @@ mod tests { Some(mora("、", None, "pau")), false, ), - AccentPhraseModel::new( + AccentPhrase::new( vec![ mora("ア", None, "a"), mora("ア", None, "a"), @@ -407,7 +407,7 @@ mod tests { None, false, ), - AccentPhraseModel::new( + AccentPhrase::new( vec![mora("ア", None, "a")], 1, None, @@ -418,13 +418,13 @@ mod tests { fn label_cases( #[case] text: &str, #[case] labels: &[&str], - #[case] accent_phrase: &[AccentPhraseModel], + #[case] accent_phrase: &[AccentPhrase], ) { } #[apply(label_cases)] #[tokio::test] - async fn open_jtalk(text: &str, labels: &[&str], _accent_phrase: &[AccentPhraseModel]) { + async fn open_jtalk(text: &str, labels: &[&str], _accent_phrase: &[AccentPhrase]) { let open_jtalk = crate::tokio::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(); @@ -432,7 +432,7 @@ mod tests { } #[apply(label_cases)] - fn parse_labels(_text: &str, labels: &[&str], accent_phrase: &[AccentPhraseModel]) { + fn parse_labels(_text: &str, labels: &[&str], accent_phrase: &[AccentPhrase]) { let parsed_labels = labels .iter() .map(|s| Label::from_str(s).unwrap()) @@ -446,11 +446,7 @@ mod tests { #[apply(label_cases)] #[tokio::test] - async fn extract_fullcontext( - text: &str, - _labels: &[&str], - accent_phrase: &[AccentPhraseModel], - ) { + async fn extract_fullcontext(text: &str, _labels: &[&str], accent_phrase: &[AccentPhrase]) { let open_jtalk = crate::tokio::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(); diff --git a/crates/voicevox_core/src/engine/kana_parser.rs b/crates/voicevox_core/src/engine/kana_parser.rs index eaa3d93c1..42f17dc63 100644 --- a/crates/voicevox_core/src/engine/kana_parser.rs +++ b/crates/voicevox_core/src/engine/kana_parser.rs @@ -1,4 +1,4 @@ -use crate::engine::model::{AccentPhraseModel, MoraModel}; +use crate::engine::model::{AccentPhrase, Mora}; use crate::engine::mora_list::MORA_LIST_MINIMUM; use once_cell::sync::Lazy; use std::collections::HashMap; @@ -16,7 +16,7 @@ pub(crate) struct KanaParseError(String); type KanaParseResult = std::result::Result; -static TEXT2MORA_WITH_UNVOICE: Lazy> = Lazy::new(|| { +static TEXT2MORA_WITH_UNVOICE: Lazy> = Lazy::new(|| { let mut text2mora_with_unvoice = HashMap::new(); for [text, consonant, vowel] in MORA_LIST_MINIMUM { let consonant = if !consonant.is_empty() { @@ -28,7 +28,7 @@ static TEXT2MORA_WITH_UNVOICE: Lazy> = Lazy::new(|| { if ["a", "i", "u", "e", "o"].contains(vowel) { let upper_vowel = vowel.to_uppercase(); - let unvoice_mora = MoraModel::new( + let unvoice_mora = Mora::new( text.to_string(), consonant.clone(), consonant_length, @@ -39,7 +39,7 @@ static TEXT2MORA_WITH_UNVOICE: Lazy> = Lazy::new(|| { text2mora_with_unvoice.insert(UNVOICE_SYMBOL.to_string() + text, unvoice_mora); } - let mora = MoraModel::new( + let mora = Mora::new( text.to_string(), consonant, consonant_length, @@ -52,10 +52,10 @@ static TEXT2MORA_WITH_UNVOICE: Lazy> = Lazy::new(|| { text2mora_with_unvoice }); -fn text_to_accent_phrase(phrase: &str) -> KanaParseResult { +fn text_to_accent_phrase(phrase: &str) -> KanaParseResult { let phrase_vec: Vec = phrase.chars().collect(); let mut accent_index: Option = None; - let mut moras: Vec = Vec::new(); + let mut moras: Vec = Vec::new(); let mut stack = String::new(); let mut matched_text: Option = None; let text2mora = &TEXT2MORA_WITH_UNVOICE; @@ -107,15 +107,10 @@ fn text_to_accent_phrase(phrase: &str) -> KanaParseResult { "accent not found in accent phrase: {phrase}" ))); } - Ok(AccentPhraseModel::new( - moras, - accent_index.unwrap(), - None, - false, - )) + Ok(AccentPhrase::new(moras, accent_index.unwrap(), None, false)) } -pub(crate) fn parse_kana(text: &str) -> KanaParseResult> { +pub(crate) fn parse_kana(text: &str) -> KanaParseResult> { const TERMINATOR: char = '\0'; let mut parsed_result = Vec::new(); let chars_of_text = text.chars().chain([TERMINATOR]); @@ -142,7 +137,7 @@ pub(crate) fn parse_kana(text: &str) -> KanaParseResult> let accent_phrase = { let mut accent_phrase = text_to_accent_phrase(&phrase)?; if letter == PAUSE_DELIMITER { - accent_phrase.set_pause_mora(Some(MoraModel::new( + accent_phrase.set_pause_mora(Some(Mora::new( PAUSE_DELIMITER.to_string(), None, None, @@ -163,7 +158,7 @@ pub(crate) fn parse_kana(text: &str) -> KanaParseResult> Ok(parsed_result) } -pub(crate) fn create_kana(accent_phrases: &[AccentPhraseModel]) -> String { +pub(crate) fn create_kana(accent_phrases: &[AccentPhrase]) -> String { let mut text = String::new(); for phrase in accent_phrases { let moras = phrase.moras(); diff --git a/crates/voicevox_core/src/engine/mod.rs b/crates/voicevox_core/src/engine/mod.rs index 95fe3d562..d446a7253 100644 --- a/crates/voicevox_core/src/engine/mod.rs +++ b/crates/voicevox_core/src/engine/mod.rs @@ -10,6 +10,6 @@ pub(crate) use self::full_context_label::{ extract_full_context_label, mora_to_text, FullContextLabelError, }; pub(crate) use self::kana_parser::{create_kana, parse_kana, KanaParseError}; -pub use self::model::{AccentPhraseModel, AudioQueryModel, MoraModel}; +pub use self::model::{AccentPhrase, AudioQuery, Mora}; pub(crate) use self::mora_list::mora2text; pub use self::open_jtalk::FullcontextExtractor; diff --git a/crates/voicevox_core/src/engine/model.rs b/crates/voicevox_core/src/engine/model.rs index de0f388f9..09f53b6ee 100644 --- a/crates/voicevox_core/src/engine/model.rs +++ b/crates/voicevox_core/src/engine/model.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; /// モーラ(子音+母音)ごとの情報。 #[derive(Clone, Debug, new, Getters, Deserialize, Serialize, PartialEq)] -pub struct MoraModel { +pub struct Mora { /// 文字。 text: String, /// 子音の音素。 @@ -23,20 +23,20 @@ pub struct MoraModel { /// AccentPhrase (アクセント句ごとの情報)。 #[derive(Clone, Debug, new, Getters, Deserialize, Serialize, PartialEq)] -pub struct AccentPhraseModel { +pub struct AccentPhrase { /// モーラの配列。 - moras: Vec, + moras: Vec, /// アクセント箇所。 accent: usize, /// 後ろに無音を付けるかどうか。 - pause_mora: Option, + pause_mora: Option, /// 疑問系かどうか。 #[serde(default)] is_interrogative: bool, } -impl AccentPhraseModel { - pub(super) fn set_pause_mora(&mut self, pause_mora: Option) { +impl AccentPhrase { + pub(super) fn set_pause_mora(&mut self, pause_mora: Option) { self.pause_mora = pause_mora; } @@ -48,9 +48,9 @@ impl AccentPhraseModel { /// AudioQuery (音声合成用のクエリ)。 #[allow(clippy::too_many_arguments)] #[derive(Clone, new, Getters, Deserialize, Serialize)] -pub struct AudioQueryModel { +pub struct AudioQuery { /// アクセント句の配列。 - accent_phrases: Vec, + accent_phrases: Vec, /// 全体の話速。 speed_scale: f32, /// 全体の音高。 @@ -76,7 +76,7 @@ pub struct AudioQueryModel { kana: Option, } -impl AudioQueryModel { +impl AudioQuery { pub(crate) fn with_kana(self, kana: Option) -> Self { Self { kana, ..self } } @@ -88,12 +88,12 @@ mod tests { use rstest::rstest; use serde_json::json; - use super::AudioQueryModel; + use super::AudioQuery; #[rstest] fn check_audio_query_model_json_field_snake_case() { let audio_query_model = - AudioQueryModel::new(vec![], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, false, None); + AudioQuery::new(vec![], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, false, None); let val = serde_json::to_value(audio_query_model).unwrap(); check_json_field_snake_case(&val); } @@ -120,7 +120,7 @@ mod tests { #[rstest] fn it_accepts_json_without_optional_fields() -> anyhow::Result<()> { - serde_json::from_value::(json!({ + serde_json::from_value::(json!({ "accent_phrases": [ { "moras": [ diff --git a/crates/voicevox_core/src/lib.rs b/crates/voicevox_core/src/lib.rs index 910f9eeef..25ff64f9e 100644 --- a/crates/voicevox_core/src/lib.rs +++ b/crates/voicevox_core/src/lib.rs @@ -93,7 +93,7 @@ use rstest_reuse; pub use self::{ devices::SupportedDevices, - engine::{AccentPhraseModel, AudioQueryModel, FullcontextExtractor}, + engine::{AccentPhrase, AudioQuery, FullcontextExtractor, Mora}, error::{Error, ErrorKind}, metas::{ RawStyleId, RawStyleVersion, SpeakerMeta, StyleId, StyleMeta, StyleType, StyleVersion, diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index 767d27b1c..dc6b5395c 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -76,7 +76,7 @@ pub(crate) mod blocking { use enum_map::enum_map; use crate::{ - engine::{create_kana, mora_to_text, MoraModel, OjtPhoneme}, + engine::{create_kana, mora_to_text, Mora, OjtPhoneme}, error::ErrorRepr, infer::{ domains::{ @@ -88,8 +88,8 @@ pub(crate) mod blocking { }, status::Status, text_analyzer::{KanaAnalyzer, OpenJTalkAnalyzer, TextAnalyzer}, - AccentPhraseModel, AudioQueryModel, FullcontextExtractor, Result, StyleId, - SynthesisOptions, VoiceModelId, VoiceModelMeta, + AccentPhrase, AudioQuery, FullcontextExtractor, Result, StyleId, SynthesisOptions, + VoiceModelId, VoiceModelMeta, }; use super::{AccelerationMode, InitializeOptions, TtsOptions}; @@ -243,7 +243,7 @@ pub(crate) mod blocking { /// AudioQueryから音声合成を行う。 pub fn synthesis( &self, - audio_query: &AudioQueryModel, + audio_query: &AudioQuery, style_id: StyleId, options: &SynthesisOptions, ) -> Result> { @@ -352,12 +352,12 @@ pub(crate) mod blocking { return Ok(to_wav(wave, audio_query)); fn adjust_interrogative_accent_phrases( - accent_phrases: &[AccentPhraseModel], - ) -> Vec { + accent_phrases: &[AccentPhrase], + ) -> Vec { accent_phrases .iter() .map(|accent_phrase| { - AccentPhraseModel::new( + AccentPhrase::new( adjust_interrogative_moras(accent_phrase), *accent_phrase.accent(), accent_phrase.pause_mora().clone(), @@ -367,13 +367,13 @@ pub(crate) mod blocking { .collect() } - fn adjust_interrogative_moras(accent_phrase: &AccentPhraseModel) -> Vec { + fn adjust_interrogative_moras(accent_phrase: &AccentPhrase) -> Vec { let moras = accent_phrase.moras(); if *accent_phrase.is_interrogative() && !moras.is_empty() { let last_mora = moras.last().unwrap(); let last_mora_pitch = *last_mora.pitch(); if last_mora_pitch != 0.0 { - let mut new_moras: Vec = Vec::with_capacity(moras.len() + 1); + let mut new_moras: Vec = Vec::with_capacity(moras.len() + 1); new_moras.extend_from_slice(moras.as_slice()); let interrogative_mora = make_interrogative_mora(last_mora); new_moras.push(interrogative_mora); @@ -383,14 +383,14 @@ pub(crate) mod blocking { moras.clone() } - fn make_interrogative_mora(last_mora: &MoraModel) -> MoraModel { + fn make_interrogative_mora(last_mora: &Mora) -> Mora { const FIX_VOWEL_LENGTH: f32 = 0.15; const ADJUST_PITCH: f32 = 0.3; const MAX_PITCH: f32 = 6.5; let pitch = (*last_mora.pitch() + ADJUST_PITCH).min(MAX_PITCH); - MoraModel::new( + Mora::new( mora_to_text(None, last_mora.vowel()), None, None, @@ -400,7 +400,7 @@ pub(crate) mod blocking { ) } - fn to_wav(wave: &[f32], audio_query: &AudioQueryModel) -> Vec { + fn to_wav(wave: &[f32], audio_query: &AudioQuery) -> Vec { let volume_scale = *audio_query.volume_scale(); let output_stereo = *audio_query.output_stereo(); let output_sampling_rate = *audio_query.output_sampling_rate(); @@ -475,7 +475,7 @@ pub(crate) mod blocking { &self, kana: &str, style_id: StyleId, - ) -> Result> { + ) -> Result> { let accent_phrases = self.kana_analyzer.analyze(kana)?; self.replace_mora_data(&accent_phrases, style_id) } @@ -483,9 +483,9 @@ pub(crate) mod blocking { /// AccentPhraseの配列の音高・音素長を、特定の声で生成しなおす。 pub fn replace_mora_data( &self, - accent_phrases: &[AccentPhraseModel], + accent_phrases: &[AccentPhrase], style_id: StyleId, - ) -> Result> { + ) -> Result> { let accent_phrases = self.replace_phoneme_length(accent_phrases, style_id)?; self.replace_mora_pitch(&accent_phrases, style_id) } @@ -493,9 +493,9 @@ pub(crate) mod blocking { /// AccentPhraseの配列の音素長を、特定の声で生成しなおす。 pub fn replace_phoneme_length( &self, - accent_phrases: &[AccentPhraseModel], + accent_phrases: &[AccentPhrase], style_id: StyleId, - ) -> Result> { + ) -> Result> { let (_, phoneme_data_list) = initial_process(accent_phrases); let (_, _, vowel_indexes_data) = split_mora(&phoneme_data_list); @@ -510,12 +510,12 @@ pub(crate) mod blocking { let new_accent_phrases = accent_phrases .iter() .map(|accent_phrase| { - AccentPhraseModel::new( + AccentPhrase::new( accent_phrase .moras() .iter() .map(|mora| { - let new_mora = MoraModel::new( + let new_mora = Mora::new( mora.text().clone(), mora.consonant().clone(), mora.consonant().as_ref().map(|_| { @@ -531,7 +531,7 @@ pub(crate) mod blocking { .collect(), *accent_phrase.accent(), accent_phrase.pause_mora().as_ref().map(|pause_mora| { - let new_pause_mora = MoraModel::new( + let new_pause_mora = Mora::new( pause_mora.text().clone(), pause_mora.consonant().clone(), *pause_mora.consonant_length(), @@ -553,9 +553,9 @@ pub(crate) mod blocking { /// AccentPhraseの配列の音高を、特定の声で生成しなおす。 pub fn replace_mora_pitch( &self, - accent_phrases: &[AccentPhraseModel], + accent_phrases: &[AccentPhrase], style_id: StyleId, - ) -> Result> { + ) -> Result> { let (_, phoneme_data_list) = initial_process(accent_phrases); let mut base_start_accent_list = vec![0]; @@ -626,12 +626,12 @@ pub(crate) mod blocking { let new_accent_phrases = accent_phrases .iter() .map(|accent_phrase| { - AccentPhraseModel::new( + AccentPhrase::new( accent_phrase .moras() .iter() .map(|mora| { - let new_mora = MoraModel::new( + let new_mora = Mora::new( mora.text().clone(), mora.consonant().clone(), *mora.consonant_length(), @@ -645,7 +645,7 @@ pub(crate) mod blocking { .collect(), *accent_phrase.accent(), accent_phrase.pause_mora().as_ref().map(|pause_mora| { - let new_pause_mora = MoraModel::new( + let new_pause_mora = Mora::new( pause_mora.text().clone(), pause_mora.consonant().clone(), *pause_mora.consonant_length(), @@ -665,7 +665,7 @@ pub(crate) mod blocking { fn create_one_accent_list( accent_list: &mut Vec, - accent_phrase: &AccentPhraseModel, + accent_phrase: &AccentPhrase, point: i32, ) { let mut one_accent_list: Vec = Vec::new(); @@ -713,14 +713,9 @@ pub(crate) mod blocking { /// ``` /// /// [AudioQuery]: crate::AudioQueryModel - pub fn audio_query_from_kana( - &self, - kana: &str, - style_id: StyleId, - ) -> Result { + pub fn audio_query_from_kana(&self, kana: &str, style_id: StyleId) -> Result { let accent_phrases = self.create_accent_phrases_from_kana(kana, style_id)?; - Ok(AudioQueryModel::from_accent_phrases(accent_phrases) - .with_kana(Some(kana.to_owned()))) + Ok(AudioQuery::from_accent_phrases(accent_phrases).with_kana(Some(kana.to_owned()))) } /// AquesTalk風記法から音声合成を行う。 @@ -764,7 +759,7 @@ pub(crate) mod blocking { &self, text: &str, style_id: StyleId, - ) -> Result> { + ) -> Result> { let accent_phrases = self.open_jtalk_analyzer.analyze(text)?; self.replace_mora_data(&accent_phrases, style_id) } @@ -795,9 +790,9 @@ pub(crate) mod blocking { /// ``` /// /// [AudioQuery]: crate::AudioQueryModel - pub fn audio_query(&self, text: &str, style_id: StyleId) -> Result { + pub fn audio_query(&self, text: &str, style_id: StyleId) -> Result { let accent_phrases = self.create_accent_phrases(text, style_id)?; - Ok(AudioQueryModel::from_accent_phrases(accent_phrases)) + Ok(AudioQuery::from_accent_phrases(accent_phrases)) } /// 日本語のテキストから音声合成を行う。 @@ -1036,7 +1031,7 @@ pub(crate) mod blocking { } } - fn initial_process(accent_phrases: &[AccentPhraseModel]) -> (Vec, Vec) { + fn initial_process(accent_phrases: &[AccentPhrase]) -> (Vec, Vec) { let flatten_moras = to_flatten_moras(accent_phrases); let mut phoneme_strings = vec!["pau".to_string()]; @@ -1052,7 +1047,7 @@ pub(crate) mod blocking { return (flatten_moras, phoneme_data_list); - fn to_flatten_moras(accent_phrases: &[AccentPhraseModel]) -> Vec { + fn to_flatten_moras(accent_phrases: &[AccentPhrase]) -> Vec { let mut flatten_moras = Vec::new(); for accent_phrase in accent_phrases { @@ -1114,8 +1109,8 @@ pub(crate) mod blocking { (consonant_phoneme_list, vowel_phoneme_list, vowel_indexes) } - impl AudioQueryModel { - fn from_accent_phrases(accent_phrases: Vec) -> Self { + impl AudioQuery { + fn from_accent_phrases(accent_phrases: Vec) -> Self { let kana = create_kana(&accent_phrases); Self::new( accent_phrases, @@ -1137,8 +1132,8 @@ pub(crate) mod tokio { use std::sync::Arc; use crate::{ - AccentPhraseModel, AudioQueryModel, FullcontextExtractor, Result, StyleId, - SynthesisOptions, VoiceModelId, VoiceModelMeta, + AccentPhrase, AudioQuery, FullcontextExtractor, Result, StyleId, SynthesisOptions, + VoiceModelId, VoiceModelMeta, }; use super::{InitializeOptions, TtsOptions}; @@ -1191,7 +1186,7 @@ pub(crate) mod tokio { pub async fn synthesis( &self, - audio_query: &AudioQueryModel, + audio_query: &AudioQuery, style_id: StyleId, options: &SynthesisOptions, ) -> Result> { @@ -1207,7 +1202,7 @@ pub(crate) mod tokio { &self, kana: &str, style_id: StyleId, - ) -> Result> { + ) -> Result> { let blocking = self.0.clone(); let kana = kana.to_owned(); @@ -1217,9 +1212,9 @@ pub(crate) mod tokio { pub async fn replace_mora_data( &self, - accent_phrases: &[AccentPhraseModel], + accent_phrases: &[AccentPhrase], style_id: StyleId, - ) -> Result> { + ) -> Result> { let blocking = self.0.clone(); let accent_phrases = accent_phrases.to_owned(); @@ -1229,9 +1224,9 @@ pub(crate) mod tokio { pub async fn replace_phoneme_length( &self, - accent_phrases: &[AccentPhraseModel], + accent_phrases: &[AccentPhrase], style_id: StyleId, - ) -> Result> { + ) -> Result> { let blocking = self.0.clone(); let accent_phrases = accent_phrases.to_owned(); @@ -1243,9 +1238,9 @@ pub(crate) mod tokio { pub async fn replace_mora_pitch( &self, - accent_phrases: &[AccentPhraseModel], + accent_phrases: &[AccentPhrase], style_id: StyleId, - ) -> Result> { + ) -> Result> { let blocking = self.0.clone(); let accent_phrases = accent_phrases.to_owned(); @@ -1257,7 +1252,7 @@ pub(crate) mod tokio { &self, kana: &str, style_id: StyleId, - ) -> Result { + ) -> Result { let blocking = self.0.clone(); let kana = kana.to_owned(); @@ -1283,14 +1278,14 @@ pub(crate) mod tokio { &self, text: &str, style_id: StyleId, - ) -> Result> { + ) -> Result> { let blocking = self.0.clone(); let text = text.to_owned(); crate::task::asyncify(move || blocking.create_accent_phrases(&text, style_id)).await } - pub async fn audio_query(&self, text: &str, style_id: StyleId) -> Result { + pub async fn audio_query(&self, text: &str, style_id: StyleId) -> Result { let blocking = self.0.clone(); let text = text.to_owned(); @@ -1316,9 +1311,7 @@ pub(crate) mod tokio { mod tests { use super::{blocking::PerformInference as _, AccelerationMode, InitializeOptions}; - use crate::{ - engine::MoraModel, macros::tests::assert_debug_fmt_eq, AccentPhraseModel, Result, StyleId, - }; + use crate::{engine::Mora, macros::tests::assert_debug_fmt_eq, AccentPhrase, Result, StyleId}; use ::test_util::OPEN_JTALK_DIC_DIR; use rstest::rstest; @@ -1740,7 +1733,7 @@ mod tests { assert_eq!(accent_phrases.len(), 5); // 入力テキストに「、」や「。」などの句読点が含まれていたときに - // AccentPhraseModel の pause_mora に期待する値をテスト + // AccentPhraseの pause_mora に期待する値をテスト assert!( accent_phrases[0].pause_mora().is_some(), @@ -1812,7 +1805,7 @@ mod tests { any_mora_param_changed( &accent_phrases, &modified_accent_phrases, - MoraModel::vowel_length + Mora::vowel_length ), "mora_length() does not work: mora.vowel_length() is not changed." ); @@ -1850,7 +1843,7 @@ mod tests { // NOTE: 一つでも音高が変わっていれば、動作しているとみなす assert!( - any_mora_param_changed(&accent_phrases, &modified_accent_phrases, MoraModel::pitch), + any_mora_param_changed(&accent_phrases, &modified_accent_phrases, Mora::pitch), "mora_pitch() does not work: mora.pitch() is not changed." ); } @@ -1887,7 +1880,7 @@ mod tests { // NOTE: 一つでも音高が変わっていれば、動作しているとみなす assert!( - any_mora_param_changed(&accent_phrases, &modified_accent_phrases, MoraModel::pitch), + any_mora_param_changed(&accent_phrases, &modified_accent_phrases, Mora::pitch), "mora_data() does not work: mora.pitch() is not changed." ); // NOTE: 一つでも母音の長さが変わっていれば、動作しているとみなす @@ -1895,16 +1888,16 @@ mod tests { any_mora_param_changed( &accent_phrases, &modified_accent_phrases, - MoraModel::vowel_length + Mora::vowel_length ), "mora_data() does not work: mora.vowel_length() is not changed." ); } fn any_mora_param_changed( - before: &[AccentPhraseModel], - after: &[AccentPhraseModel], - param: fn(&MoraModel) -> &T, + before: &[AccentPhrase], + after: &[AccentPhrase], + param: fn(&Mora) -> &T, ) -> bool { std::iter::zip(before, after) .flat_map(move |(before, after)| std::iter::zip(before.moras(), after.moras())) diff --git a/crates/voicevox_core/src/text_analyzer.rs b/crates/voicevox_core/src/text_analyzer.rs index 8540f26e0..f0811ed91 100644 --- a/crates/voicevox_core/src/text_analyzer.rs +++ b/crates/voicevox_core/src/text_analyzer.rs @@ -1,10 +1,10 @@ use crate::{ engine::{extract_full_context_label, parse_kana}, - AccentPhraseModel, FullcontextExtractor, Result, + AccentPhrase, FullcontextExtractor, Result, }; pub(crate) trait TextAnalyzer { - fn analyze(&self, text: &str) -> Result>; + fn analyze(&self, text: &str) -> Result>; } /// AquesTalk風記法からAccentPhraseの配列を生成するTextAnalyzer @@ -12,7 +12,7 @@ pub(crate) trait TextAnalyzer { pub(crate) struct KanaAnalyzer; impl TextAnalyzer for KanaAnalyzer { - fn analyze(&self, text: &str) -> Result> { + fn analyze(&self, text: &str) -> Result> { if text.is_empty() { return Ok(Vec::new()); } @@ -31,7 +31,7 @@ impl OpenJTalkAnalyzer { } impl TextAnalyzer for OpenJTalkAnalyzer { - fn analyze(&self, text: &str) -> Result> { + fn analyze(&self, text: &str) -> Result> { if text.is_empty() { return Ok(Vec::new()); } diff --git a/crates/voicevox_core_c_api/src/helpers.rs b/crates/voicevox_core_c_api/src/helpers.rs index 5066b643a..af4057d09 100644 --- a/crates/voicevox_core_c_api/src/helpers.rs +++ b/crates/voicevox_core_c_api/src/helpers.rs @@ -1,12 +1,12 @@ use easy_ext::ext; use std::{ffi::CStr, fmt::Debug, iter}; use uuid::Uuid; -use voicevox_core::{AudioQueryModel, UserDictWord, VoiceModelId}; +use voicevox_core::{AudioQuery, UserDictWord, VoiceModelId}; use thiserror::Error; use tracing::error; -use voicevox_core::AccentPhraseModel; +use voicevox_core::AccentPhrase; use crate::{ result_code::VoicevoxResultCode, VoicevoxAccelerationMode, VoicevoxInitializeOptions, @@ -80,11 +80,11 @@ pub(crate) enum CApiError { InvalidUuid(uuid::Error), } -pub(crate) fn audio_query_model_to_json(audio_query_model: &AudioQueryModel) -> String { +pub(crate) fn audio_query_model_to_json(audio_query_model: &AudioQuery) -> String { serde_json::to_string(audio_query_model).expect("should be always valid") } -pub(crate) fn accent_phrases_to_json(audio_query_model: &[AccentPhraseModel]) -> String { +pub(crate) fn accent_phrases_to_json(audio_query_model: &[AccentPhrase]) -> String { serde_json::to_string(audio_query_model).expect("should be always valid") } diff --git a/crates/voicevox_core_c_api/src/lib.rs b/crates/voicevox_core_c_api/src/lib.rs index 964e635ab..3904698fc 100644 --- a/crates/voicevox_core_c_api/src/lib.rs +++ b/crates/voicevox_core_c_api/src/lib.rs @@ -33,7 +33,7 @@ use tracing_subscriber::fmt::format::Writer; use tracing_subscriber::EnvFilter; use uuid::Uuid; use voicevox_core::__internal::interop::IdRef as _; -use voicevox_core::{AccentPhraseModel, AudioQueryModel, TtsOptions, UserDictWord}; +use voicevox_core::{AccentPhrase, AudioQuery, TtsOptions, UserDictWord}; use voicevox_core::{StyleId, SynthesisOptions}; fn init_logger_once() { @@ -906,7 +906,7 @@ pub unsafe extern "C" fn voicevox_synthesizer_replace_mora_data( ) -> VoicevoxResultCode { init_logger_once(); into_result_code_with_error((|| { - let accent_phrases: Vec = + let accent_phrases: Vec = serde_json::from_str(ensure_utf8(CStr::from_ptr(accent_phrases_json))?) .map_err(CApiError::InvalidAccentPhrase)?; let accent_phrases = synthesizer @@ -946,7 +946,7 @@ pub unsafe extern "C" fn voicevox_synthesizer_replace_phoneme_length( ) -> VoicevoxResultCode { init_logger_once(); into_result_code_with_error((|| { - let accent_phrases: Vec = + let accent_phrases: Vec = serde_json::from_str(ensure_utf8(CStr::from_ptr(accent_phrases_json))?) .map_err(CApiError::InvalidAccentPhrase)?; let accent_phrases = synthesizer @@ -986,7 +986,7 @@ pub unsafe extern "C" fn voicevox_synthesizer_replace_mora_pitch( ) -> VoicevoxResultCode { init_logger_once(); into_result_code_with_error((|| { - let accent_phrases: Vec = + let accent_phrases: Vec = serde_json::from_str(ensure_utf8(CStr::from_ptr(accent_phrases_json))?) .map_err(CApiError::InvalidAccentPhrase)?; let accent_phrases = synthesizer @@ -1049,7 +1049,7 @@ pub unsafe extern "C" fn voicevox_synthesizer_synthesis( let audio_query_json = CStr::from_ptr(audio_query_json) .to_str() .map_err(|_| CApiError::InvalidUtf8Input)?; - let audio_query: AudioQueryModel = + let audio_query: AudioQuery = serde_json::from_str(audio_query_json).map_err(CApiError::InvalidAudioQuery)?; let wav = synthesizer.synthesizer().synthesis( &audio_query, diff --git a/crates/voicevox_core_java_api/src/synthesizer.rs b/crates/voicevox_core_java_api/src/synthesizer.rs index b2605e8ae..9ebd98e47 100644 --- a/crates/voicevox_core_java_api/src/synthesizer.rs +++ b/crates/voicevox_core_java_api/src/synthesizer.rs @@ -288,7 +288,7 @@ unsafe extern "system" fn Java_jp_hiroshiba_voicevoxcore_Synthesizer_rsReplaceMo ) -> jobject { throw_if_err(env, std::ptr::null_mut(), |env| { let accent_phrases_json: String = env.get_string(&accent_phrases_json)?.into(); - let accent_phrases: Vec = + let accent_phrases: Vec = serde_json::from_str(&accent_phrases_json).map_err(JavaApiError::DeJson)?; let style_id = style_id as u32; @@ -319,7 +319,7 @@ unsafe extern "system" fn Java_jp_hiroshiba_voicevoxcore_Synthesizer_rsReplacePh ) -> jobject { throw_if_err(env, std::ptr::null_mut(), |env| { let accent_phrases_json: String = env.get_string(&accent_phrases_json)?.into(); - let accent_phrases: Vec = + let accent_phrases: Vec = serde_json::from_str(&accent_phrases_json).map_err(JavaApiError::DeJson)?; let style_id = style_id as u32; @@ -348,7 +348,7 @@ unsafe extern "system" fn Java_jp_hiroshiba_voicevoxcore_Synthesizer_rsReplaceMo ) -> jobject { throw_if_err(env, std::ptr::null_mut(), |env| { let accent_phrases_json: String = env.get_string(&accent_phrases_json)?.into(); - let accent_phrases: Vec = + let accent_phrases: Vec = serde_json::from_str(&accent_phrases_json).map_err(JavaApiError::DeJson)?; let style_id = style_id as u32; @@ -378,7 +378,7 @@ unsafe extern "system" fn Java_jp_hiroshiba_voicevoxcore_Synthesizer_rsSynthesis ) -> jobject { throw_if_err(env, std::ptr::null_mut(), |env| { let audio_query: String = env.get_string(&query_json)?.into(); - let audio_query: voicevox_core::AudioQueryModel = + let audio_query: voicevox_core::AudioQuery = serde_json::from_str(&audio_query).map_err(JavaApiError::DeJson)?; let style_id = style_id as u32; diff --git a/crates/voicevox_core_python_api/src/convert.rs b/crates/voicevox_core_python_api/src/convert.rs index 0eee14a5b..b625f70b5 100644 --- a/crates/voicevox_core_python_api/src/convert.rs +++ b/crates/voicevox_core_python_api/src/convert.rs @@ -10,9 +10,7 @@ use pyo3::{ use serde::{de::DeserializeOwned, Serialize}; use serde_json::json; use uuid::Uuid; -use voicevox_core::{ - AccelerationMode, AccentPhraseModel, StyleId, UserDictWordType, VoiceModelMeta, -}; +use voicevox_core::{AccelerationMode, AccentPhrase, StyleId, UserDictWordType, VoiceModelMeta}; use crate::{ ExtractFullContextLabelError, GetSupportedDevicesError, GpuSupportError, InferenceFailedError, @@ -86,15 +84,12 @@ pub(crate) fn blocking_modify_accent_phrases<'py>( accent_phrases: &'py PyList, speaker_id: StyleId, py: Python<'py>, - method: impl FnOnce( - Vec, - StyleId, - ) -> voicevox_core::Result>, + method: impl FnOnce(Vec, StyleId) -> voicevox_core::Result>, ) -> PyResult> { let rust_accent_phrases = accent_phrases .iter() .map(from_dataclass) - .collect::>>()?; + .collect::>>()?; method(rust_accent_phrases, speaker_id) .into_py_result(py)? @@ -115,13 +110,13 @@ pub(crate) fn async_modify_accent_phrases<'py, Fun, Fut>( method: Fun, ) -> PyResult<&'py PyAny> where - Fun: FnOnce(Vec, StyleId) -> Fut + Send + 'static, - Fut: Future>> + Send + 'static, + Fun: FnOnce(Vec, StyleId) -> Fut + Send + 'static, + Fut: Future>> + Send + 'static, { let rust_accent_phrases = accent_phrases .iter() .map(from_dataclass) - .collect::>>()?; + .collect::>>()?; pyo3_asyncio::tokio::future_into_py_with_locals( py, pyo3_asyncio::tokio::get_current_locals(py)?, diff --git a/crates/voicevox_core_python_api/src/lib.rs b/crates/voicevox_core_python_api/src/lib.rs index 0da82f9ca..e301f1042 100644 --- a/crates/voicevox_core_python_api/src/lib.rs +++ b/crates/voicevox_core_python_api/src/lib.rs @@ -151,8 +151,8 @@ mod blocking { }; use uuid::Uuid; use voicevox_core::{ - AccelerationMode, AudioQueryModel, InitializeOptions, StyleId, SynthesisOptions, - TtsOptions, UserDictWord, + AccelerationMode, AudioQuery, InitializeOptions, StyleId, SynthesisOptions, TtsOptions, + UserDictWord, }; use crate::{convert::VoicevoxCoreResultExt as _, Closable}; @@ -497,7 +497,7 @@ mod blocking { ))] fn synthesis<'py>( &self, - #[pyo3(from_py_with = "crate::convert::from_dataclass")] audio_query: AudioQueryModel, + #[pyo3(from_py_with = "crate::convert::from_dataclass")] audio_query: AudioQuery, style_id: u32, enable_interrogative_upspeak: bool, py: Python<'py>, @@ -651,8 +651,8 @@ mod asyncio { }; use uuid::Uuid; use voicevox_core::{ - AccelerationMode, AudioQueryModel, InitializeOptions, StyleId, SynthesisOptions, - TtsOptions, UserDictWord, + AccelerationMode, AudioQuery, InitializeOptions, StyleId, SynthesisOptions, TtsOptions, + UserDictWord, }; use crate::{convert::VoicevoxCoreResultExt as _, Closable}; @@ -1045,7 +1045,7 @@ mod asyncio { #[pyo3(signature=(audio_query,style_id,enable_interrogative_upspeak = TtsOptions::default().enable_interrogative_upspeak))] fn synthesis<'py>( &self, - #[pyo3(from_py_with = "crate::convert::from_dataclass")] audio_query: AudioQueryModel, + #[pyo3(from_py_with = "crate::convert::from_dataclass")] audio_query: AudioQuery, style_id: u32, enable_interrogative_upspeak: bool, py: Python<'py>, From d8d565112e4ecd579622de7010dd4980d8dc0880 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 6 Jul 2024 22:04:10 +0900 Subject: [PATCH 2/3] =?UTF-8?q?doc=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/voicevox_core/src/synthesizer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index dc6b5395c..902d7e6dc 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -712,7 +712,7 @@ pub(crate) mod blocking { /// # } /// ``` /// - /// [AudioQuery]: crate::AudioQueryModel + /// [AudioQuery]: crate::QueryModel pub fn audio_query_from_kana(&self, kana: &str, style_id: StyleId) -> Result { let accent_phrases = self.create_accent_phrases_from_kana(kana, style_id)?; Ok(AudioQuery::from_accent_phrases(accent_phrases).with_kana(Some(kana.to_owned()))) @@ -789,7 +789,7 @@ pub(crate) mod blocking { /// # } /// ``` /// - /// [AudioQuery]: crate::AudioQueryModel + /// [AudioQuery]: crate::QueryModel pub fn audio_query(&self, text: &str, style_id: StyleId) -> Result { let accent_phrases = self.create_accent_phrases(text, style_id)?; Ok(AudioQuery::from_accent_phrases(accent_phrases)) From a891b787c4080330dfb2fd259dc0b8a146a2e0a5 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 6 Jul 2024 22:34:26 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fixup!=20doc=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/voicevox_core/src/synthesizer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index 902d7e6dc..4f9576500 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -712,7 +712,7 @@ pub(crate) mod blocking { /// # } /// ``` /// - /// [AudioQuery]: crate::QueryModel + /// [AudioQuery]: crate::AudioQuery pub fn audio_query_from_kana(&self, kana: &str, style_id: StyleId) -> Result { let accent_phrases = self.create_accent_phrases_from_kana(kana, style_id)?; Ok(AudioQuery::from_accent_phrases(accent_phrases).with_kana(Some(kana.to_owned()))) @@ -789,7 +789,7 @@ pub(crate) mod blocking { /// # } /// ``` /// - /// [AudioQuery]: crate::QueryModel + /// [AudioQuery]: crate::AudioQuery pub fn audio_query(&self, text: &str, style_id: StyleId) -> Result { let accent_phrases = self.create_accent_phrases(text, style_id)?; Ok(AudioQuery::from_accent_phrases(accent_phrases))