diff --git a/Cargo.lock b/Cargo.lock index a783bb6d7..595e0e30f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -718,27 +718,6 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -name = "const-default" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b396d1f76d455557e1218ec8066ae14bba60b4b36ecd55577ba979f5db7ecaa" -dependencies = [ - "const-default-derive", -] - -[[package]] -name = "const-default-derive" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f814dd8cbb812233751ff6857b7fa86d9f52e88ac64e8f54e7a1ca0168f03da" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.102", -] - [[package]] name = "const_fn" version = "0.4.9" @@ -1060,16 +1039,6 @@ dependencies = [ "shared_child", ] -[[package]] -name = "duplicate" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de78e66ac9061e030587b2a2e75cc88f22304913c907b11307bca737141230cb" -dependencies = [ - "heck", - "proc-macro-error", -] - [[package]] name = "easy-ext" version = "1.0.1" @@ -2552,16 +2521,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3981,10 +3940,8 @@ dependencies = [ "anyhow", "async_zip", "cfg-if", - "const-default", "derive-getters", "derive-new", - "duplicate", "easy-ext", "flate2", "fs-err", @@ -4022,7 +3979,6 @@ dependencies = [ "assert_cmd", "chrono", "clap 4.0.10", - "const-default", "derive-getters", "duct", "easy-ext", diff --git a/Cargo.toml b/Cargo.toml index fc5c52efc..3e66cff9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ members = [ anyhow = "1.0.65" async_zip = { version = "0.0.11", features = ["full"] } clap = { version = "4.0.10", features = ["derive"] } -const-default = { version = "1.0.0", features = ["derive"] } easy-ext = "1.0.1" fs-err = { version = "2.9.0", features = ["tokio"] } itertools = "0.10.5" diff --git a/crates/voicevox_core/Cargo.toml b/crates/voicevox_core/Cargo.toml index 9e5febe22..05949fa90 100644 --- a/crates/voicevox_core/Cargo.toml +++ b/crates/voicevox_core/Cargo.toml @@ -12,10 +12,8 @@ directml = ["onnxruntime/directml"] anyhow.workspace = true async_zip.workspace = true cfg-if = "1.0.0" -const-default.workspace = true derive-getters.workspace = true derive-new = "0.5.9" -duplicate = "1.0.0" easy-ext.workspace = true fs-err.workspace = true futures = "0.3.26" diff --git a/crates/voicevox_core/src/voice_synthesizer.rs b/crates/voicevox_core/src/voice_synthesizer.rs index fbfb12337..41c0406da 100644 --- a/crates/voicevox_core/src/voice_synthesizer.rs +++ b/crates/voicevox_core/src/voice_synthesizer.rs @@ -1,8 +1,5 @@ use std::sync::Arc; -use const_default::ConstDefault; -use duplicate::duplicate_item; - use crate::engine::{create_kana, parse_kana, AccentPhraseModel, OpenJtalk, SynthesisEngine}; use super::*; @@ -31,7 +28,7 @@ impl From<&TtsOptions> for SynthesisOptions { /// [`Synthesizer::create_accent_phrases`]のオプション。 /// /// [`Synthesizer::create_accent_phrases`]: Synthesizer::create_accent_phrases -#[derive(ConstDefault)] +#[derive(Default)] pub struct AccentPhrasesOptions { /// AquesTalk風記法としてテキストを解釈する。 pub kana: bool, @@ -40,7 +37,7 @@ pub struct AccentPhrasesOptions { /// [`Synthesizer::audio_query`]のオプション。 /// /// [`Synthesizer::audio_query`]: Synthesizer::audio_query -#[derive(ConstDefault)] +#[derive(Default)] pub struct AudioQueryOptions { /// AquesTalk風記法としてテキストを解釈する。 pub kana: bool, @@ -67,17 +64,20 @@ impl AsRef for TtsOptions { } } -impl ConstDefault for TtsOptions { - const DEFAULT: Self = Self { - enable_interrogative_upspeak: true, - kana: ConstDefault::DEFAULT, - }; +impl Default for TtsOptions { + fn default() -> Self { + Self { + enable_interrogative_upspeak: true, + kana: Default::default(), + } + } } /// ハードウェアアクセラレーションモードを設定する設定値。 -#[derive(Debug, PartialEq, Eq)] +#[derive(Default, Debug, PartialEq, Eq)] pub enum AccelerationMode { /// 実行環境に合った適切なハードウェアアクセラレーションモードを選択する。 + #[default] Auto, /// ハードウェアアクセラレーションモードを"CPU"に設定する。 Cpu, @@ -85,34 +85,16 @@ pub enum AccelerationMode { Gpu, } -impl ConstDefault for AccelerationMode { - const DEFAULT: Self = Self::Auto; -} - /// [`Synthesizer::new_with_initialize`]のオプション。 /// /// [`Synthesizer::new_with_initialize`]: Synthesizer::new_with_initialize -#[derive(ConstDefault)] +#[derive(Default)] pub struct InitializeOptions { pub acceleration_mode: AccelerationMode, pub cpu_num_threads: u16, pub load_all_models: bool, } -#[duplicate_item( - T; - [ AccentPhrasesOptions ]; - [ AudioQueryOptions ]; - [ TtsOptions ]; - [ AccelerationMode ]; - [ InitializeOptions ]; -)] -impl Default for T { - fn default() -> Self { - Self::DEFAULT - } -} - /// 音声シンセサイザ。 pub struct Synthesizer { synthesis_engine: SynthesisEngine, diff --git a/crates/voicevox_core_c_api/Cargo.toml b/crates/voicevox_core_c_api/Cargo.toml index 5ba235311..ddad23112 100644 --- a/crates/voicevox_core_c_api/Cargo.toml +++ b/crates/voicevox_core_c_api/Cargo.toml @@ -16,7 +16,6 @@ name = "e2e" directml = ["voicevox_core/directml"] [dependencies] -const-default.workspace = true derive-getters.workspace = true libc = "0.2.134" once_cell.workspace = true diff --git a/crates/voicevox_core_c_api/include/voicevox_core.h b/crates/voicevox_core_c_api/include/voicevox_core.h index 09a7499dd..d5cf4f6b2 100644 --- a/crates/voicevox_core_c_api/include/voicevox_core.h +++ b/crates/voicevox_core_c_api/include/voicevox_core.h @@ -259,11 +259,6 @@ typedef struct VoicevoxUserDict VoicevoxUserDict; */ typedef struct VoicevoxVoiceModel VoicevoxVoiceModel; -/** - * 音声モデルID。 - */ -typedef const char *VoicevoxVoiceModelId; - /** * ::voicevox_synthesizer_new_with_initialize のオプション。 */ @@ -284,11 +279,9 @@ typedef struct VoicevoxInitializeOptions { } VoicevoxInitializeOptions; /** - * スタイルID。 - * - * VOICEVOXにおける、ある話者(_speaker_)のあるスタイル(_style_)を指す。 + * 音声モデルID。 */ -typedef uint32_t VoicevoxStyleId; +typedef const char *VoicevoxVoiceModelId; /** * ::voicevox_synthesizer_create_audio_query のオプション。 @@ -300,6 +293,13 @@ typedef struct VoicevoxAudioQueryOptions { bool kana; } VoicevoxAudioQueryOptions; +/** + * スタイルID。 + * + * VOICEVOXにおける、ある話者(_speaker_)のあるスタイル(_style_)を指す。 + */ +typedef uint32_t VoicevoxStyleId; + /** * ::voicevox_synthesizer_create_accent_phrases のオプション。 */ @@ -364,18 +364,6 @@ typedef struct VoicevoxUserDictWord { extern "C" { #endif // __cplusplus -extern const struct VoicevoxInitializeOptions voicevox_default_initialize_options; - -extern const char *voicevox_version; - -extern const struct VoicevoxAudioQueryOptions voicevox_default_audio_query_options; - -extern const struct VoicevoxAccentPhrasesOptions voicevox_default_accent_phrases_options; - -extern const struct VoicevoxSynthesisOptions voicevox_default_synthesis_options; - -extern const struct VoicevoxTtsOptions voicevox_default_tts_options; - /** * ::OpenJtalkRc を構築(_construct_)する。 * @@ -444,6 +432,24 @@ __declspec(dllimport) #endif void voicevox_open_jtalk_rc_delete(struct OpenJtalkRc *open_jtalk); +/** + * デフォルトの初期化オプションを生成する + * @return デフォルト値が設定された初期化オプション + */ +#ifdef _WIN32 +__declspec(dllimport) +#endif +struct VoicevoxInitializeOptions voicevox_make_default_initialize_options(void); + +/** + * voicevoxのバージョンを取得する。 + * @return SemVerでフォーマットされたバージョン。 + */ +#ifdef _WIN32 +__declspec(dllimport) +#endif +const char *voicevox_get_version(void); + /** * VVMファイルから ::VoicevoxVoiceModel を構築(_construct_)する。 * @@ -664,6 +670,15 @@ __declspec(dllimport) #endif VoicevoxResultCode voicevox_create_supported_devices_json(char **output_supported_devices_json); +/** + * デフォルトの AudioQuery のオプションを生成する + * @return デフォルト値が設定された AudioQuery オプション + */ +#ifdef _WIN32 +__declspec(dllimport) +#endif +struct VoicevoxAudioQueryOptions voicevox_make_default_audio_query_options(void); + /** * AudioQueryをJSONとして生成する。 * @@ -713,6 +728,15 @@ VoicevoxResultCode voicevox_synthesizer_create_audio_query(const struct Voicevox struct VoicevoxAudioQueryOptions options, char **output_audio_query_json); +/** + * デフォルトの `accent_phrases` のオプションを生成する + * @return デフォルト値が設定された `accent_phrases` のオプション + */ +#ifdef _WIN32 +__declspec(dllimport) +#endif +struct VoicevoxAccentPhrasesOptions voicevox_make_default_accent_phrases_options(void); + /** * AccentPhrase (アクセント句)の配列をJSON形式で生成する。 * @@ -839,6 +863,15 @@ VoicevoxResultCode voicevox_synthesizer_replace_mora_pitch(const struct Voicevox VoicevoxStyleId style_id, char **output_accent_phrases_json); +/** + * デフォルトの `voicevox_synthesizer_synthesis` のオプションを生成する + * @return デフォルト値が設定された `voicevox_synthesizer_synthesis` のオプション + */ +#ifdef _WIN32 +__declspec(dllimport) +#endif +struct VoicevoxSynthesisOptions voicevox_make_default_synthesis_options(void); + /** * AudioQueryから音声合成を行う。 * @@ -870,6 +903,15 @@ VoicevoxResultCode voicevox_synthesizer_synthesis(const struct VoicevoxSynthesiz uintptr_t *output_wav_length, uint8_t **output_wav); +/** + * デフォルトのテキスト音声合成オプションを生成する + * @return テキスト音声合成オプション + */ +#ifdef _WIN32 +__declspec(dllimport) +#endif +struct VoicevoxTtsOptions voicevox_make_default_tts_options(void); + /** * テキスト音声合成を行う。 * diff --git a/crates/voicevox_core_c_api/src/helpers.rs b/crates/voicevox_core_c_api/src/helpers.rs index 1be3109ed..72d43497e 100644 --- a/crates/voicevox_core_c_api/src/helpers.rs +++ b/crates/voicevox_core_c_api/src/helpers.rs @@ -1,7 +1,6 @@ use std::fmt::Debug; use voicevox_core::UserDictWord; -use const_default::ConstDefault; use thiserror::Error; use super::*; @@ -81,11 +80,10 @@ pub(crate) fn ensure_utf8(s: &CStr) -> CApiResult<&str> { s.to_str().map_err(|_| CApiError::InvalidUtf8Input) } -impl ConstDefault for VoicevoxAudioQueryOptions { - const DEFAULT: Self = { - let options = voicevox_core::AudioQueryOptions::DEFAULT; +impl From for VoicevoxAudioQueryOptions { + fn from(options: voicevox_core::AudioQueryOptions) -> Self { Self { kana: options.kana } - }; + } } impl From for voicevox_core::AudioQueryOptions { fn from(options: VoicevoxAudioQueryOptions) -> Self { @@ -93,11 +91,10 @@ impl From for voicevox_core::AudioQueryOptions { } } -impl ConstDefault for VoicevoxAccentPhrasesOptions { - const DEFAULT: Self = { - let options = voicevox_core::AccentPhrasesOptions::DEFAULT; +impl From for VoicevoxAccentPhrasesOptions { + fn from(options: voicevox_core::AccentPhrasesOptions) -> Self { Self { kana: options.kana } - }; + } } impl From for voicevox_core::AccentPhrasesOptions { fn from(options: VoicevoxAccentPhrasesOptions) -> Self { @@ -113,10 +110,9 @@ impl From for voicevox_core::SynthesisOptions { } } -impl VoicevoxAccelerationMode { - const fn from_rust(mode: voicevox_core::AccelerationMode) -> Self { +impl From for VoicevoxAccelerationMode { + fn from(mode: voicevox_core::AccelerationMode) -> Self { use voicevox_core::AccelerationMode::*; - match mode { Auto => Self::VOICEVOX_ACCELERATION_MODE_AUTO, Cpu => Self::VOICEVOX_ACCELERATION_MODE_CPU, @@ -124,10 +120,10 @@ impl VoicevoxAccelerationMode { } } } + impl From for voicevox_core::AccelerationMode { fn from(mode: VoicevoxAccelerationMode) -> Self { use VoicevoxAccelerationMode::*; - match mode { VOICEVOX_ACCELERATION_MODE_AUTO => Self::Auto, VOICEVOX_ACCELERATION_MODE_CPU => Self::Cpu, @@ -136,15 +132,15 @@ impl From for voicevox_core::AccelerationMode { } } -impl ConstDefault for VoicevoxInitializeOptions { - const DEFAULT: Self = { - let options = voicevox_core::InitializeOptions::DEFAULT; +impl Default for VoicevoxInitializeOptions { + fn default() -> Self { + let options = voicevox_core::InitializeOptions::default(); Self { - acceleration_mode: VoicevoxAccelerationMode::from_rust(options.acceleration_mode), + acceleration_mode: options.acceleration_mode.into(), cpu_num_threads: options.cpu_num_threads, load_all_models: options.load_all_models, } - }; + } } impl From for voicevox_core::InitializeOptions { @@ -157,14 +153,13 @@ impl From for voicevox_core::InitializeOptions { } } -impl ConstDefault for VoicevoxTtsOptions { - const DEFAULT: Self = { - let options = voicevox_core::TtsOptions::DEFAULT; +impl From for VoicevoxTtsOptions { + fn from(options: voicevox_core::TtsOptions) -> Self { Self { kana: options.kana, enable_interrogative_upspeak: options.enable_interrogative_upspeak, } - }; + } } impl From for voicevox_core::TtsOptions { @@ -176,13 +171,13 @@ impl From for voicevox_core::TtsOptions { } } -impl ConstDefault for VoicevoxSynthesisOptions { - const DEFAULT: Self = { - let options = voicevox_core::TtsOptions::DEFAULT; +impl Default for VoicevoxSynthesisOptions { + fn default() -> Self { + let options = voicevox_core::TtsOptions::default(); Self { enable_interrogative_upspeak: options.enable_interrogative_upspeak, } - }; + } } impl VoicevoxUserDictWord { diff --git a/crates/voicevox_core_c_api/src/lib.rs b/crates/voicevox_core_c_api/src/lib.rs index 8f701e920..db06de484 100644 --- a/crates/voicevox_core_c_api/src/lib.rs +++ b/crates/voicevox_core_c_api/src/lib.rs @@ -12,7 +12,6 @@ use self::drop_check::C_STRING_DROP_CHECKER; use self::helpers::*; use self::slice_owner::U8_SLICE_OWNER; use chrono::SecondsFormat; -use const_default::ConstDefault; use derive_getters::Getters; use once_cell::sync::Lazy; use std::env; @@ -205,21 +204,24 @@ pub struct VoicevoxInitializeOptions { load_all_models: bool, } -/// デフォルトの初期化オプション +/// デフォルトの初期化オプションを生成する +/// @return デフォルト値が設定された初期化オプション #[no_mangle] -pub static voicevox_default_initialize_options: VoicevoxInitializeOptions = ConstDefault::DEFAULT; +pub extern "C" fn voicevox_make_default_initialize_options() -> VoicevoxInitializeOptions { + VoicevoxInitializeOptions::default() +} -/// voicevoxのバージョン。 +/// voicevoxのバージョンを取得する。 +/// @return SemVerでフォーマットされたバージョン。 #[no_mangle] -pub static voicevox_version: &c_char = { - const VOICEVOX_VERSION: &CStr = unsafe { +pub extern "C" fn voicevox_get_version() -> *const c_char { + return C_STRING_DROP_CHECKER.blacklist(VERSION).as_ptr(); + + const VERSION: &CStr = unsafe { // SAFETY: The package version is a SemVer, so it should not contain '\0' CStr::from_bytes_with_nul_unchecked(concat!(env!("CARGO_PKG_VERSION"), '\0').as_bytes()) }; - - // SAFETY: `CStr::as_ptr` always returns a valid pointer. - unsafe { &*VOICEVOX_VERSION.as_ptr() } -}; +} /// 音声モデル。 /// @@ -504,9 +506,12 @@ pub struct VoicevoxAudioQueryOptions { kana: bool, } -/// デフォルトの AudioQuery のオプション +/// デフォルトの AudioQuery のオプションを生成する +/// @return デフォルト値が設定された AudioQuery オプション #[no_mangle] -pub static voicevox_default_audio_query_options: VoicevoxAudioQueryOptions = ConstDefault::DEFAULT; +pub extern "C" fn voicevox_make_default_audio_query_options() -> VoicevoxAudioQueryOptions { + voicevox_core::AudioQueryOptions::default().into() +} /// AudioQueryをJSONとして生成する。 /// @@ -578,10 +583,12 @@ pub struct VoicevoxAccentPhrasesOptions { kana: bool, } -/// デフォルトの `accent_phrases` のオプション +/// デフォルトの `accent_phrases` のオプションを生成する +/// @return デフォルト値が設定された `accent_phrases` のオプション #[no_mangle] -pub static voicevox_default_accent_phrases_options: VoicevoxAccentPhrasesOptions = - ConstDefault::DEFAULT; +pub extern "C" fn voicevox_make_default_accent_phrases_options() -> VoicevoxAccentPhrasesOptions { + voicevox_core::AccentPhrasesOptions::default().into() +} /// AccentPhrase (アクセント句)の配列をJSON形式で生成する。 /// @@ -774,9 +781,12 @@ pub struct VoicevoxSynthesisOptions { enable_interrogative_upspeak: bool, } -/// デフォルトの `voicevox_synthesizer_synthesis` のオプション +/// デフォルトの `voicevox_synthesizer_synthesis` のオプションを生成する +/// @return デフォルト値が設定された `voicevox_synthesizer_synthesis` のオプション #[no_mangle] -pub static voicevox_default_synthesis_options: VoicevoxSynthesisOptions = ConstDefault::DEFAULT; +pub extern "C" fn voicevox_make_default_synthesis_options() -> VoicevoxSynthesisOptions { + VoicevoxSynthesisOptions::default() +} /// AudioQueryから音声合成を行う。 /// @@ -831,9 +841,12 @@ pub struct VoicevoxTtsOptions { enable_interrogative_upspeak: bool, } -/// デフォルトのテキスト音声合成オプション +/// デフォルトのテキスト音声合成オプションを生成する +/// @return テキスト音声合成オプション #[no_mangle] -pub static voicevox_default_tts_options: VoicevoxTtsOptions = ConstDefault::DEFAULT; +pub extern "C" fn voicevox_make_default_tts_options() -> VoicevoxTtsOptions { + voicevox_core::TtsOptions::default().into() +} /// テキスト音声合成を行う。 /// diff --git a/crates/voicevox_core_c_api/tests/e2e/symbols.rs b/crates/voicevox_core_c_api/tests/e2e/symbols.rs index a214a781b..47d15ec1d 100644 --- a/crates/voicevox_core_c_api/tests/e2e/symbols.rs +++ b/crates/voicevox_core_c_api/tests/e2e/symbols.rs @@ -6,11 +6,6 @@ use voicevox_core::result_code::VoicevoxResultCode; /// voicevox\_core\_c\_apiのcdylibのシンボルを集めたもの。 #[allow(dead_code)] // TODO: WIP pub(crate) struct Symbols<'lib> { - pub(crate) voicevox_version: Symbol<'lib, &'lib &'lib c_char>, - pub(crate) voicevox_default_initialize_options: Symbol<'lib, &'lib VoicevoxInitializeOptions>, - pub(crate) voicevox_default_audio_query_options: Symbol<'lib, &'lib VoicevoxAudioQueryOptions>, - pub(crate) voicevox_default_synthesis_options: Symbol<'lib, &'lib VoicevoxSynthesisOptions>, - pub(crate) voicevox_default_tts_options: Symbol<'lib, &'lib VoicevoxTtsOptions>, pub(crate) voicevox_open_jtalk_rc_new: Symbol< 'lib, unsafe extern "C" fn(*const c_char, *mut *mut OpenJtalkRc) -> VoicevoxResultCode, @@ -20,6 +15,9 @@ pub(crate) struct Symbols<'lib> { unsafe extern "C" fn(*mut OpenJtalkRc, *const VoicevoxUserDict) -> VoicevoxResultCode, >, pub(crate) voicevox_open_jtalk_rc_delete: Symbol<'lib, unsafe extern "C" fn(*mut OpenJtalkRc)>, + pub(crate) voicevox_make_default_initialize_options: + Symbol<'lib, unsafe extern "C" fn() -> VoicevoxInitializeOptions>, + pub(crate) voicevox_get_version: Symbol<'lib, unsafe extern "C" fn() -> *const c_char>, pub(crate) voicevox_voice_model_new_from_path: Symbol< 'lib, unsafe extern "C" fn(*const c_char, *mut *mut VoicevoxVoiceModel) -> VoicevoxResultCode, @@ -61,6 +59,8 @@ 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_make_default_audio_query_options: + Symbol<'lib, unsafe extern "C" fn() -> VoicevoxAudioQueryOptions>, pub(crate) voicevox_synthesizer_create_audio_query: Symbol< 'lib, unsafe extern "C" fn( @@ -71,6 +71,8 @@ pub(crate) struct Symbols<'lib> { *mut *mut c_char, ) -> VoicevoxResultCode, >, + pub(crate) voicevox_make_default_synthesis_options: + Symbol<'lib, unsafe extern "C" fn() -> VoicevoxSynthesisOptions>, pub(crate) voicevox_synthesizer_synthesis: Symbol< 'lib, unsafe extern "C" fn( @@ -82,6 +84,8 @@ pub(crate) struct Symbols<'lib> { *mut *mut u8, ) -> VoicevoxResultCode, >, + pub(crate) voicevox_make_default_tts_options: + Symbol<'lib, unsafe extern "C" fn() -> VoicevoxTtsOptions>, pub(crate) voicevox_synthesizer_tts: Symbol< 'lib, unsafe extern "C" fn( @@ -184,14 +188,11 @@ impl<'lib> Symbols<'lib> { }); Ok(new!( - voicevox_version, - voicevox_default_initialize_options, - voicevox_default_audio_query_options, - voicevox_default_synthesis_options, - voicevox_default_tts_options, voicevox_open_jtalk_rc_new, voicevox_open_jtalk_rc_use_user_dict, voicevox_open_jtalk_rc_delete, + voicevox_make_default_initialize_options, + voicevox_get_version, voicevox_voice_model_new_from_path, voicevox_voice_model_id, voicevox_voice_model_get_metas_json, @@ -204,8 +205,11 @@ impl<'lib> Symbols<'lib> { voicevox_synthesizer_is_loaded_voice_model, voicevox_synthesizer_get_metas_json, voicevox_create_supported_devices_json, + voicevox_make_default_audio_query_options, voicevox_synthesizer_create_audio_query, + voicevox_make_default_synthesis_options, voicevox_synthesizer_synthesis, + voicevox_make_default_tts_options, voicevox_synthesizer_tts, voicevox_json_free, voicevox_wav_free, @@ -253,19 +257,16 @@ pub(crate) struct VoicevoxInitializeOptions { pub(crate) load_all_models: bool, } -#[derive(Clone, Copy)] #[repr(C)] pub(crate) struct VoicevoxAudioQueryOptions { _kana: bool, } -#[derive(Clone, Copy)] #[repr(C)] pub(crate) struct VoicevoxSynthesisOptions { _enable_interrogative_upspeak: bool, } -#[derive(Clone, Copy)] #[repr(C)] pub(crate) struct VoicevoxTtsOptions { _kana: bool, 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 d81b79117..38537dad5 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 @@ -22,7 +22,7 @@ struct TestCase; impl assert_cdylib::TestCase for TestCase { unsafe fn exec(&self, lib: &Library) -> anyhow::Result<()> { let Symbols { - voicevox_version, + voicevox_get_version, voicevox_create_supported_devices_json, voicevox_error_result_to_message, voicevox_json_free, @@ -31,7 +31,7 @@ impl assert_cdylib::TestCase for TestCase { std::assert_eq!( env!("CARGO_PKG_VERSION"), - CStr::from_ptr(**voicevox_version).to_str()?, + CStr::from_ptr(voicevox_get_version()).to_str()?, ); { diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/simple_tts.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/simple_tts.rs index 2e691100f..70a16ea1c 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/simple_tts.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/simple_tts.rs @@ -36,15 +36,15 @@ struct TestCase { impl assert_cdylib::TestCase for TestCase { unsafe fn exec(&self, lib: &Library) -> anyhow::Result<()> { let Symbols { - voicevox_default_initialize_options, - voicevox_default_tts_options, voicevox_open_jtalk_rc_new, voicevox_open_jtalk_rc_delete, + voicevox_make_default_initialize_options, voicevox_voice_model_new_from_path, voicevox_voice_model_delete, voicevox_synthesizer_new_with_initialize, voicevox_synthesizer_delete, voicevox_synthesizer_load_voice_model, + voicevox_make_default_tts_options, voicevox_synthesizer_tts, voicevox_wav_free, .. @@ -75,7 +75,7 @@ impl assert_cdylib::TestCase for TestCase { openjtalk, VoicevoxInitializeOptions { acceleration_mode: VoicevoxAccelerationMode::VOICEVOX_ACCELERATION_MODE_CPU, - ..**voicevox_default_initialize_options + ..voicevox_make_default_initialize_options() }, synthesizer.as_mut_ptr(), )); @@ -92,7 +92,7 @@ impl assert_cdylib::TestCase for TestCase { synthesizer, text.as_ptr(), STYLE_ID, - **voicevox_default_tts_options, + voicevox_make_default_tts_options(), wav_length.as_mut_ptr(), wav.as_mut_ptr(), )); diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_with_initialize_output_json.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_with_initialize_output_json.rs index 0edd73300..502880a14 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_with_initialize_output_json.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_with_initialize_output_json.rs @@ -26,7 +26,7 @@ struct TestCase; impl assert_cdylib::TestCase for TestCase { unsafe fn exec(&self, lib: &Library) -> anyhow::Result<()> { let Symbols { - voicevox_default_initialize_options, + voicevox_make_default_initialize_options, voicevox_open_jtalk_rc_new, voicevox_open_jtalk_rc_delete, voicevox_synthesizer_new_with_initialize, @@ -52,7 +52,7 @@ impl assert_cdylib::TestCase for TestCase { VoicevoxInitializeOptions { acceleration_mode: VoicevoxAccelerationMode::VOICEVOX_ACCELERATION_MODE_CPU, load_all_models: true, - ..**voicevox_default_initialize_options + ..voicevox_make_default_initialize_options() }, synthesizer.as_mut_ptr(), )); 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 4c0ef91c1..741e289b3 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 @@ -36,17 +36,17 @@ struct TestCase { impl assert_cdylib::TestCase for TestCase { unsafe fn exec(&self, lib: &Library) -> anyhow::Result<()> { let Symbols { - voicevox_default_initialize_options, - voicevox_default_audio_query_options, - voicevox_default_synthesis_options, voicevox_open_jtalk_rc_new, voicevox_open_jtalk_rc_delete, + voicevox_make_default_initialize_options, voicevox_voice_model_new_from_path, voicevox_voice_model_delete, voicevox_synthesizer_new_with_initialize, voicevox_synthesizer_delete, voicevox_synthesizer_load_voice_model, + voicevox_make_default_audio_query_options, voicevox_synthesizer_create_audio_query, + voicevox_make_default_synthesis_options, voicevox_synthesizer_synthesis, voicevox_json_free, voicevox_wav_free, @@ -78,7 +78,7 @@ impl assert_cdylib::TestCase for TestCase { openjtalk, VoicevoxInitializeOptions { acceleration_mode: VoicevoxAccelerationMode::VOICEVOX_ACCELERATION_MODE_CPU, - ..**voicevox_default_initialize_options + ..voicevox_make_default_initialize_options() }, synthesizer.as_mut_ptr(), )); @@ -94,7 +94,7 @@ impl assert_cdylib::TestCase for TestCase { synthesizer, text.as_ptr(), STYLE_ID, - **voicevox_default_audio_query_options, + voicevox_make_default_audio_query_options(), audio_query.as_mut_ptr(), )); audio_query.assume_init() @@ -107,7 +107,7 @@ impl assert_cdylib::TestCase for TestCase { synthesizer, audio_query, STYLE_ID, - **voicevox_default_synthesis_options, + voicevox_make_default_synthesis_options(), wav_length.as_mut_ptr(), wav.as_mut_ptr(), )); 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 e8c8ca834..25ee033c4 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 @@ -37,8 +37,8 @@ impl assert_cdylib::TestCase for TestCase { voicevox_user_dict_new, voicevox_user_dict_add_word, voicevox_user_dict_delete, - voicevox_default_initialize_options, - voicevox_default_audio_query_options, + voicevox_make_default_initialize_options, + voicevox_make_default_audio_query_options, voicevox_open_jtalk_rc_new, voicevox_open_jtalk_rc_use_user_dict, voicevox_open_jtalk_rc_delete, @@ -93,7 +93,7 @@ impl assert_cdylib::TestCase for TestCase { openjtalk, VoicevoxInitializeOptions { acceleration_mode: VoicevoxAccelerationMode::VOICEVOX_ACCELERATION_MODE_CPU, - ..**voicevox_default_initialize_options + ..voicevox_make_default_initialize_options() }, synthesizer.as_mut_ptr(), )); @@ -107,7 +107,7 @@ impl assert_cdylib::TestCase for TestCase { synthesizer, cstr!("this_word_should_not_exist_in_default_dictionary").as_ptr(), STYLE_ID, - **voicevox_default_audio_query_options, + voicevox_make_default_audio_query_options(), &mut audio_query_without_dict, )); let audio_query_without_dict = serde_json::from_str::( @@ -121,7 +121,7 @@ impl assert_cdylib::TestCase for TestCase { synthesizer, cstr!("this_word_should_not_exist_in_default_dictionary").as_ptr(), STYLE_ID, - **voicevox_default_audio_query_options, + voicevox_make_default_audio_query_options(), &mut audio_query_with_dict, )); diff --git a/example/cpp/unix/simple_tts.cpp b/example/cpp/unix/simple_tts.cpp index 1c9fa00ca..3fb61742a 100644 --- a/example/cpp/unix/simple_tts.cpp +++ b/example/cpp/unix/simple_tts.cpp @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) { std::cout << "coreの初期化中..." << std::endl; - auto initialize_options = voicevox_default_initialize_options; + auto initialize_options = voicevox_make_default_initialize_options(); initialize_options.load_all_models = true; OpenJtalkRc* open_jtalk; auto result = voicevox_open_jtalk_rc_new(open_jtalk_dict_path.c_str(),&open_jtalk); @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { uint8_t *output_wav = nullptr; result = voicevox_synthesizer_tts(synthesizer,text.c_str(), speaker_id, - voicevox_default_tts_options, + voicevox_make_default_tts_options(), &output_wav_size, &output_wav); if (result != VOICEVOX_RESULT_OK) { std::cerr << voicevox_error_result_to_message(result) << std::endl; diff --git a/example/cpp/windows/simple_tts/simple_tts.cpp b/example/cpp/windows/simple_tts/simple_tts.cpp index 4905b09d2..b22ba067f 100644 --- a/example/cpp/windows/simple_tts/simple_tts.cpp +++ b/example/cpp/windows/simple_tts/simple_tts.cpp @@ -28,7 +28,7 @@ int main() { std::wcin >> speak_words; std::wcout << L"coreの初期化中" << std::endl; - VoicevoxInitializeOptions initializeOptions = voicevox_default_initialize_options; + VoicevoxInitializeOptions initializeOptions = voicevox_make_default_initialize_options(); std::string dict = GetOpenJTalkDict(); initializeOptions.load_all_models = true; @@ -50,7 +50,7 @@ int main() { int32_t speaker_id = 0; uintptr_t output_binary_size = 0; uint8_t* output_wav = nullptr; - VoicevoxTtsOptions ttsOptions = voicevox_default_tts_options; + VoicevoxTtsOptions ttsOptions = voicevox_make_default_tts_options(); result = voicevox_synthesizer_tts(synthesizer,wide_to_utf8_cppapi(speak_words).c_str(), speaker_id, ttsOptions, &output_binary_size, &output_wav); if (result != VoicevoxResultCode::VOICEVOX_RESULT_OK) {