From c6f60b82c577693bdae2999c89683029a759848d Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 18 Jan 2025 00:20:47 +0900 Subject: [PATCH] =?UTF-8?q?feat!:=20Rust=20API=E3=81=A0=E3=81=91`TextAnaly?= =?UTF-8?q?zer`=E3=82=92=E3=83=91=E3=83=96=E3=83=AA=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B=20(#919)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rust APIの`FullcontextExtractor`の役割を`TextAnalyzer`に譲る。基本的にそ れだけ。パブリックAPIの機能としてはまだあまり整えない。 BREAKING-CHANGE: Rust APIの`FullcontextExtractor`が`TextAnalyzer`に変わる。 BREAKING-CHANGE: `ExtractFullContextLabelError` → `AnalyzeTextError`。 Refs: #730 --- .../src/__internal/doctest_fixtures.rs | 2 +- crates/voicevox_core/src/blocking.rs | 3 +- .../src/engine/full_context_label.rs | 5 +- .../voicevox_core/src/engine/kana_parser.rs | 3 + crates/voicevox_core/src/engine/mod.rs | 3 +- crates/voicevox_core/src/engine/open_jtalk.rs | 46 +++- crates/voicevox_core/src/error.rs | 21 +- crates/voicevox_core/src/lib.rs | 2 +- crates/voicevox_core/src/nonblocking.rs | 3 +- crates/voicevox_core/src/synthesizer.rs | 210 ++++++++++-------- crates/voicevox_core/src/text_analyzer.rs | 44 +--- .../include/voicevox_core.h | 4 +- crates/voicevox_core_c_api/src/c_impls.rs | 2 +- crates/voicevox_core_c_api/src/helpers.rs | 2 +- crates/voicevox_core_c_api/src/result_code.rs | 8 +- .../tests/e2e/snapshots.toml | 2 +- .../tests/e2e/testcases/global_info.rs | 2 +- .../exceptions/AnalyzeTextException.java | 12 + .../ExtractFullContextLabelException.java | 12 - crates/voicevox_core_java_api/src/common.rs | 2 +- .../voicevox_core_java_api/src/synthesizer.rs | 2 +- .../python/voicevox_core/__init__.py | 4 +- .../python/voicevox_core/_rust/__init__.pyi | 4 +- .../voicevox_core_python_api/src/convert.rs | 12 +- crates/voicevox_core_python_api/src/lib.rs | 6 +- 25 files changed, 227 insertions(+), 189 deletions(-) create mode 100644 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/AnalyzeTextException.java delete mode 100644 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/ExtractFullContextLabelException.java diff --git a/crates/voicevox_core/src/__internal/doctest_fixtures.rs b/crates/voicevox_core/src/__internal/doctest_fixtures.rs index 9ccb2282a..6fb9937f6 100644 --- a/crates/voicevox_core/src/__internal/doctest_fixtures.rs +++ b/crates/voicevox_core/src/__internal/doctest_fixtures.rs @@ -22,7 +22,7 @@ pub async fn synthesizer_with_sample_voice_model( #[cfg(feature = "link-onnxruntime")] crate::nonblocking::Onnxruntime::init_once().await?, ) - .open_jtalk(crate::nonblocking::OpenJtalk::new(open_jtalk_dic_dir).await?) + .text_analyzer(crate::nonblocking::OpenJtalk::new(open_jtalk_dic_dir).await?) .acceleration_mode(AccelerationMode::Cpu) .build()?; diff --git a/crates/voicevox_core/src/blocking.rs b/crates/voicevox_core/src/blocking.rs index 5e37d1792..ad2f81ddc 100644 --- a/crates/voicevox_core/src/blocking.rs +++ b/crates/voicevox_core/src/blocking.rs @@ -3,7 +3,8 @@ pub use crate::{ engine::open_jtalk::blocking::OpenJtalk, infer::runtimes::onnxruntime::blocking::Onnxruntime, synthesizer::blocking::AudioFeature, synthesizer::blocking::Synthesizer, - user_dict::dict::blocking::UserDict, voice_model::blocking::VoiceModelFile, + text_analyzer::blocking::TextAnalyzer, user_dict::dict::blocking::UserDict, + voice_model::blocking::VoiceModelFile, }; pub mod onnxruntime { diff --git a/crates/voicevox_core/src/engine/full_context_label.rs b/crates/voicevox_core/src/engine/full_context_label.rs index 50472f3e1..391b7cc27 100644 --- a/crates/voicevox_core/src/engine/full_context_label.rs +++ b/crates/voicevox_core/src/engine/full_context_label.rs @@ -7,7 +7,6 @@ use crate::{ use jlabel::Label; use smallvec::SmallVec; -// FIXME: 入力テキストをここで持って、メッセージに含む #[derive(thiserror::Error, Debug)] #[error("入力テキストからのフルコンテキストラベル抽出に失敗しました: {context}")] pub(crate) struct FullContextLabelError { @@ -428,7 +427,7 @@ mod tests { let open_jtalk = crate::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(); - assert_eq!(&open_jtalk.extract_fullcontext(text).unwrap(), labels); + assert_eq!(&open_jtalk.0.extract_fullcontext(text).unwrap(), labels); } #[apply(label_cases)] @@ -451,7 +450,7 @@ mod tests { .await .unwrap(); assert_eq!( - &extract_full_context_label(&open_jtalk, text).unwrap(), + &extract_full_context_label(&open_jtalk.0, text).unwrap(), accent_phrase ); } diff --git a/crates/voicevox_core/src/engine/kana_parser.rs b/crates/voicevox_core/src/engine/kana_parser.rs index 67aa276cb..ae5c3c6a5 100644 --- a/crates/voicevox_core/src/engine/kana_parser.rs +++ b/crates/voicevox_core/src/engine/kana_parser.rs @@ -121,6 +121,9 @@ fn text_to_accent_phrase(phrase: &str) -> KanaParseResult { pub(crate) fn parse_kana(text: &str) -> KanaParseResult> { const TERMINATOR: char = '\0'; + if text.is_empty() { + return Ok(vec![]); + } let mut parsed_result = Vec::new(); let chars_of_text = text.chars().chain([TERMINATOR]); let mut phrase = String::new(); diff --git a/crates/voicevox_core/src/engine/mod.rs b/crates/voicevox_core/src/engine/mod.rs index 0c1576ca3..7758de81b 100644 --- a/crates/voicevox_core/src/engine/mod.rs +++ b/crates/voicevox_core/src/engine/mod.rs @@ -10,9 +10,8 @@ pub(crate) mod open_jtalk; pub(crate) use self::acoustic_feature_extractor::OjtPhoneme; pub(crate) use self::audio_file::to_s16le_pcm; pub use self::audio_file::wav_from_s16le; -pub(crate) use self::full_context_label::{extract_full_context_label, FullContextLabelError}; +pub(crate) use self::full_context_label::extract_full_context_label; pub(crate) use self::interpret_query::{initial_process, split_mora, DecoderFeature}; pub(crate) use self::kana_parser::{create_kana, parse_kana, KanaParseError}; 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/open_jtalk.rs b/crates/voicevox_core/src/engine/open_jtalk.rs index 3cad9c99a..3e2a1348a 100644 --- a/crates/voicevox_core/src/engine/open_jtalk.rs +++ b/crates/voicevox_core/src/engine/open_jtalk.rs @@ -21,7 +21,7 @@ pub(crate) struct OpenjtalkFunctionError { source: Option, } -pub trait FullcontextExtractor: Clone + Send + Sync + 'static { +pub(crate) trait FullcontextExtractor { fn extract_fullcontext(&self, text: &str) -> anyhow::Result>; } @@ -38,7 +38,10 @@ pub(crate) mod blocking { use crate::error::ErrorRepr; - use super::{FullcontextExtractor, OpenjtalkFunctionError}; + use super::{ + super::{extract_full_context_label, AccentPhrase}, + FullcontextExtractor, OpenjtalkFunctionError, + }; /// テキスト解析器としてのOpen JTalk。 #[derive(Clone)] @@ -80,12 +83,19 @@ pub(crate) mod blocking { } impl FullcontextExtractor for self::OpenJtalk { + fn extract_fullcontext(&self, text: &str) -> anyhow::Result> { + self.0.extract_fullcontext(text) + } + } + + // TODO: このコードの移動 + impl FullcontextExtractor for Inner { fn extract_fullcontext(&self, text: &str) -> anyhow::Result> { let Resources { mecab, njd, jpcommon, - } = &mut *self.0.resources.lock().unwrap(); + } = &mut *self.resources.lock().unwrap(); jpcommon.refresh(); njd.refresh(); @@ -129,6 +139,15 @@ pub(crate) mod blocking { } } + impl crate::blocking::TextAnalyzer for self::OpenJtalk { + fn analyze(&self, text: &str) -> anyhow::Result> { + if text.is_empty() { + return Ok(Vec::new()); + } + Ok(extract_full_context_label(&*self.0, text)?) + } + } + pub(super) struct Inner { resources: std::sync::Mutex, dict_dir: Utf8PathBuf, @@ -196,7 +215,7 @@ pub(crate) mod blocking { pub(crate) mod nonblocking { use camino::Utf8Path; - use super::FullcontextExtractor; + use super::super::{extract_full_context_label, AccentPhrase}; /// テキスト解析器としてのOpen JTalk。 /// @@ -207,7 +226,7 @@ pub(crate) mod nonblocking { /// [blocking]: https://docs.rs/crate/blocking /// [`nonblocking`モジュールのドキュメント]: crate::nonblocking #[derive(Clone)] - pub struct OpenJtalk(super::blocking::OpenJtalk); + pub struct OpenJtalk(pub(in super::super) super::blocking::OpenJtalk); impl self::OpenJtalk { pub async fn new(open_jtalk_dict_dir: impl AsRef) -> crate::result::Result { @@ -231,9 +250,16 @@ pub(crate) mod nonblocking { } } - impl FullcontextExtractor for self::OpenJtalk { - fn extract_fullcontext(&self, text: &str) -> anyhow::Result> { - self.0.extract_fullcontext(text) + impl crate::nonblocking::TextAnalyzer for self::OpenJtalk { + async fn analyze(&self, text: &str) -> anyhow::Result> { + if text.is_empty() { + return Ok(Vec::new()); + } + let inner = self.0 .0.clone(); + let text = text.to_owned(); + crate::task::asyncify(move || extract_full_context_label(&*inner, &text)) + .await + .map_err(Into::into) } } } @@ -345,7 +371,7 @@ mod tests { let open_jtalk = super::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(); - let result = open_jtalk.extract_fullcontext(text); + let result = open_jtalk.0.extract_fullcontext(text); assert_debug_fmt_eq!(expected, result); } @@ -360,7 +386,7 @@ mod tests { .await .unwrap(); for _ in 0..10 { - let result = open_jtalk.extract_fullcontext(text); + let result = open_jtalk.0.extract_fullcontext(text); assert_debug_fmt_eq!(expected, result); } } diff --git a/crates/voicevox_core/src/error.rs b/crates/voicevox_core/src/error.rs index 55c83097f..12c5e9519 100644 --- a/crates/voicevox_core/src/error.rs +++ b/crates/voicevox_core/src/error.rs @@ -1,8 +1,6 @@ use crate::{ - devices::DeviceAvailabilities, - engine::{FullContextLabelError, KanaParseError}, - user_dict::InvalidWordError, - StyleId, StyleType, VoiceModelId, + devices::DeviceAvailabilities, engine::KanaParseError, user_dict::InvalidWordError, StyleId, + StyleType, VoiceModelId, }; //use engine:: use duplicate::duplicate_item; @@ -19,7 +17,6 @@ pub struct Error(#[from] ErrorRepr); #[duplicate_item( E; [ LoadModelError ]; - [ FullContextLabelError ]; [ KanaParseError ]; [ InvalidWordError ]; )] @@ -48,7 +45,7 @@ impl Error { ErrorRepr::StyleNotFound { .. } => ErrorKind::StyleNotFound, ErrorRepr::ModelNotFound { .. } => ErrorKind::ModelNotFound, ErrorRepr::RunModel { .. } => ErrorKind::RunModel, - ErrorRepr::ExtractFullContextLabel(_) => ErrorKind::ExtractFullContextLabel, + ErrorRepr::AnalyzeText { .. } => ErrorKind::AnalyzeText, ErrorRepr::ParseKana(_) => ErrorKind::ParseKana, ErrorRepr::LoadUserDict(_) => ErrorKind::LoadUserDict, ErrorRepr::SaveUserDict(_) => ErrorKind::SaveUserDict, @@ -99,8 +96,12 @@ pub(crate) enum ErrorRepr { #[error("推論に失敗しました")] RunModel(#[source] anyhow::Error), - #[error(transparent)] - ExtractFullContextLabel(#[from] FullContextLabelError), + #[error("入力テキストの解析に失敗しました")] + AnalyzeText { + text: String, + #[source] + source: anyhow::Error, + }, #[error(transparent)] ParseKana(#[from] KanaParseError), @@ -150,8 +151,8 @@ pub enum ErrorKind { ModelNotFound, /// 推論に失敗した。 RunModel, - /// コンテキストラベル出力に失敗した。 - ExtractFullContextLabel, + /// 入力テキストの解析に失敗した。 + AnalyzeText, /// AquesTalk風記法のテキストの解析に失敗した。 ParseKana, /// ユーザー辞書を読み込めなかった。 diff --git a/crates/voicevox_core/src/lib.rs b/crates/voicevox_core/src/lib.rs index a112cecb3..fef645d8d 100644 --- a/crates/voicevox_core/src/lib.rs +++ b/crates/voicevox_core/src/lib.rs @@ -84,7 +84,7 @@ use rstest_reuse; pub use self::{ devices::SupportedDevices, - engine::{wav_from_s16le, AccentPhrase, AudioQuery, FullcontextExtractor, Mora}, + engine::{wav_from_s16le, AccentPhrase, AudioQuery, Mora}, error::{Error, ErrorKind}, metas::{ RawStyleId, RawStyleVersion, SpeakerMeta, StyleId, StyleMeta, StyleType, StyleVersion, diff --git a/crates/voicevox_core/src/nonblocking.rs b/crates/voicevox_core/src/nonblocking.rs index f65aebcb1..d5c6cc34d 100644 --- a/crates/voicevox_core/src/nonblocking.rs +++ b/crates/voicevox_core/src/nonblocking.rs @@ -20,7 +20,8 @@ pub use crate::{ engine::open_jtalk::nonblocking::OpenJtalk, infer::runtimes::onnxruntime::nonblocking::Onnxruntime, synthesizer::nonblocking::Synthesizer, - user_dict::dict::nonblocking::UserDict, voice_model::nonblocking::VoiceModelFile, + text_analyzer::nonblocking::TextAnalyzer, user_dict::dict::nonblocking::UserDict, + voice_model::nonblocking::VoiceModelFile, }; pub mod onnxruntime { diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index f56b55529..6a3f0bb27 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -8,10 +8,11 @@ use crate::{ core::{ensure_minimum_phoneme_length, pad_decoder_feature}, devices::{DeviceSpec, GpuSpec}, engine::{ - create_kana, initial_process, split_mora, to_s16le_pcm, wav_from_s16le, DecoderFeature, - Mora, OjtPhoneme, + create_kana, initial_process, parse_kana, split_mora, to_s16le_pcm, wav_from_s16le, + DecoderFeature, Mora, OjtPhoneme, }, error::ErrorRepr, + future::FutureExt as _, infer::{ self, domains::{ @@ -25,10 +26,9 @@ use crate::{ }, InferenceRuntime, InferenceSessionOptions, }, + nonblocking::TextAnalyzer as _, status::Status, - text_analyzer::{KanaAnalyzer, OpenJTalkAnalyzer, TextAnalyzer}, - voice_model, AccentPhrase, AudioQuery, FullcontextExtractor, Result, StyleId, VoiceModelId, - VoiceModelMeta, + voice_model, AccentPhrase, AudioQuery, Result, StyleId, VoiceModelId, VoiceModelMeta, }; pub const DEFAULT_CPU_NUM_THREADS: u16 = 0; @@ -173,34 +173,52 @@ pub struct AudioFeature { audio_query: AudioQuery, } -struct Inner { +struct Inner { status: Arc>, - open_jtalk_analyzer: OpenJTalkAnalyzer, + text_analyzer: T, use_gpu: bool, _marker: PhantomData A>, } -struct InnerRefWithoutOpenJtalk<'a, A: Async> { +struct InnerRefWithoutTextAnalyzer<'a, A: Async> { status: &'a Arc>, use_gpu: bool, _marker: PhantomData A>, } -impl From> for Inner { - fn from(from: Inner) -> Self { +impl From> + for Inner>, SingleTasked> +{ + fn from(from: Inner) -> Self { Self { status: from.status, - open_jtalk_analyzer: from.open_jtalk_analyzer, + text_analyzer: AssumeSingleTasked(AssumeBlockable(from.text_analyzer)), use_gpu: from.use_gpu, _marker: PhantomData, } } } -impl Inner { +struct AssumeSingleTasked(T); + +impl crate::nonblocking::TextAnalyzer for AssumeSingleTasked { + async fn analyze(&self, text: &str) -> anyhow::Result> { + self.0.analyze(text) + } +} + +pub struct AssumeBlockable(T); + +impl crate::blocking::TextAnalyzer for AssumeBlockable { + fn analyze(&self, text: &str) -> anyhow::Result> { + self.0.analyze(text).block_on() + } +} + +impl Inner { fn new( onnxruntime: &'static crate::blocking::Onnxruntime, - open_jtalk: O, + text_analyzer: T, options: &InitializeOptions, ) -> Result { #[cfg(windows)] @@ -276,14 +294,14 @@ impl Inner { Ok(Self { status, - open_jtalk_analyzer: OpenJTalkAnalyzer::new(open_jtalk), + text_analyzer, use_gpu, _marker: PhantomData, }) } - fn without_open_jtalk(&self) -> InnerRefWithoutOpenJtalk<'_, A> { - InnerRefWithoutOpenJtalk { + fn without_text_analyzer(&self) -> InnerRefWithoutTextAnalyzer<'_, A> { + InnerRefWithoutTextAnalyzer { status: &self.status, use_gpu: self.use_gpu, _marker: PhantomData, @@ -292,10 +310,10 @@ impl Inner { } trait AsInner { - type OpenJtalk; + type TextAnalyzer; type Async: AsyncExt; fn status(&self) -> &Arc>; - fn open_jtalk_analyzer(&self) -> &OpenJTalkAnalyzer; + fn text_analyzer(&self) -> &Self::TextAnalyzer; fn use_gpu(&self) -> bool; fn onnxruntime(&self) -> &'static crate::blocking::Onnxruntime { @@ -416,7 +434,7 @@ trait AsInner { kana: &str, style_id: StyleId, ) -> Result> { - let accent_phrases = KanaAnalyzer.analyze(kana)?; + let accent_phrases = parse_kana(kana)?; self.replace_mora_data(&accent_phrases, style_id).await } @@ -632,15 +650,22 @@ trait AsInner { style_id: StyleId, ) -> Result> where - Self::OpenJtalk: FullcontextExtractor, + Self::TextAnalyzer: crate::nonblocking::TextAnalyzer, { - let accent_phrases = self.open_jtalk_analyzer().analyze(text)?; + let accent_phrases = + self.text_analyzer() + .analyze(text) + .await + .map_err(|source| ErrorRepr::AnalyzeText { + text: text.to_owned(), + source, + })?; self.replace_mora_data(&accent_phrases, style_id).await } async fn create_audio_query(&self, text: &str, style_id: StyleId) -> Result where - Self::OpenJtalk: FullcontextExtractor, + Self::TextAnalyzer: crate::nonblocking::TextAnalyzer, { let accent_phrases = self.create_accent_phrases(text, style_id).await?; Ok(AudioQuery::from_accent_phrases(accent_phrases)) @@ -648,7 +673,7 @@ trait AsInner { async fn tts(&self, text: &str, style_id: StyleId, options: &TtsOptions) -> Result> where - Self::OpenJtalk: FullcontextExtractor, + Self::TextAnalyzer: crate::nonblocking::TextAnalyzer, { let audio_query = &self.create_audio_query(text, style_id).await?; self.synthesis(audio_query, style_id, &SynthesisOptions::from(options)) @@ -755,16 +780,16 @@ trait AsInner { } } -impl AsInner for Inner { - type OpenJtalk = O; +impl AsInner for Inner { + type TextAnalyzer = T; type Async = A; fn status(&self) -> &Arc> { &self.status } - fn open_jtalk_analyzer(&self) -> &OpenJTalkAnalyzer { - &self.open_jtalk_analyzer + fn text_analyzer(&self) -> &Self::TextAnalyzer { + &self.text_analyzer } fn use_gpu(&self) -> bool { @@ -772,17 +797,16 @@ impl AsInner for Inner { } } -impl AsInner for InnerRefWithoutOpenJtalk<'_, A> { - type OpenJtalk = (); +impl AsInner for InnerRefWithoutTextAnalyzer<'_, A> { + type TextAnalyzer = (); type Async = A; fn status(&self) -> &Arc> { self.status } - fn open_jtalk_analyzer(&self) -> &OpenJTalkAnalyzer { - static OPEN_JTALK_ANALYZER: OpenJTalkAnalyzer<()> = OpenJTalkAnalyzer::new(()); - &OPEN_JTALK_ANALYZER + fn text_analyzer(&self) -> &Self::TextAnalyzer { + &() } fn use_gpu(&self) -> bool { @@ -1165,19 +1189,19 @@ pub(crate) mod blocking { use easy_ext::ext; use crate::{ - asyncs::SingleTasked, future::FutureExt as _, AccentPhrase, AudioQuery, - FullcontextExtractor, StyleId, VoiceModelId, VoiceModelMeta, + asyncs::SingleTasked, future::FutureExt as _, AccentPhrase, AudioQuery, StyleId, + VoiceModelId, VoiceModelMeta, }; use super::{ - AccelerationMode, AsInner as _, InitializeOptions, Inner, InnerRefWithoutOpenJtalk, - SynthesisOptions, TtsOptions, + AccelerationMode, AsInner as _, AssumeSingleTasked, InitializeOptions, Inner, + InnerRefWithoutTextAnalyzer, SynthesisOptions, TtsOptions, }; pub use super::AudioFeature; /// 音声シンセサイザ。 - pub struct Synthesizer(pub(super) Inner); + pub struct Synthesizer(pub(super) Inner, SingleTasked>); impl self::Synthesizer<()> { /// `Synthesizer`のビルダーをコンストラクトする。 @@ -1205,7 +1229,7 @@ pub(crate) mod blocking { /// # /// // FIXME: `Synthesizer`には`&mut self`なメソッドはもう無いはず /// let mut syntesizer = Synthesizer::builder(Onnxruntime::load_once().perform()?) - /// .open_jtalk(Arc::new(OpenJtalk::new(OPEN_JTALK_DIC_DIR).unwrap())) // FIXME: `Arc`は要らないはず + /// .text_analyzer(Arc::new(OpenJtalk::new(OPEN_JTALK_DIC_DIR).unwrap())) // FIXME: `Arc`は要らないはず /// .acceleration_mode(ACCELERATION_MODE) /// .build()?; /// # @@ -1215,13 +1239,13 @@ pub(crate) mod blocking { pub fn builder(onnxruntime: &'static crate::blocking::Onnxruntime) -> Builder<()> { Builder { onnxruntime, - open_jtalk: (), + text_analyzer: (), options: Default::default(), } } } - impl self::Synthesizer { + impl self::Synthesizer { pub fn onnxruntime(&self) -> &'static crate::blocking::Onnxruntime { self.0.onnxruntime() } @@ -1266,7 +1290,7 @@ pub(crate) mod blocking { style_id: StyleId, ) -> PrecomputeRender<'a> { PrecomputeRender { - synthesizer: self.0.without_open_jtalk(), + synthesizer: self.0.without_text_analyzer(), audio_query, style_id, options: Default::default(), @@ -1285,7 +1309,7 @@ pub(crate) mod blocking { style_id: StyleId, ) -> Synthesis<'a> { Synthesis { - synthesizer: self.0.without_open_jtalk(), + synthesizer: self.0.without_text_analyzer(), audio_query, style_id, options: Default::default(), @@ -1401,7 +1425,7 @@ pub(crate) mod blocking { /// AquesTalk風記法から音声合成を行う。 pub fn tts_from_kana<'a>(&'a self, kana: &'a str, style_id: StyleId) -> TtsFromKana<'a> { TtsFromKana { - synthesizer: self.0.without_open_jtalk(), + synthesizer: self.0.without_text_analyzer(), kana, style_id, options: TtsOptions::default(), @@ -1409,7 +1433,7 @@ pub(crate) mod blocking { } } - impl self::Synthesizer { + impl self::Synthesizer { /// 日本語のテキストからAccentPhrase (アクセント句)の配列を生成する。 /// /// # Example @@ -1479,7 +1503,7 @@ pub(crate) mod blocking { } /// 日本語のテキストから音声合成を行う。 - pub fn tts<'a>(&'a self, text: &'a str, style_id: StyleId) -> Tts<'a, O> { + pub fn tts<'a>(&'a self, text: &'a str, style_id: StyleId) -> Tts<'a, T> { Tts { synthesizer: &self.0, text, @@ -1616,16 +1640,16 @@ pub(crate) mod blocking { } #[must_use] - pub struct Builder { + pub struct Builder { onnxruntime: &'static crate::blocking::Onnxruntime, - open_jtalk: O, + text_analyzer: T, options: InitializeOptions, } - impl Builder { - pub fn open_jtalk(self, open_jtalk: O2) -> Builder { + impl Builder { + pub fn text_analyzer(self, text_analyzer: T2) -> Builder { Builder { - open_jtalk, + text_analyzer, onnxruntime: self.onnxruntime, options: self.options, } @@ -1643,14 +1667,19 @@ pub(crate) mod blocking { } /// [`Synthesizer`]をコンストラクトする。 - pub fn build(self) -> crate::Result> { - Inner::new(self.onnxruntime, self.open_jtalk, &self.options).map(Synthesizer) + pub fn build(self) -> crate::Result> { + Inner::new( + self.onnxruntime, + AssumeSingleTasked(self.text_analyzer), + &self.options, + ) + .map(Synthesizer) } } #[must_use = "this is a builder. it does nothing until `perform`ed"] pub struct PrecomputeRender<'a> { - synthesizer: InnerRefWithoutOpenJtalk<'a, SingleTasked>, + synthesizer: InnerRefWithoutTextAnalyzer<'a, SingleTasked>, audio_query: &'a AudioQuery, style_id: StyleId, options: SynthesisOptions, @@ -1672,7 +1701,7 @@ pub(crate) mod blocking { #[must_use = "this is a builder. it does nothing until `perform`ed"] pub struct Synthesis<'a> { - synthesizer: InnerRefWithoutOpenJtalk<'a, SingleTasked>, + synthesizer: InnerRefWithoutTextAnalyzer<'a, SingleTasked>, audio_query: &'a AudioQuery, style_id: StyleId, options: SynthesisOptions, @@ -1694,7 +1723,7 @@ pub(crate) mod blocking { #[must_use = "this is a builder. it does nothing until `perform`ed"] pub struct TtsFromKana<'a> { - synthesizer: InnerRefWithoutOpenJtalk<'a, SingleTasked>, + synthesizer: InnerRefWithoutTextAnalyzer<'a, SingleTasked>, kana: &'a str, style_id: StyleId, options: TtsOptions, @@ -1715,14 +1744,14 @@ pub(crate) mod blocking { } #[must_use = "this is a builder. it does nothing until `perform`ed"] - pub struct Tts<'a, O> { - synthesizer: &'a Inner, + pub struct Tts<'a, T> { + synthesizer: &'a Inner, SingleTasked>, text: &'a str, style_id: StyleId, options: TtsOptions, } - impl Tts<'_, O> { + impl Tts<'_, T> { pub fn enable_interrogative_upspeak(mut self, enable_interrogative_upspeak: bool) -> Self { self.options.enable_interrogative_upspeak = enable_interrogative_upspeak; self @@ -1741,13 +1770,13 @@ pub(crate) mod nonblocking { use easy_ext::ext; use crate::{ - asyncs::BlockingThreadPool, AccentPhrase, AudioQuery, FullcontextExtractor, Result, - StyleId, VoiceModelId, VoiceModelMeta, + asyncs::BlockingThreadPool, AccentPhrase, AudioQuery, Result, StyleId, VoiceModelId, + VoiceModelMeta, }; use super::{ - AccelerationMode, AsInner as _, InitializeOptions, Inner, InnerRefWithoutOpenJtalk, - SynthesisOptions, TtsOptions, + AccelerationMode, AsInner as _, AssumeBlockable, InitializeOptions, Inner, + InnerRefWithoutTextAnalyzer, SynthesisOptions, TtsOptions, }; /// 音声シンセサイザ。 @@ -1758,7 +1787,7 @@ pub(crate) mod nonblocking { /// /// [blocking]: https://docs.rs/crate/blocking /// [`nonblocking`モジュールのドキュメント]: crate::nonblocking - pub struct Synthesizer(pub(super) Inner); + pub struct Synthesizer(pub(super) Inner); impl self::Synthesizer<()> { /// `Synthesizer`のビルダーをコンストラクトする。 @@ -1787,7 +1816,7 @@ pub(crate) mod nonblocking { /// # /// // FIXME: `Synthesizer`には`&mut self`なメソッドはもう無いはず /// let mut syntesizer = Synthesizer::builder(Onnxruntime::load_once().perform().await?) - /// .open_jtalk(Arc::new(OpenJtalk::new(OPEN_JTALK_DIC_DIR).await.unwrap())) // FIXME: `Arc`は要らないはず + /// .text_analyzer(Arc::new(OpenJtalk::new(OPEN_JTALK_DIC_DIR).await.unwrap())) // FIXME: `Arc`は要らないはず /// .acceleration_mode(ACCELERATION_MODE) /// .build()?; /// # @@ -1797,13 +1826,13 @@ pub(crate) mod nonblocking { pub fn builder(onnxruntime: &'static crate::nonblocking::Onnxruntime) -> Builder<()> { Builder { onnxruntime, - open_jtalk: (), + text_analyzer: (), options: Default::default(), } } } - impl self::Synthesizer { + impl self::Synthesizer { pub fn onnxruntime(&self) -> &'static crate::nonblocking::Onnxruntime { crate::nonblocking::Onnxruntime::from_blocking(self.0.onnxruntime()) } @@ -1848,7 +1877,7 @@ pub(crate) mod nonblocking { style_id: StyleId, ) -> Synthesis<'a> { Synthesis { - synthesizer: self.0.without_open_jtalk(), + synthesizer: self.0.without_text_analyzer(), audio_query, style_id, options: Default::default(), @@ -1953,7 +1982,7 @@ pub(crate) mod nonblocking { /// AquesTalk風記法から音声合成を行う。 pub fn tts_from_kana<'a>(&'a self, kana: &'a str, style_id: StyleId) -> TtsFromKana<'a> { TtsFromKana { - synthesizer: self.0.without_open_jtalk(), + synthesizer: self.0.without_text_analyzer(), kana, style_id, options: Default::default(), @@ -1961,7 +1990,7 @@ pub(crate) mod nonblocking { } } - impl self::Synthesizer { + impl self::Synthesizer { /// 日本語のテキストからAccentPhrase (アクセント句)の配列を生成する。 /// /// # Example @@ -2040,23 +2069,24 @@ pub(crate) mod nonblocking { } #[ext(IntoBlocking)] - impl self::Synthesizer { - pub fn into_blocking(self) -> super::blocking::Synthesizer { - super::blocking::Synthesizer(self.0.into()) + impl self::Synthesizer { + pub fn into_blocking(self) -> super::blocking::Synthesizer> { + let x = self.0; + super::blocking::Synthesizer(x.into()) } } #[must_use] - pub struct Builder { + pub struct Builder { onnxruntime: &'static crate::nonblocking::Onnxruntime, - open_jtalk: O, + text_analyzer: T, options: InitializeOptions, } - impl Builder { - pub fn open_jtalk(self, open_jtalk: O2) -> Builder { + impl Builder { + pub fn text_analyzer(self, text_analyzer: T2) -> Builder { Builder { - open_jtalk, + text_analyzer, onnxruntime: self.onnxruntime, options: self.options, } @@ -2081,14 +2111,14 @@ pub(crate) mod nonblocking { } /// [`Synthesizer`]をコンストラクトする。 - pub fn build(self) -> crate::Result> { - Inner::new(&self.onnxruntime.0, self.open_jtalk, &self.options).map(Synthesizer) + pub fn build(self) -> crate::Result> { + Inner::new(&self.onnxruntime.0, self.text_analyzer, &self.options).map(Synthesizer) } } #[must_use = "this is a builder. it does nothing until `perform`ed"] pub struct Synthesis<'a> { - synthesizer: InnerRefWithoutOpenJtalk<'a, BlockingThreadPool>, + synthesizer: InnerRefWithoutTextAnalyzer<'a, BlockingThreadPool>, audio_query: &'a AudioQuery, style_id: StyleId, options: SynthesisOptions, @@ -2110,7 +2140,7 @@ pub(crate) mod nonblocking { #[must_use = "this is a builder. it does nothing until `perform`ed"] pub struct TtsFromKana<'a> { - synthesizer: InnerRefWithoutOpenJtalk<'a, BlockingThreadPool>, + synthesizer: InnerRefWithoutTextAnalyzer<'a, BlockingThreadPool>, kana: &'a str, style_id: StyleId, options: TtsOptions, @@ -2131,14 +2161,14 @@ pub(crate) mod nonblocking { } #[must_use = "this is a builder. it does nothing until `perform`ed"] - pub struct Tts<'a, O> { - synthesizer: &'a Inner, + pub struct Tts<'a, T> { + synthesizer: &'a Inner, text: &'a str, style_id: StyleId, options: TtsOptions, } - impl Tts<'_, O> { + impl Tts<'_, T> { pub fn enable_interrogative_upspeak(mut self, enable_interrogative_upspeak: bool) -> Self { self.options.enable_interrogative_upspeak = enable_interrogative_upspeak; self @@ -2536,7 +2566,7 @@ mod tests { .await .unwrap(), ) - .open_jtalk( + .text_analyzer( crate::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(), @@ -2607,7 +2637,7 @@ mod tests { .await .unwrap(), ) - .open_jtalk( + .text_analyzer( crate::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(), @@ -2675,7 +2705,7 @@ mod tests { .await .unwrap(), ) - .open_jtalk( + .text_analyzer( crate::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(), @@ -2738,7 +2768,7 @@ mod tests { .await .unwrap(), ) - .open_jtalk( + .text_analyzer( crate::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(), @@ -2779,7 +2809,7 @@ mod tests { .await .unwrap(), ) - .open_jtalk( + .text_analyzer( crate::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(), @@ -2820,7 +2850,7 @@ mod tests { .await .unwrap(), ) - .open_jtalk( + .text_analyzer( crate::nonblocking::OpenJtalk::new(OPEN_JTALK_DIC_DIR) .await .unwrap(), diff --git a/crates/voicevox_core/src/text_analyzer.rs b/crates/voicevox_core/src/text_analyzer.rs index fa53f2e47..3126ce472 100644 --- a/crates/voicevox_core/src/text_analyzer.rs +++ b/crates/voicevox_core/src/text_analyzer.rs @@ -1,40 +1,20 @@ -use crate::{ - engine::{extract_full_context_label, parse_kana}, - AccentPhrase, FullcontextExtractor, Result, -}; +pub(crate) mod blocking { + use crate::AccentPhrase; -pub(crate) trait TextAnalyzer { - fn analyze(&self, text: &str) -> Result>; -} - -/// AquesTalk風記法からAccentPhraseの配列を生成するTextAnalyzer -#[derive(Clone)] -pub(crate) struct KanaAnalyzer; - -impl TextAnalyzer for KanaAnalyzer { - fn analyze(&self, text: &str) -> Result> { - if text.is_empty() { - return Ok(Vec::new()); - } - Ok(parse_kana(text)?) + pub trait TextAnalyzer: Sync { + fn analyze(&self, text: &str) -> anyhow::Result>; } } -/// OpenJtalkからAccentPhraseの配列を生成するTextAnalyzer -#[derive(Clone)] -pub(crate) struct OpenJTalkAnalyzer(O); +pub(crate) mod nonblocking { + use std::future::Future; -impl OpenJTalkAnalyzer { - pub(crate) const fn new(open_jtalk: O) -> Self { - Self(open_jtalk) - } -} + use crate::AccentPhrase; -impl TextAnalyzer for OpenJTalkAnalyzer { - fn analyze(&self, text: &str) -> Result> { - if text.is_empty() { - return Ok(Vec::new()); - } - Ok(extract_full_context_label(&self.0, text)?) + pub trait TextAnalyzer: Sync { + fn analyze( + &self, + text: &str, + ) -> impl Future>> + Send; } } diff --git a/crates/voicevox_core_c_api/include/voicevox_core.h b/crates/voicevox_core_c_api/include/voicevox_core.h index f7de66b49..979712565 100644 --- a/crates/voicevox_core_c_api/include/voicevox_core.h +++ b/crates/voicevox_core_c_api/include/voicevox_core.h @@ -143,9 +143,9 @@ enum VoicevoxResultCode */ VOICEVOX_RESULT_RUN_MODEL_ERROR = 8, /** - * コンテキストラベル出力に失敗した + * 入力テキストの解析に失敗した */ - VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR = 11, + VOICEVOX_RESULT_ANALYZE_TEXT_ERROR = 11, /** * 無効なutf8文字列が入力された */ diff --git a/crates/voicevox_core_c_api/src/c_impls.rs b/crates/voicevox_core_c_api/src/c_impls.rs index 8322325ef..939f0ddfb 100644 --- a/crates/voicevox_core_c_api/src/c_impls.rs +++ b/crates/voicevox_core_c_api/src/c_impls.rs @@ -86,7 +86,7 @@ impl VoicevoxSynthesizer { }: VoicevoxInitializeOptions, ) -> Result> { let body = voicevox_core::blocking::Synthesizer::builder(&onnxruntime.0) - .open_jtalk(open_jtalk.body().clone()) + .text_analyzer(open_jtalk.body().clone()) .acceleration_mode(acceleration_mode.into()) .cpu_num_threads(cpu_num_threads) .build()?; diff --git a/crates/voicevox_core_c_api/src/helpers.rs b/crates/voicevox_core_c_api/src/helpers.rs index 0867aa9b0..51e876e3e 100644 --- a/crates/voicevox_core_c_api/src/helpers.rs +++ b/crates/voicevox_core_c_api/src/helpers.rs @@ -40,7 +40,7 @@ pub(crate) fn into_result_code_with_error(result: CApiResult<()>) -> VoicevoxRes StyleNotFound => VOICEVOX_RESULT_STYLE_NOT_FOUND_ERROR, ModelNotFound => VOICEVOX_RESULT_MODEL_NOT_FOUND_ERROR, RunModel => VOICEVOX_RESULT_RUN_MODEL_ERROR, - ExtractFullContextLabel => VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR, + AnalyzeText => VOICEVOX_RESULT_ANALYZE_TEXT_ERROR, ParseKana => VOICEVOX_RESULT_PARSE_KANA_ERROR, LoadUserDict => VOICEVOX_RESULT_LOAD_USER_DICT_ERROR, SaveUserDict => VOICEVOX_RESULT_SAVE_USER_DICT_ERROR, diff --git a/crates/voicevox_core_c_api/src/result_code.rs b/crates/voicevox_core_c_api/src/result_code.rs index 645eb289b..d2412f4cf 100644 --- a/crates/voicevox_core_c_api/src/result_code.rs +++ b/crates/voicevox_core_c_api/src/result_code.rs @@ -24,8 +24,8 @@ pub enum VoicevoxResultCode { VOICEVOX_RESULT_MODEL_NOT_FOUND_ERROR = 7, /// 推論に失敗した VOICEVOX_RESULT_RUN_MODEL_ERROR = 8, - /// コンテキストラベル出力に失敗した - VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR = 11, + /// 入力テキストの解析に失敗した + VOICEVOX_RESULT_ANALYZE_TEXT_ERROR = 11, /// 無効なutf8文字列が入力された VOICEVOX_RESULT_INVALID_UTF8_INPUT_ERROR = 12, /// AquesTalk風記法のテキストの解析に失敗した @@ -81,9 +81,7 @@ pub(crate) const fn error_result_to_message(result_code: VoicevoxResultCode) -> が既に解除されています" } VOICEVOX_RESULT_RUN_MODEL_ERROR => c"推論に失敗しました", - VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR => { - c"入力テキストからのフルコンテキストラベル抽出に失敗しました" - } + VOICEVOX_RESULT_ANALYZE_TEXT_ERROR => c"入力テキストの解析に失敗しました", VOICEVOX_RESULT_INVALID_UTF8_INPUT_ERROR => c"入力テキストが無効なUTF-8データでした", VOICEVOX_RESULT_PARSE_KANA_ERROR => { c"入力テキストをAquesTalk風記法としてパースすることに失敗しました" diff --git a/crates/voicevox_core_c_api/tests/e2e/snapshots.toml b/crates/voicevox_core_c_api/tests/e2e/snapshots.toml index f6b9f6928..e8bbb9a0a 100644 --- a/crates/voicevox_core_c_api/tests/e2e/snapshots.toml +++ b/crates/voicevox_core_c_api/tests/e2e/snapshots.toml @@ -118,7 +118,7 @@ result_messages.4 = "GPU機能をサポートすることができません" result_messages.6 = "指定されたIDに対するスタイルが見つかりませんでした。音声モデルが読み込まれていないか、読み込みが解除されています" result_messages.7 = "指定されたIDに対する音声モデルが見つかりませんでした。読み込まれていないか、読み込みが既に解除されています" result_messages.8 = "推論に失敗しました" -result_messages.11 = "入力テキストからのフルコンテキストラベル抽出に失敗しました" +result_messages.11 = "入力テキストの解析に失敗しました" result_messages.12 = "入力テキストが無効なUTF-8データでした" result_messages.13 = "入力テキストをAquesTalk風記法としてパースすることに失敗しました" result_messages.14 = "無効なaudio_queryです" diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/global_info.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/global_info.rs index fe9d518a1..c4dd21c32 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/global_info.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/global_info.rs @@ -77,7 +77,7 @@ impl assert_cdylib::TestCase for TestCase { c_api::VoicevoxResultCode_VOICEVOX_RESULT_STYLE_NOT_FOUND_ERROR, c_api::VoicevoxResultCode_VOICEVOX_RESULT_MODEL_NOT_FOUND_ERROR, c_api::VoicevoxResultCode_VOICEVOX_RESULT_RUN_MODEL_ERROR, - c_api::VoicevoxResultCode_VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR, + c_api::VoicevoxResultCode_VOICEVOX_RESULT_ANALYZE_TEXT_ERROR, c_api::VoicevoxResultCode_VOICEVOX_RESULT_INVALID_UTF8_INPUT_ERROR, c_api::VoicevoxResultCode_VOICEVOX_RESULT_PARSE_KANA_ERROR, c_api::VoicevoxResultCode_VOICEVOX_RESULT_INVALID_AUDIO_QUERY_ERROR, diff --git a/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/AnalyzeTextException.java b/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/AnalyzeTextException.java new file mode 100644 index 000000000..3d9280232 --- /dev/null +++ b/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/AnalyzeTextException.java @@ -0,0 +1,12 @@ +package jp.hiroshiba.voicevoxcore.exceptions; + +/** 入力テキストの解析に失敗した。 */ +public class AnalyzeTextException extends IllegalArgumentException { + public AnalyzeTextException(String message) { + super(message); + } + + public AnalyzeTextException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/ExtractFullContextLabelException.java b/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/ExtractFullContextLabelException.java deleted file mode 100644 index 2bae2a5e8..000000000 --- a/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/exceptions/ExtractFullContextLabelException.java +++ /dev/null @@ -1,12 +0,0 @@ -package jp.hiroshiba.voicevoxcore.exceptions; - -/** コンテキストラベル出力に失敗した。 */ -public class ExtractFullContextLabelException extends IllegalArgumentException { - public ExtractFullContextLabelException(String message) { - super(message); - } - - public ExtractFullContextLabelException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/crates/voicevox_core_java_api/src/common.rs b/crates/voicevox_core_java_api/src/common.rs index cb2a89a7f..0648033a4 100644 --- a/crates/voicevox_core_java_api/src/common.rs +++ b/crates/voicevox_core_java_api/src/common.rs @@ -85,7 +85,7 @@ where StyleNotFound, ModelNotFound, RunModel, - ExtractFullContextLabel, + AnalyzeText, ParseKana, LoadUserDict, SaveUserDict, diff --git a/crates/voicevox_core_java_api/src/synthesizer.rs b/crates/voicevox_core_java_api/src/synthesizer.rs index ddbbf1ec6..2067d0c92 100644 --- a/crates/voicevox_core_java_api/src/synthesizer.rs +++ b/crates/voicevox_core_java_api/src/synthesizer.rs @@ -59,7 +59,7 @@ unsafe extern "system" fn Java_jp_hiroshiba_voicevoxcore_blocking_Synthesizer_rs .clone(); let internal = Arc::new( voicevox_core::blocking::Synthesizer::builder(onnxruntime) - .open_jtalk(open_jtalk) + .text_analyzer(open_jtalk) .acceleration_mode(acceleration_mode) .cpu_num_threads(cpu_num_threads) .build()?, diff --git a/crates/voicevox_core_python_api/python/voicevox_core/__init__.py b/crates/voicevox_core_python_api/python/voicevox_core/__init__.py index 3e68bf455..65e89c681 100644 --- a/crates/voicevox_core_python_api/python/voicevox_core/__init__.py +++ b/crates/voicevox_core_python_api/python/voicevox_core/__init__.py @@ -15,7 +15,7 @@ VoiceModelId, ) from ._rust import ( # noqa: F401 - ExtractFullContextLabelError, + AnalyzeTextError, GetSupportedDevicesError, GpuSupportError, InitInferenceRuntimeError, @@ -45,10 +45,10 @@ "wav_from_s16le", "AccelerationMode", "AccentPhrase", + "AnalyzeTextError", "AudioQuery", "asyncio", "blocking", - "ExtractFullContextLabelError", "GetSupportedDevicesError", "GpuSupportError", "InitInferenceRuntimeError", diff --git a/crates/voicevox_core_python_api/python/voicevox_core/_rust/__init__.pyi b/crates/voicevox_core_python_api/python/voicevox_core/_rust/__init__.pyi index 8099d9a9d..e7e44c2b0 100644 --- a/crates/voicevox_core_python_api/python/voicevox_core/_rust/__init__.pyi +++ b/crates/voicevox_core_python_api/python/voicevox_core/_rust/__init__.pyi @@ -65,8 +65,8 @@ class RunModelError(Exception): ... -class ExtractFullContextLabelError(Exception): - """コンテキストラベル出力に失敗した。""" +class AnalyzeTextError(Exception): + """入力テキストの解析に失敗した。""" ... diff --git a/crates/voicevox_core_python_api/src/convert.rs b/crates/voicevox_core_python_api/src/convert.rs index 711da5fe4..416dc2ac1 100644 --- a/crates/voicevox_core_python_api/src/convert.rs +++ b/crates/voicevox_core_python_api/src/convert.rs @@ -13,11 +13,11 @@ use uuid::Uuid; use voicevox_core::{AccelerationMode, AccentPhrase, StyleId, UserDictWordType, VoiceModelMeta}; use crate::{ - ExtractFullContextLabelError, GetSupportedDevicesError, GpuSupportError, - InitInferenceRuntimeError, InvalidModelDataError, InvalidModelFormatError, InvalidWordError, - LoadUserDictError, ModelAlreadyLoadedError, ModelNotFoundError, NotLoadedOpenjtalkDictError, - OpenZipFileError, ParseKanaError, ReadZipEntryError, RunModelError, SaveUserDictError, - StyleAlreadyLoadedError, StyleNotFoundError, UseUserDictError, WordNotFoundError, + AnalyzeTextError, GetSupportedDevicesError, GpuSupportError, InitInferenceRuntimeError, + InvalidModelDataError, InvalidModelFormatError, InvalidWordError, LoadUserDictError, + ModelAlreadyLoadedError, ModelNotFoundError, NotLoadedOpenjtalkDictError, OpenZipFileError, + ParseKanaError, ReadZipEntryError, RunModelError, SaveUserDictError, StyleAlreadyLoadedError, + StyleNotFoundError, UseUserDictError, WordNotFoundError, }; pub(crate) fn from_acceleration_mode(ob: &PyAny) -> PyResult { @@ -234,7 +234,7 @@ pub(crate) impl voicevox_core::Result { ErrorKind::StyleNotFound => StyleNotFoundError::new_err(msg), ErrorKind::ModelNotFound => ModelNotFoundError::new_err(msg), ErrorKind::RunModel => RunModelError::new_err(msg), - ErrorKind::ExtractFullContextLabel => ExtractFullContextLabelError::new_err(msg), + ErrorKind::AnalyzeText => AnalyzeTextError::new_err(msg), ErrorKind::ParseKana => ParseKanaError::new_err(msg), ErrorKind::LoadUserDict => LoadUserDictError::new_err(msg), ErrorKind::SaveUserDict => SaveUserDictError::new_err(msg), diff --git a/crates/voicevox_core_python_api/src/lib.rs b/crates/voicevox_core_python_api/src/lib.rs index abb845f18..d9a9341f4 100644 --- a/crates/voicevox_core_python_api/src/lib.rs +++ b/crates/voicevox_core_python_api/src/lib.rs @@ -92,7 +92,7 @@ exceptions! { StyleNotFoundError: PyKeyError; ModelNotFoundError: PyKeyError; RunModelError: PyException; - ExtractFullContextLabelError: PyException; + AnalyzeTextError: PyException; ParseKanaError: PyValueError; LoadUserDictError: PyException; SaveUserDictError: PyException; @@ -494,7 +494,7 @@ mod blocking { py: Python<'_>, ) -> PyResult { let inner = voicevox_core::blocking::Synthesizer::builder(onnxruntime.0) - .open_jtalk(open_jtalk.open_jtalk.clone()) + .text_analyzer(open_jtalk.open_jtalk.clone()) .acceleration_mode(acceleration_mode) .cpu_num_threads(cpu_num_threads) .build() @@ -1089,7 +1089,7 @@ mod asyncio { cpu_num_threads: u16, ) -> PyResult { let synthesizer = voicevox_core::nonblocking::Synthesizer::builder(onnxruntime.0) - .open_jtalk(open_jtalk.open_jtalk.clone()) + .text_analyzer(open_jtalk.open_jtalk.clone()) .acceleration_mode(acceleration_mode) .cpu_num_threads(cpu_num_threads) .build();