diff --git a/crates/voicevox_core/src/error.rs b/crates/voicevox_core/src/error.rs index c4436f450..7ad258a34 100644 --- a/crates/voicevox_core/src/error.rs +++ b/crates/voicevox_core/src/error.rs @@ -27,13 +27,19 @@ pub enum Error { #[source] source: anyhow::Error, }, - #[error("{} ({})", base_error_message(VOICEVOX_ALREADY_LOADED_MODEL_ERROR), path.display())] + #[error("{} ({})", base_error_message(VOICEVOX_RESULT_ALREADY_LOADED_MODEL_ERROR), path.display())] AlreadyLoadedModel { path: PathBuf }, - #[error("{} ({model_id:?})", base_error_message(VOICEVOX_UNLOADED_MODEL_ERROR))] + #[error( + "{} ({model_id:?})", + base_error_message(VOICEVOX_RESULT_UNLOADED_MODEL_ERROR) + )] UnloadedModel { model_id: VoiceModelId }, - #[error("{}({path}):{source}", base_error_message(VOICEVOX_OPEN_FILE_ERROR))] + #[error( + "{}({path}):{source}", + base_error_message(VOICEVOX_RESULT_OPEN_FILE_ERROR) + )] OpenFile { path: PathBuf, #[source] @@ -42,7 +48,7 @@ pub enum Error { #[error( "{}({path}):{source}", - base_error_message(VOICEVOX_VVM_MODEL_READ_ERROR) + base_error_message(VOICEVOX_RESULT_VVM_MODEL_READ_ERROR) )] VvmRead { path: PathBuf, @@ -83,19 +89,25 @@ pub enum Error { #[error("{},{0}", base_error_message(VOICEVOX_RESULT_PARSE_KANA_ERROR))] ParseKana(#[from] KanaParseError), - #[error("{}: {0}", base_error_message(VOICEVOX_LOAD_USER_DICT_ERROR))] + #[error("{}: {0}", base_error_message(VOICEVOX_RESULT_LOAD_USER_DICT_ERROR))] LoadUserDict(String), - #[error("{}: {0}", base_error_message(VOICEVOX_SAVE_USER_DICT_ERROR))] + #[error("{}: {0}", base_error_message(VOICEVOX_RESULT_SAVE_USER_DICT_ERROR))] SaveUserDict(String), - #[error("{}: {0}", base_error_message(VOICEVOX_UNKNOWN_USER_DICT_WORD_ERROR))] + #[error( + "{}: {0}", + base_error_message(VOICEVOX_RESULT_UNKNOWN_USER_DICT_WORD_ERROR) + )] UnknownWord(Uuid), - #[error("{}: {0}", base_error_message(VOICEVOX_USE_USER_DICT_ERROR))] + #[error("{}: {0}", base_error_message(VOICEVOX_RESULT_USE_USER_DICT_ERROR))] UseUserDict(String), - #[error("{}: {0}", base_error_message(VOICEVOX_INVALID_USER_DICT_WORD_ERROR))] + #[error( + "{}: {0}", + base_error_message(VOICEVOX_RESULT_INVALID_USER_DICT_WORD_ERROR) + )] InvalidWord(InvalidWordError), } diff --git a/crates/voicevox_core/src/result_code.rs b/crates/voicevox_core/src/result_code.rs index a89633bfe..07cf05e18 100644 --- a/crates/voicevox_core/src/result_code.rs +++ b/crates/voicevox_core/src/result_code.rs @@ -36,23 +36,23 @@ pub enum VoicevoxResultCode { /// 無効なAccentPhrase VOICEVOX_RESULT_INVALID_ACCENT_PHRASE_ERROR = 15, /// ファイルオープンエラー - VOICEVOX_OPEN_FILE_ERROR = 16, + VOICEVOX_RESULT_OPEN_FILE_ERROR = 16, /// Modelを読み込めなかった - VOICEVOX_VVM_MODEL_READ_ERROR = 17, + VOICEVOX_RESULT_VVM_MODEL_READ_ERROR = 17, /// すでに読み込まれているModelを読み込もうとした - VOICEVOX_ALREADY_LOADED_MODEL_ERROR = 18, + VOICEVOX_RESULT_ALREADY_LOADED_MODEL_ERROR = 18, /// Modelが読み込まれていない - VOICEVOX_UNLOADED_MODEL_ERROR = 19, + VOICEVOX_RESULT_UNLOADED_MODEL_ERROR = 19, /// ユーザー辞書を読み込めなかった - VOICEVOX_LOAD_USER_DICT_ERROR = 20, + VOICEVOX_RESULT_LOAD_USER_DICT_ERROR = 20, /// ユーザー辞書を書き込めなかった - VOICEVOX_SAVE_USER_DICT_ERROR = 21, + VOICEVOX_RESULT_SAVE_USER_DICT_ERROR = 21, /// ユーザー辞書に単語が見つからなかった - VOICEVOX_UNKNOWN_USER_DICT_WORD_ERROR = 22, + VOICEVOX_RESULT_UNKNOWN_USER_DICT_WORD_ERROR = 22, /// OpenJTalkのユーザー辞書の設定に失敗した - VOICEVOX_USE_USER_DICT_ERROR = 23, + VOICEVOX_RESULT_USE_USER_DICT_ERROR = 23, /// ユーザー辞書の単語のバリデーションに失敗した - VOICEVOX_INVALID_USER_DICT_WORD_ERROR = 24, + VOICEVOX_RESULT_INVALID_USER_DICT_WORD_ERROR = 24, /// UUIDの変換に失敗した VOICEVOX_RESULT_INVALID_UUID_ERROR = 25, } @@ -85,17 +85,19 @@ pub const fn error_result_to_message(result_code: VoicevoxResultCode) -> &'stati } VOICEVOX_RESULT_INVALID_AUDIO_QUERY_ERROR => "無効なaudio_queryです\0", VOICEVOX_RESULT_INVALID_ACCENT_PHRASE_ERROR => "無効なaccent_phraseです\0", - VOICEVOX_OPEN_FILE_ERROR => "ファイルオープンに失敗しました\0", - VOICEVOX_VVM_MODEL_READ_ERROR => "Modelを読み込めませんでした\0", - VOICEVOX_ALREADY_LOADED_MODEL_ERROR => { + VOICEVOX_RESULT_OPEN_FILE_ERROR => "ファイルオープンに失敗しました\0", + VOICEVOX_RESULT_VVM_MODEL_READ_ERROR => "Modelを読み込めませんでした\0", + VOICEVOX_RESULT_ALREADY_LOADED_MODEL_ERROR => { "すでに読み込まれているModelを読み込もうとしました\0" } - VOICEVOX_UNLOADED_MODEL_ERROR => "Modelが読み込まれていません\0", - VOICEVOX_LOAD_USER_DICT_ERROR => "ユーザー辞書を読み込めませんでした\0", - VOICEVOX_SAVE_USER_DICT_ERROR => "ユーザー辞書を書き込めませんでした\0", - VOICEVOX_UNKNOWN_USER_DICT_WORD_ERROR => "ユーザー辞書に単語が見つかりませんでした\0", - VOICEVOX_USE_USER_DICT_ERROR => "OpenJTalkのユーザー辞書の設定に失敗しました\0", - VOICEVOX_INVALID_USER_DICT_WORD_ERROR => { + VOICEVOX_RESULT_UNLOADED_MODEL_ERROR => "Modelが読み込まれていません\0", + VOICEVOX_RESULT_LOAD_USER_DICT_ERROR => "ユーザー辞書を読み込めませんでした\0", + VOICEVOX_RESULT_SAVE_USER_DICT_ERROR => "ユーザー辞書を書き込めませんでした\0", + VOICEVOX_RESULT_UNKNOWN_USER_DICT_WORD_ERROR => { + "ユーザー辞書に単語が見つかりませんでした\0" + } + VOICEVOX_RESULT_USE_USER_DICT_ERROR => "OpenJTalkのユーザー辞書の設定に失敗しました\0", + VOICEVOX_RESULT_INVALID_USER_DICT_WORD_ERROR => { "ユーザー辞書の単語のバリデーションに失敗しました\0" } VOICEVOX_RESULT_INVALID_UUID_ERROR => "UUIDの変換に失敗しました\0", diff --git a/crates/voicevox_core_c_api/include/voicevox_core.h b/crates/voicevox_core_c_api/include/voicevox_core.h index 9f83cef39..df2798486 100644 --- a/crates/voicevox_core_c_api/include/voicevox_core.h +++ b/crates/voicevox_core_c_api/include/voicevox_core.h @@ -145,39 +145,39 @@ enum VoicevoxResultCode /** * ファイルオープンエラー */ - VOICEVOX_OPEN_FILE_ERROR = 16, + VOICEVOX_RESULT_OPEN_FILE_ERROR = 16, /** * Modelを読み込めなかった */ - VOICEVOX_VVM_MODEL_READ_ERROR = 17, + VOICEVOX_RESULT_VVM_MODEL_READ_ERROR = 17, /** * すでに読み込まれているModelを読み込もうとした */ - VOICEVOX_ALREADY_LOADED_MODEL_ERROR = 18, + VOICEVOX_RESULT_ALREADY_LOADED_MODEL_ERROR = 18, /** * Modelが読み込まれていない */ - VOICEVOX_UNLOADED_MODEL_ERROR = 19, + VOICEVOX_RESULT_UNLOADED_MODEL_ERROR = 19, /** * ユーザー辞書を読み込めなかった */ - VOICEVOX_LOAD_USER_DICT_ERROR = 20, + VOICEVOX_RESULT_LOAD_USER_DICT_ERROR = 20, /** * ユーザー辞書を書き込めなかった */ - VOICEVOX_SAVE_USER_DICT_ERROR = 21, + VOICEVOX_RESULT_SAVE_USER_DICT_ERROR = 21, /** * ユーザー辞書に単語が見つからなかった */ - VOICEVOX_UNKNOWN_USER_DICT_WORD_ERROR = 22, + VOICEVOX_RESULT_UNKNOWN_USER_DICT_WORD_ERROR = 22, /** * OpenJTalkのユーザー辞書の設定に失敗した */ - VOICEVOX_USE_USER_DICT_ERROR = 23, + VOICEVOX_RESULT_USE_USER_DICT_ERROR = 23, /** * ユーザー辞書の単語のバリデーションに失敗した */ - VOICEVOX_INVALID_USER_DICT_WORD_ERROR = 24, + VOICEVOX_RESULT_INVALID_USER_DICT_WORD_ERROR = 24, /** * UUIDの変換に失敗した */ @@ -291,7 +291,7 @@ typedef struct VoicevoxInitializeOptions { typedef uint32_t VoicevoxStyleId; /** - * ::voicevox_synthesizer_audio_query のオプション。 + * ::voicevox_synthesizer_create_audio_query のオプション。 */ typedef struct VoicevoxAudioQueryOptions { /** @@ -680,20 +680,20 @@ VoicevoxResultCode voicevox_create_supported_devices_json(char **output_supporte * \examples{ * ```c * char *audio_query; - * voicevox_synthesizer_audio_query(synthesizer, - * "こんにちは", // 日本語テキスト - * 2, // "四国めたん (ノーマル)" - * (VoicevoxAudioQueryOptions){.kana = false}, - * &audio_query); + * voicevox_synthesizer_create_audio_query(synthesizer, + * "こんにちは", // 日本語テキスト + * 2, // "四国めたん (ノーマル)" + * (VoicevoxAudioQueryOptions){.kana = false}, + * &audio_query); * ``` * * ```c * char *audio_query; - * voicevox_synthesizer_audio_query(synthesizer, - * "コンニチワ'", // AquesTalk風記法 - * 2, // "四国めたん (ノーマル)" - * (VoicevoxAudioQueryOptions){.kana = true}, - * &audio_query); + * voicevox_synthesizer_create_audio_query(synthesizer, + * "コンニチワ'", // AquesTalk風記法 + * 2, // "四国めたん (ノーマル)" + * (VoicevoxAudioQueryOptions){.kana = true}, + * &audio_query); * ``` * } * @@ -707,11 +707,11 @@ VoicevoxResultCode voicevox_create_supported_devices_json(char **output_supporte #ifdef _WIN32 __declspec(dllimport) #endif -VoicevoxResultCode voicevox_synthesizer_audio_query(const struct VoicevoxSynthesizer *synthesizer, - const char *text, - VoicevoxStyleId style_id, - struct VoicevoxAudioQueryOptions options, - char **output_audio_query_json); +VoicevoxResultCode voicevox_synthesizer_create_audio_query(const struct VoicevoxSynthesizer *synthesizer, + const char *text, + VoicevoxStyleId style_id, + struct VoicevoxAudioQueryOptions options, + char **output_audio_query_json); /** * AccentPhrase (アクセント句)の配列をJSON形式で生成する。 @@ -909,7 +909,7 @@ VoicevoxResultCode voicevox_synthesizer_tts(const struct VoicevoxSynthesizer *sy * \safety{ * - `json`は以下のAPIで得られたポインタでなくてはいけない。 * - ::voicevox_create_supported_devices_json - * - ::voicevox_synthesizer_audio_query + * - ::voicevox_synthesizer_create_audio_query * - ::voicevox_synthesizer_create_accent_phrases * - ::voicevox_synthesizer_replace_mora_data * - ::voicevox_synthesizer_replace_phoneme_length diff --git a/crates/voicevox_core_c_api/src/helpers.rs b/crates/voicevox_core_c_api/src/helpers.rs index 15c3dd3cc..1be3109ed 100644 --- a/crates/voicevox_core_c_api/src/helpers.rs +++ b/crates/voicevox_core_c_api/src/helpers.rs @@ -35,16 +35,16 @@ pub(crate) fn into_result_code_with_error(result: CApiResult<()>) -> VoicevoxRes Err(RustApi(ExtractFullContextLabel(_))) => { VOICEVOX_RESULT_EXTRACT_FULL_CONTEXT_LABEL_ERROR } - Err(RustApi(UnloadedModel { .. })) => VOICEVOX_UNLOADED_MODEL_ERROR, - Err(RustApi(AlreadyLoadedModel { .. })) => VOICEVOX_ALREADY_LOADED_MODEL_ERROR, - Err(RustApi(OpenFile { .. })) => VOICEVOX_OPEN_FILE_ERROR, - Err(RustApi(VvmRead { .. })) => VOICEVOX_VVM_MODEL_READ_ERROR, + Err(RustApi(UnloadedModel { .. })) => VOICEVOX_RESULT_UNLOADED_MODEL_ERROR, + Err(RustApi(AlreadyLoadedModel { .. })) => VOICEVOX_RESULT_ALREADY_LOADED_MODEL_ERROR, + Err(RustApi(OpenFile { .. })) => VOICEVOX_RESULT_OPEN_FILE_ERROR, + Err(RustApi(VvmRead { .. })) => VOICEVOX_RESULT_VVM_MODEL_READ_ERROR, Err(RustApi(ParseKana(_))) => VOICEVOX_RESULT_PARSE_KANA_ERROR, - Err(RustApi(LoadUserDict(_))) => VOICEVOX_LOAD_USER_DICT_ERROR, - Err(RustApi(SaveUserDict(_))) => VOICEVOX_SAVE_USER_DICT_ERROR, - Err(RustApi(UnknownWord(_))) => VOICEVOX_UNKNOWN_USER_DICT_WORD_ERROR, - Err(RustApi(UseUserDict(_))) => VOICEVOX_USE_USER_DICT_ERROR, - Err(RustApi(InvalidWord(_))) => VOICEVOX_INVALID_USER_DICT_WORD_ERROR, + Err(RustApi(LoadUserDict(_))) => VOICEVOX_RESULT_LOAD_USER_DICT_ERROR, + Err(RustApi(SaveUserDict(_))) => VOICEVOX_RESULT_SAVE_USER_DICT_ERROR, + Err(RustApi(UnknownWord(_))) => VOICEVOX_RESULT_UNKNOWN_USER_DICT_WORD_ERROR, + Err(RustApi(UseUserDict(_))) => VOICEVOX_RESULT_USE_USER_DICT_ERROR, + Err(RustApi(InvalidWord(_))) => VOICEVOX_RESULT_INVALID_USER_DICT_WORD_ERROR, Err(InvalidUtf8Input) => VOICEVOX_RESULT_INVALID_UTF8_INPUT_ERROR, Err(InvalidAudioQuery(_)) => VOICEVOX_RESULT_INVALID_AUDIO_QUERY_ERROR, Err(InvalidAccentPhrase(_)) => VOICEVOX_RESULT_INVALID_ACCENT_PHRASE_ERROR, diff --git a/crates/voicevox_core_c_api/src/lib.rs b/crates/voicevox_core_c_api/src/lib.rs index 827654da5..4b6bba670 100644 --- a/crates/voicevox_core_c_api/src/lib.rs +++ b/crates/voicevox_core_c_api/src/lib.rs @@ -497,7 +497,7 @@ pub unsafe extern "C" fn voicevox_create_supported_devices_json( })()) } -/// ::voicevox_synthesizer_audio_query のオプション。 +/// ::voicevox_synthesizer_create_audio_query のオプション。 #[repr(C)] pub struct VoicevoxAudioQueryOptions { /// AquesTalk風記法としてテキストを解釈する @@ -523,20 +523,20 @@ pub static voicevox_default_audio_query_options: VoicevoxAudioQueryOptions = Con /// \examples{ /// ```c /// char *audio_query; -/// voicevox_synthesizer_audio_query(synthesizer, -/// "こんにちは", // 日本語テキスト -/// 2, // "四国めたん (ノーマル)" -/// (VoicevoxAudioQueryOptions){.kana = false}, -/// &audio_query); +/// voicevox_synthesizer_create_audio_query(synthesizer, +/// "こんにちは", // 日本語テキスト +/// 2, // "四国めたん (ノーマル)" +/// (VoicevoxAudioQueryOptions){.kana = false}, +/// &audio_query); /// ``` /// /// ```c /// char *audio_query; -/// voicevox_synthesizer_audio_query(synthesizer, -/// "コンニチワ'", // AquesTalk風記法 -/// 2, // "四国めたん (ノーマル)" -/// (VoicevoxAudioQueryOptions){.kana = true}, -/// &audio_query); +/// voicevox_synthesizer_create_audio_query(synthesizer, +/// "コンニチワ'", // AquesTalk風記法 +/// 2, // "四国めたん (ノーマル)" +/// (VoicevoxAudioQueryOptions){.kana = true}, +/// &audio_query); /// ``` /// } /// @@ -547,7 +547,7 @@ pub static voicevox_default_audio_query_options: VoicevoxAudioQueryOptions = Con /// - `output_audio_query_json`は書き込みについて有効でなければならない。 /// } #[no_mangle] -pub unsafe extern "C" fn voicevox_synthesizer_audio_query( +pub unsafe extern "C" fn voicevox_synthesizer_create_audio_query( synthesizer: &VoicevoxSynthesizer, text: *const c_char, style_id: VoicevoxStyleId, @@ -882,7 +882,7 @@ pub unsafe extern "C" fn voicevox_synthesizer_tts( /// \safety{ /// - `json`は以下のAPIで得られたポインタでなくてはいけない。 /// - ::voicevox_create_supported_devices_json -/// - ::voicevox_synthesizer_audio_query +/// - ::voicevox_synthesizer_create_audio_query /// - ::voicevox_synthesizer_create_accent_phrases /// - ::voicevox_synthesizer_replace_mora_data /// - ::voicevox_synthesizer_replace_phoneme_length diff --git a/crates/voicevox_core_c_api/tests/e2e/symbols.rs b/crates/voicevox_core_c_api/tests/e2e/symbols.rs index 810fbf91b..de849090e 100644 --- a/crates/voicevox_core_c_api/tests/e2e/symbols.rs +++ b/crates/voicevox_core_c_api/tests/e2e/symbols.rs @@ -61,7 +61,7 @@ pub(crate) struct Symbols<'lib> { Symbol<'lib, unsafe extern "C" fn(*const VoicevoxSynthesizer) -> *const c_char>, pub(crate) voicevox_create_supported_devices_json: Symbol<'lib, unsafe extern "C" fn(*mut *mut c_char) -> VoicevoxResultCode>, - pub(crate) voicevox_synthesizer_audio_query: Symbol< + pub(crate) voicevox_synthesizer_create_audio_query: Symbol< 'lib, unsafe extern "C" fn( *const VoicevoxSynthesizer, @@ -204,7 +204,7 @@ impl<'lib> Symbols<'lib> { voicevox_synthesizer_is_loaded_voice_model, voicevox_synthesizer_get_metas_json, voicevox_create_supported_devices_json, - voicevox_synthesizer_audio_query, + voicevox_synthesizer_create_audio_query, voicevox_synthesizer_synthesis, voicevox_synthesizer_tts, voicevox_json_free, diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/tts_via_audio_query.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/tts_via_audio_query.rs index 024d68b0f..4c0ef91c1 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/tts_via_audio_query.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/tts_via_audio_query.rs @@ -46,7 +46,7 @@ impl assert_cdylib::TestCase for TestCase { voicevox_synthesizer_new_with_initialize, voicevox_synthesizer_delete, voicevox_synthesizer_load_voice_model, - voicevox_synthesizer_audio_query, + voicevox_synthesizer_create_audio_query, voicevox_synthesizer_synthesis, voicevox_json_free, voicevox_wav_free, @@ -90,7 +90,7 @@ impl assert_cdylib::TestCase for TestCase { let audio_query = { let mut audio_query = MaybeUninit::uninit(); let text = CString::new(&*self.text).unwrap(); - assert_ok(voicevox_synthesizer_audio_query( + assert_ok(voicevox_synthesizer_create_audio_query( synthesizer, text.as_ptr(), STYLE_ID, diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_load.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_load.rs index b9284c153..e8c8ca834 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_load.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_load.rs @@ -47,7 +47,7 @@ impl assert_cdylib::TestCase for TestCase { voicevox_synthesizer_new_with_initialize, voicevox_synthesizer_delete, voicevox_synthesizer_load_voice_model, - voicevox_synthesizer_audio_query, + voicevox_synthesizer_create_audio_query, .. } = Symbols::new(lib)?; @@ -103,7 +103,7 @@ impl assert_cdylib::TestCase for TestCase { assert_ok(voicevox_synthesizer_load_voice_model(synthesizer, model)); let mut audio_query_without_dict = std::ptr::null_mut(); - assert_ok(voicevox_synthesizer_audio_query( + assert_ok(voicevox_synthesizer_create_audio_query( synthesizer, cstr!("this_word_should_not_exist_in_default_dictionary").as_ptr(), STYLE_ID, @@ -117,7 +117,7 @@ impl assert_cdylib::TestCase for TestCase { assert_ok(voicevox_open_jtalk_rc_use_user_dict(openjtalk, dict)); let mut audio_query_with_dict = std::ptr::null_mut(); - assert_ok(voicevox_synthesizer_audio_query( + assert_ok(voicevox_synthesizer_create_audio_query( synthesizer, cstr!("this_word_should_not_exist_in_default_dictionary").as_ptr(), STYLE_ID,