diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 2bb1f7e88..d2092001d 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -16,6 +16,8 @@ on: type: boolean required: false default: false + # TODO: ライセンス表記およびモデル配布形体の方針が固まったら廃止 + # is_production: description: "製品版をビルドする" type: boolean @@ -158,7 +160,7 @@ jobs: build_and_deploy: needs: config - environment: ${{ inputs.is_production && 'production' || '' }} # 製品版のenvironment + environment: ${{ inputs.code_signing && 'production' || '' }} # コード署名用のenvironment strategy: matrix: include: ${{ fromJson(needs.config.outputs.includes) }} @@ -166,22 +168,7 @@ jobs: env: ASSET_NAME: voicevox_core-${{ matrix.artifact_name }}-${{ needs.config.outputs.version }} steps: - - uses: actions/checkout@v4 # 製品版ではない場合 - if: ${{ !inputs.is_production }} - - uses: actions/checkout@v4 # 製品版の場合 - if: inputs.is_production - with: - fetch-depth: 0 # 全履歴取得 - token: ${{ secrets.PRODUCTION_GITHUB_TOKEN }} - - name: Merge production branch - if: inputs.is_production - shell: bash - run: | - ( - git remote add private ${{ secrets.PRODUCTION_REPOSITORY_URL }} - git fetch private refs/tags/${{ env.PRODUCTION_REPOSITORY_TAG }} - git -c user.name=dummy -c user.email=dummy@dummy.dummy merge FETCH_HEAD - ) > /dev/null 2>&1 + - uses: actions/checkout@v4 - name: Set up Python 3.8 if: matrix.python_whl uses: actions/setup-python@v5 @@ -228,7 +215,6 @@ jobs: if ${{ matrix.python_whl }}; then cargo set-version "$VERSION" -p voicevox_core_python_api; fi - name: cache target uses: Swatinem/rust-cache@v2 - if: ${{ !inputs.is_production }} - name: build voicevox_core_c_api shell: bash run: | @@ -236,14 +222,7 @@ jobs: plain-cdylib) linking=load-onnxruntime ;; ios-xcframework) linking=link-onnxruntime ;; esac - function build() { - cargo build -p voicevox_core_c_api -v --features "$linking" --target ${{ matrix.target }} --release - } - if ${{ !inputs.is_production }}; then - build - else - build > /dev/null 2>&1 - fi + cargo build -p voicevox_core_c_api -v --features "$linking" --target ${{ matrix.target }} --release env: RUSTFLAGS: -C panic=abort - name: build voicevox_core_python_api @@ -254,26 +233,11 @@ jobs: pip install --upgrade poetry poetry config virtualenvs.create false (cd crates/voicevox_core_python_api && poetry install --with dev) - function build() { - maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --target ${{ matrix.target }} --release - } - if ${{ !inputs.is_production }}; then - build - else - build > /dev/null 2>&1 - fi + maturin build --manifest-path ./crates/voicevox_core_python_api/Cargo.toml --target ${{ matrix.target }} --release echo "whl=$(find ./target/wheels -type f)" >> "$GITHUB_OUTPUT" - name: build voicevox_core_java_api if: contains(matrix.target, 'android') - run: | - function build() { - cargo build -p voicevox_core_java_api -v --target ${{ matrix.target }} --release - } - if ${{ !inputs.is_production }}; then - build - else - build > /dev/null 2>&1 - fi + run: cargo build -p voicevox_core_java_api vv --target ${{ matrix.target }} --release - name: Organize artifact run: | mkdir -p "artifact/${{ env.ASSET_NAME }}" diff --git a/.github/workflows/build_and_deploy_downloader.yml b/.github/workflows/build_and_deploy_downloader.yml index 36ef0378a..addb3804a 100644 --- a/.github/workflows/build_and_deploy_downloader.yml +++ b/.github/workflows/build_and_deploy_downloader.yml @@ -11,11 +11,6 @@ on: type: boolean required: false default: false - is_production: - description: "製品版をビルドする" - type: boolean - required: false - default: false release: types: - published @@ -42,7 +37,7 @@ defaults: jobs: deploy_and_deploy_downloader: - environment: ${{ inputs.is_production && 'production' || '' }} # コード署名用のenvironment + environment: ${{ inputs.code_signing && 'production' || '' }} # コード署名用のenvironment strategy: matrix: include: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96018a7ef..a8134d5e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -284,17 +284,12 @@ jobs: - run: cargo build -p test_util -v # build scriptにより/crates/test_util/data/の生成 - run: poetry run maturin build --locked - run: poetry run maturin develop --locked - - name: 必要なDLLをコピーしてpytestを実行 - run: | - cp -v ../../target/debug/onnxruntime.dll . || true - cp -v ../../target/debug/libonnxruntime.so.* . || true - cp -v ../../target/debug/libonnxruntime.*.dylib . || true - - poetry run pytest + - name: pytestを実行 + run: poetry run pytest - name: Exampleを実行 run: | for file in ../../example/python/run{,-asyncio}.py; do - poetry run python "$file" ../test_util/data/model/sample.vvm --dict-dir ../test_util/data/open_jtalk_dic_utf_8-1.11 + poetry run python "$file" ../test_util/data/model/sample.vvm --dict-dir ../test_util/data/open_jtalk_dic_utf_8-1.11 --onnxruntime ../test_util/data/lib/*onnxruntime* done build-and-test-java-api: strategy: diff --git a/build_util/make_ios_xcframework.bash b/build_util/make_ios_xcframework.bash index 2d35fac88..e2608955e 100755 --- a/build_util/make_ios_xcframework.bash +++ b/build_util/make_ios_xcframework.bash @@ -65,9 +65,9 @@ for arch in "${arches[@]}"; do install_name_tool -id "@rpath/voicevox_core.framework/voicevox_core" \ "Framework-${arch}/voicevox_core.framework/voicevox_core" - # 依存ライブラリonnxruntimeへの@rpathを変更 + # onnxruntimeへの@rpathを、voicevox_onnxruntimeのXCFrameworkに変更 install_name_tool -change "@rpath/$dylib_string" \ - "@rpath/onnxruntime.framework/onnxruntime" \ + "@rpath/voicevox_onnxruntime.framework/voicevox_onnxruntime" \ "Framework-${arch}/voicevox_core.framework/voicevox_core" done diff --git a/crates/voicevox_core/Cargo.toml b/crates/voicevox_core/Cargo.toml index 984b62ec5..0f3b248bb 100644 --- a/crates/voicevox_core/Cargo.toml +++ b/crates/voicevox_core/Cargo.toml @@ -25,7 +25,7 @@ camino.workspace = true const_format.workspace = true derive-getters.workspace = true derive-new.workspace = true -derive_more = { workspace = true, features = ["add", "deref", "display", "from", "from_str"] } +derive_more = { workspace = true, features = ["add", "deref", "display", "from", "from_str", "index"] } duplicate.workspace = true easy-ext.workspace = true educe.workspace = true diff --git a/crates/voicevox_core/src/devices.rs b/crates/voicevox_core/src/devices.rs index ea46db6cf..552b7437a 100644 --- a/crates/voicevox_core/src/devices.rs +++ b/crates/voicevox_core/src/devices.rs @@ -57,12 +57,7 @@ fn test_gpu( /// use voicevox_core::{nonblocking::Onnxruntime, SupportedDevices}; /// /// # voicevox_core::blocking::Onnxruntime::load_once() -/// # .filename(if cfg!(windows) { -/// # // Windows\System32\onnxruntime.dllを回避 -/// # test_util::ONNXRUNTIME_DYLIB_PATH -/// # } else { -/// # voicevox_core::blocking::Onnxruntime::LIB_VERSIONED_FILENAME -/// # }) +/// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) /// # .exec()?; /// # /// let onnxruntime = Onnxruntime::get().unwrap(); diff --git a/crates/voicevox_core/src/infer.rs b/crates/voicevox_core/src/infer.rs index 49cbb476e..0f38dae7e 100644 --- a/crates/voicevox_core/src/infer.rs +++ b/crates/voicevox_core/src/infer.rs @@ -1,9 +1,8 @@ pub(crate) mod domains; -mod model_file; pub(crate) mod runtimes; pub(crate) mod session_set; -use std::{borrow::Cow, collections::BTreeSet, fmt::Debug, ops::Index, sync::Arc}; +use std::{borrow::Cow, collections::BTreeSet, fmt::Debug, sync::Arc}; use derive_new::new; use duplicate::duplicate_item; @@ -14,6 +13,7 @@ use thiserror::Error; use crate::{ asyncs::{Async, BlockingThreadPool, SingleTasked}, devices::{DeviceSpec, GpuSpec}, + voice_model::ModelBytes, StyleType, SupportedDevices, }; @@ -62,7 +62,7 @@ pub(crate) trait InferenceRuntime: 'static { )] fn new_session( &self, - model: impl FnOnce() -> std::result::Result, DecryptModelError>, + model: &ModelBytes, options: InferenceSessionOptions, ) -> anyhow::Result<( Self::Session, @@ -78,7 +78,7 @@ pub(crate) trait InferenceRuntime: 'static { /// 共に扱われるべき推論操作の集合を示す。 pub(crate) trait InferenceDomain: Sized { type Operation: InferenceOperation; - type Manifest: Index>; + type Manifest; /// 対応する`StyleType`。 /// @@ -265,7 +265,3 @@ pub(crate) enum ExtractError { #[error(transparent)] Shape(#[from] ShapeError), } - -#[derive(Error, Debug)] -#[error("不正なモデルファイルです")] -pub(crate) struct DecryptModelError; diff --git a/crates/voicevox_core/src/infer/domains/frame_decode.rs b/crates/voicevox_core/src/infer/domains/frame_decode.rs index c228196fc..2e76ba5a1 100644 --- a/crates/voicevox_core/src/infer/domains/frame_decode.rs +++ b/crates/voicevox_core/src/infer/domains/frame_decode.rs @@ -3,6 +3,7 @@ use std::{collections::BTreeSet, sync::LazyLock}; use enum_map::Enum; use macros::{InferenceInputSignature, InferenceOperation, InferenceOutputSignature}; use ndarray::{Array1, Array2}; +use serde::Deserialize; use crate::{manifest::FrameDecodeManifest, StyleType}; @@ -23,7 +24,8 @@ impl InferenceDomain for FrameDecodeDomain { } } -#[derive(Clone, Copy, Enum, InferenceOperation)] +#[derive(Clone, Copy, Deserialize, Enum, InferenceOperation)] +#[serde(rename_all = "snake_case")] #[inference_operation( type Domain = FrameDecodeDomain; )] diff --git a/crates/voicevox_core/src/infer/domains/singing_teacher.rs b/crates/voicevox_core/src/infer/domains/singing_teacher.rs index a2b9add80..a81e90d92 100644 --- a/crates/voicevox_core/src/infer/domains/singing_teacher.rs +++ b/crates/voicevox_core/src/infer/domains/singing_teacher.rs @@ -3,6 +3,7 @@ use std::{collections::BTreeSet, sync::LazyLock}; use enum_map::Enum; use macros::{InferenceInputSignature, InferenceOperation, InferenceOutputSignature}; use ndarray::{Array1, Array2}; +use serde::Deserialize; use crate::{manifest::SingingTeacherManifest, StyleType}; @@ -23,7 +24,8 @@ impl InferenceDomain for SingingTeacherDomain { } } -#[derive(Clone, Copy, Enum, InferenceOperation)] +#[derive(Clone, Copy, Deserialize, Enum, InferenceOperation)] +#[serde(rename_all = "snake_case")] #[inference_operation( type Domain = SingingTeacherDomain; )] diff --git a/crates/voicevox_core/src/infer/domains/talk.rs b/crates/voicevox_core/src/infer/domains/talk.rs index 3dbeac762..cc6e54bbc 100644 --- a/crates/voicevox_core/src/infer/domains/talk.rs +++ b/crates/voicevox_core/src/infer/domains/talk.rs @@ -3,6 +3,7 @@ use std::{collections::BTreeSet, sync::LazyLock}; use enum_map::Enum; use macros::{InferenceInputSignature, InferenceOperation, InferenceOutputSignature}; use ndarray::{Array0, Array1, Array2}; +use serde::Deserialize; use crate::{manifest::TalkManifest, StyleType}; @@ -23,7 +24,8 @@ impl InferenceDomain for TalkDomain { } } -#[derive(Clone, Copy, Enum, InferenceOperation)] +#[derive(Clone, Copy, Deserialize, Enum, InferenceOperation)] +#[serde(rename_all = "snake_case")] #[inference_operation( type Domain = TalkDomain; )] diff --git a/crates/voicevox_core/src/infer/model_file.rs b/crates/voicevox_core/src/infer/model_file.rs deleted file mode 100644 index 470ce9a6b..000000000 --- a/crates/voicevox_core/src/infer/model_file.rs +++ /dev/null @@ -1,5 +0,0 @@ -use super::DecryptModelError; - -pub(super) fn decrypt(content: &[u8]) -> std::result::Result, DecryptModelError> { - Ok(content.to_owned()) -} diff --git a/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs b/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs index 3cfd11608..3c5bf716d 100644 --- a/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs +++ b/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs @@ -24,11 +24,12 @@ use ort::{ use crate::{ devices::{DeviceSpec, GpuSpec, SupportedDevices}, error::ErrorRepr, + voice_model::ModelBytes, }; use super::super::{ - DecryptModelError, InferenceRuntime, InferenceSessionOptions, InputScalarKind, - OutputScalarKind, OutputTensor, ParamInfo, PushInputTensor, + InferenceRuntime, InferenceSessionOptions, InputScalarKind, OutputScalarKind, OutputTensor, + ParamInfo, PushInputTensor, }; impl InferenceRuntime for self::blocking::Onnxruntime { @@ -72,7 +73,7 @@ impl InferenceRuntime for self::blocking::Onnxruntime { fn new_session( &self, - model: impl FnOnce() -> std::result::Result, DecryptModelError>, + model: &ModelBytes, options: InferenceSessionOptions, ) -> anyhow::Result<( Self::Session, @@ -96,8 +97,10 @@ impl InferenceRuntime for self::blocking::Onnxruntime { } }; - let model = model()?; - let sess = builder.commit_from_memory(&{ model })?; + let sess = match model { + ModelBytes::Onnx(onnx) => builder.commit_from_memory(onnx), + ModelBytes::VvBin(bin) => builder.commit_from_vv_bin(bin), + }?; let input_param_infos = sess .inputs @@ -289,12 +292,10 @@ pub(crate) mod blocking { /// # use voicevox_core as another_lib; /// # /// # fn main() -> anyhow::Result<()> { - /// # if cfg!(windows) { - /// # // Windows\System32\onnxruntime.dllを回避 - /// # voicevox_core::blocking::Onnxruntime::load_once() - /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) - /// # .exec()?; - /// # } + /// # voicevox_core::blocking::Onnxruntime::load_once() + /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) + /// # .exec()?; + /// # /// let ort1 = voicevox_core::blocking::Onnxruntime::load_once().exec()?; /// let ort2 = another_lib::nonblocking::Onnxruntime::get().expect("`ort1`と同一のはず"); /// assert_eq!(ptr_addr(ort1), ptr_addr(ort2)); @@ -317,7 +318,7 @@ pub(crate) mod blocking { /// ONNX Runtimeのライブラリ名。 #[cfg(feature = "load-onnxruntime")] #[cfg_attr(docsrs, doc(cfg(feature = "load-onnxruntime")))] - pub const LIB_NAME: &'static str = "onnxruntime"; + pub const LIB_NAME: &'static str = "voicevox_onnxruntime"; /// 推奨されるONNX Runtimeのバージョン。 #[cfg(feature = "load-onnxruntime")] @@ -478,12 +479,10 @@ pub(crate) mod nonblocking { /// # /// # #[pollster::main] /// # async fn main() -> anyhow::Result<()> { - /// # if cfg!(windows) { - /// # // Windows\System32\onnxruntime.dllを回避 - /// # voicevox_core::blocking::Onnxruntime::load_once() - /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) - /// # .exec()?; - /// # } + /// # voicevox_core::blocking::Onnxruntime::load_once() + /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) + /// # .exec()?; + /// # /// let ort1 = voicevox_core::nonblocking::Onnxruntime::load_once() /// .exec() /// .await?; @@ -513,7 +512,7 @@ pub(crate) mod nonblocking { #[cfg(feature = "load-onnxruntime")] #[cfg_attr(docsrs, doc(cfg(feature = "load-onnxruntime")))] // ブロッキング版と等しいことはテストで担保 - pub const LIB_NAME: &'static str = "onnxruntime"; + pub const LIB_NAME: &'static str = "voicevox_onnxruntime"; /// 推奨されるONNX Runtimeのバージョン。 #[cfg(feature = "load-onnxruntime")] diff --git a/crates/voicevox_core/src/infer/session_set.rs b/crates/voicevox_core/src/infer/session_set.rs index 1bac459b7..cbbddfec0 100644 --- a/crates/voicevox_core/src/infer/session_set.rs +++ b/crates/voicevox_core/src/infer/session_set.rs @@ -4,10 +4,10 @@ use anyhow::bail; use enum_map::{Enum as _, EnumMap}; use itertools::Itertools as _; -use crate::error::ErrorRepr; +use crate::{error::ErrorRepr, voice_model::ModelBytes}; use super::{ - model_file, InferenceDomain, InferenceInputSignature, InferenceOperation, InferenceRuntime, + InferenceDomain, InferenceInputSignature, InferenceOperation, InferenceRuntime, InferenceSessionOptions, InferenceSignature, ParamInfo, }; @@ -18,7 +18,7 @@ pub(crate) struct InferenceSessionSet( impl InferenceSessionSet { pub(crate) fn new( rt: &R, - model_bytes: &EnumMap>, + model_bytes: &EnumMap, options: &EnumMap, ) -> anyhow::Result { let mut sessions = model_bytes @@ -28,7 +28,7 @@ impl InferenceSessionSet { ::PARAM_INFOS[op]; let (sess, actual_input_param_infos, actual_output_param_infos) = - rt.new_session(|| model_file::decrypt(model_bytes), options[op])?; + rt.new_session(model_bytes, options[op])?; check_param_infos(expected_input_param_infos, &actual_input_param_infos)?; check_param_infos(expected_output_param_infos, &actual_output_param_infos)?; diff --git a/crates/voicevox_core/src/manifest.rs b/crates/voicevox_core/src/manifest.rs index 0c11c3647..0129c84e1 100644 --- a/crates/voicevox_core/src/manifest.rs +++ b/crates/voicevox_core/src/manifest.rs @@ -1,14 +1,13 @@ use std::{ collections::BTreeMap, fmt::{self, Display}, - ops::Index, sync::Arc, }; use derive_getters::Getters; -use derive_more::Deref; +use derive_more::{Deref, Index}; use derive_new::new; -use enum_map::{Enum, EnumMap}; +use enum_map::EnumMap; use serde::{de, Deserialize, Deserializer, Serialize}; use serde_with::{serde_as, DisplayFromStr}; @@ -86,109 +85,62 @@ pub struct Manifest { pub(crate) type ManifestDomains = inference_domain_map_values!(for Option); // TODO: #825 が終わったら`singing_teacher`と`frame_decode`のやつと統一する -#[derive(Deserialize)] +#[derive(Index, Deserialize)] #[cfg_attr(test, derive(Default))] pub(crate) struct TalkManifest { + #[index] #[serde(flatten)] - filenames: EnumMap>, + filenames: EnumMap, #[serde(default)] pub(crate) style_id_to_inner_voice_id: StyleIdToInnerVoiceId, } -#[derive(Deserialize)] +// TODO: #825 が終わったら`singing_teacher`と`frame_decode`のやつと統一する +#[derive(Index, Deserialize)] #[cfg_attr(test, derive(Default))] pub(crate) struct SingingTeacherManifest { + #[index] #[serde(flatten)] - filenames: EnumMap>, + filenames: EnumMap, #[serde(default)] pub(crate) style_id_to_inner_voice_id: StyleIdToInnerVoiceId, } -#[derive(Deserialize)] +// TODO: #825 が終わったら`singing_teacher`と`frame_decode`のやつと統一する +#[derive(Index, Deserialize)] #[cfg_attr(test, derive(Default))] pub(crate) struct FrameDecodeManifest { + #[index] #[serde(flatten)] - filenames: EnumMap>, + filenames: EnumMap, #[serde(default)] pub(crate) style_id_to_inner_voice_id: StyleIdToInnerVoiceId, } -// TODO: #825 では`TalkOperation`と統合する。`Index`の実装もderive_moreで委譲する -#[derive(Enum, Deserialize)] -pub(crate) enum TalkOperationFilenameKey { - #[serde(rename = "predict_duration_filename")] - PredictDuration, - #[serde(rename = "predict_intonation_filename")] - PredictIntonation, - #[serde(rename = "generate_full_intermediate_filename")] - GenerateFullIntermediate, - #[serde(rename = "render_audio_segment_filename")] - RenderAudioSegment, -} - -impl Index for TalkManifest { - type Output = Arc; - - fn index(&self, index: TalkOperation) -> &Self::Output { - let key = match index { - TalkOperation::PredictDuration => TalkOperationFilenameKey::PredictDuration, - TalkOperation::PredictIntonation => TalkOperationFilenameKey::PredictIntonation, - TalkOperation::GenerateFullIntermediate => { - TalkOperationFilenameKey::GenerateFullIntermediate - } - TalkOperation::RenderAudioSegment => TalkOperationFilenameKey::RenderAudioSegment, - }; - &self.filenames[key] - } -} - -#[derive(Enum, Deserialize)] -pub(crate) enum SingingTeacherOperationFilenameKey { - #[serde(rename = "predict_sing_consonant_length_filename")] - PredictSingConsonantLength, - #[serde(rename = "predict_sing_f0_filename")] - PredictSingF0, - #[serde(rename = "predict_sing_volume_filename")] - PredictSingVolume, +#[derive(Deserialize, Clone)] +pub(crate) struct ModelFile { + pub(crate) r#type: ModelFileType, + pub(crate) filename: Arc, } -impl Index for SingingTeacherManifest { - type Output = Arc; - - fn index(&self, index: SingingTeacherOperation) -> &Self::Output { - let key = match index { - SingingTeacherOperation::PredictSingConsonantLength => { - SingingTeacherOperationFilenameKey::PredictSingConsonantLength - } - SingingTeacherOperation::PredictSingF0 => { - SingingTeacherOperationFilenameKey::PredictSingF0 - } - SingingTeacherOperation::PredictSingVolume => { - SingingTeacherOperationFilenameKey::PredictSingVolume - } - }; - &self.filenames[key] +#[cfg(test)] +impl Default for ModelFile { + fn default() -> Self { + Self { + r#type: ModelFileType::Onnx, + filename: "".into(), + } } } -#[derive(Enum, Deserialize)] -pub(crate) enum FrameDecodeOperationFilenameKey { - #[serde(rename = "sf_decode_filename")] - SfDecode, -} - -impl Index for FrameDecodeManifest { - type Output = Arc; - - fn index(&self, index: FrameDecodeOperation) -> &Self::Output { - let key = match index { - FrameDecodeOperation::SfDecode => FrameDecodeOperationFilenameKey::SfDecode, - }; - &self.filenames[key] - } +#[derive(Deserialize, Clone, Copy)] +#[serde(rename_all = "snake_case")] +pub(crate) enum ModelFileType { + Onnx, + VvBin, } #[serde_as] diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index c49763252..9863ba5d7 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -1330,12 +1330,10 @@ pub(crate) mod blocking { /// AccelerationMode, InitializeOptions, /// }; /// - /// # if cfg!(windows) { - /// # // Windows\System32\onnxruntime.dllを回避 - /// # voicevox_core::blocking::Onnxruntime::load_once() - /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) - /// # .exec()?; - /// # } + /// # voicevox_core::blocking::Onnxruntime::load_once() + /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) + /// # .exec()?; + /// # /// let mut syntesizer = Synthesizer::new( /// Onnxruntime::load_once().exec()?, /// Arc::new(OpenJtalk::new(OPEN_JTALK_DIC_DIR).unwrap()), @@ -1784,12 +1782,10 @@ pub(crate) mod nonblocking { /// AccelerationMode, InitializeOptions, /// }; /// - /// # if cfg!(windows) { - /// # // Windows\System32\onnxruntime.dllを回避 - /// # voicevox_core::blocking::Onnxruntime::load_once() - /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) - /// # .exec()?; - /// # } + /// # voicevox_core::blocking::Onnxruntime::load_once() + /// # .filename(test_util::ONNXRUNTIME_DYLIB_PATH) + /// # .exec()?; + /// # /// let mut syntesizer = Synthesizer::new( /// Onnxruntime::load_once().exec().await?, /// Arc::new(OpenJtalk::new(OPEN_JTALK_DIC_DIR).await.unwrap()), diff --git a/crates/voicevox_core/src/voice_model.rs b/crates/voicevox_core/src/voice_model.rs index 754064a29..67fec8580 100644 --- a/crates/voicevox_core/src/voice_model.rs +++ b/crates/voicevox_core/src/voice_model.rs @@ -29,7 +29,7 @@ use crate::{ }, InferenceDomain, }, - manifest::{Manifest, ManifestDomains, StyleIdToInnerVoiceId}, + manifest::{Manifest, ManifestDomains, ModelFile, ModelFileType, StyleIdToInnerVoiceId}, SpeakerMeta, StyleMeta, StyleType, VoiceModelMeta, }; @@ -39,7 +39,7 @@ use crate::{ pub type RawVoiceModelId = Uuid; pub(crate) type ModelBytesWithInnerVoiceIdsByDomain = inference_domain_map_values!( - for Option<(StyleIdToInnerVoiceId, EnumMap>)> + for Option<(StyleIdToInnerVoiceId, EnumMap)> ); /// 音声モデルID。 @@ -142,8 +142,9 @@ impl Inner { talk: |talk| { talk.as_ref() .map(|manifest| { - let indices = EnumMap::from_fn(|k| &manifest[k]) - .try_map(|_, s| find_entry_index(s))?; + let indices = EnumMap::from_fn(|k| &manifest[k]).try_map( + |_, ModelFile { filename, .. }| find_entry_index(filename), + )?; Ok(InferenceModelEntry { indices, manifest }) }) .transpose() @@ -160,8 +161,9 @@ impl Inner { singing_teacher .as_ref() .map(|manifest| { - let indices = EnumMap::from_fn(|k| &manifest[k]) - .try_map(|_, s| find_entry_index(s))?; + let indices = EnumMap::from_fn(|k| &manifest[k]).try_map( + |_, ModelFile { filename, .. }| find_entry_index(filename), + )?; Ok(InferenceModelEntry { indices, manifest }) }) .transpose() @@ -178,8 +180,9 @@ impl Inner { frame_decode .as_ref() .map(|manifest| { - let indices = EnumMap::from_fn(|k| &manifest[k]) - .try_map(|_, s| find_entry_index(s))?; + let indices = EnumMap::from_fn(|k| &manifest[k]).try_map( + |_, ModelFile { filename, .. }| find_entry_index(filename), + )?; Ok(InferenceModelEntry { indices, manifest }) }) .transpose() @@ -250,8 +253,9 @@ impl Inner { macro_rules! read_file { ($entry:expr $(,)?) => {{ - let (index, filename): (usize, Arc) = $entry; - zip.read_file(index) + let (index, ModelFile { r#type, filename }): (usize, ModelFile) = $entry; + let bytes = zip + .read_file(index) .map_err(move |source| { error( LoadModelErrorKind::ReadZipEntry { @@ -260,7 +264,8 @@ impl Inner { source, ) }) - .await? + .await?; + ModelBytes::new(r#type, bytes) }}; } @@ -473,6 +478,20 @@ impl VoiceModelHeader { } } +pub(crate) enum ModelBytes { + Onnx(Vec), + VvBin(Vec), +} + +impl ModelBytes { + fn new(kind: ModelFileType, bytes: Vec) -> Self { + (match kind { + ModelFileType::Onnx => Self::Onnx, + ModelFileType::VvBin => Self::VvBin, + })(bytes) + } +} + impl InferenceDomainMap { /// manifestとして対応していない`StyleType`に対してエラーを発する。 /// diff --git a/crates/voicevox_core_c_api/src/compatible_engine.rs b/crates/voicevox_core_c_api/src/compatible_engine.rs index ab191164c..b55a73523 100644 --- a/crates/voicevox_core_c_api/src/compatible_engine.rs +++ b/crates/voicevox_core_c_api/src/compatible_engine.rs @@ -7,6 +7,7 @@ use std::{ use libc::c_int; +use tracing::warn; use voicevox_core::{StyleId, VoiceModelId, __internal::interop::PerformInference as _}; use crate::{helpers::display_error, init_logger_once}; @@ -26,8 +27,20 @@ macro_rules! ensure_initialized { static ERROR_MESSAGE: LazyLock> = LazyLock::new(|| Mutex::new(String::new())); static ONNXRUNTIME: LazyLock<&'static voicevox_core::blocking::Onnxruntime> = LazyLock::new(|| { + let alt_onnxruntime_filename = voicevox_core::blocking::Onnxruntime::LIB_VERSIONED_FILENAME + .replace( + voicevox_core::blocking::Onnxruntime::LIB_NAME, + "onnxruntime", + ); voicevox_core::blocking::Onnxruntime::load_once() .exec() + .or_else(|err| { + warn!("{err}"); + warn!("falling back to `{alt_onnxruntime_filename}`"); + voicevox_core::blocking::Onnxruntime::load_once() + .filename(alt_onnxruntime_filename) + .exec() + }) .unwrap_or_else(|err| { display_error(&err); panic!("ONNX Runtimeをロードもしくは初期化ができなかったため、クラッシュします"); diff --git a/crates/voicevox_core_c_api/tests/e2e/log_mask.rs b/crates/voicevox_core_c_api/tests/e2e/log_mask.rs index a9ffe0f6e..68b9fae71 100644 --- a/crates/voicevox_core_c_api/tests/e2e/log_mask.rs +++ b/crates/voicevox_core_c_api/tests/e2e/log_mask.rs @@ -1,5 +1,6 @@ use std::sync::LazyLock; +use const_format::concatcp; use regex::{Regex, Replacer}; use crate::assert_cdylib::Utf8Output; @@ -21,10 +22,22 @@ impl Utf8Output { ) } - pub(crate) fn mask_onnxruntime_version(self) -> Self { + pub(crate) fn mask_onnxruntime_filename(self) -> Self { self.mask_stderr( - static_regex!(regex::escape(ort::downloaded_version!())), - "{onnxruntime_version}", + static_regex!(regex::escape( + const { + if cfg!(windows) { + r"onnxruntime.dll" + } else if cfg!(target_os = "linux") { + concatcp!("libonnxruntime.so.", ort::downloaded_version!()) + } else if cfg!(target_os = "macos") { + concatcp!("libonnxruntime.", ort::downloaded_version!(), ".dylib") + } else { + panic!("unsupported") + } + } + )), + "{onnxruntime_filename}", ) } diff --git a/crates/voicevox_core_c_api/tests/e2e/snapshots.toml b/crates/voicevox_core_c_api/tests/e2e/snapshots.toml index 87a704af4..f6b9f6928 100644 --- a/crates/voicevox_core_c_api/tests/e2e/snapshots.toml +++ b/crates/voicevox_core_c_api/tests/e2e/snapshots.toml @@ -71,10 +71,14 @@ metas = ''' } ]''' stderr.windows = ''' +{timestamp} WARN voicevox_core::compatible_engine: ONNX Runtimeのロードまたは初期化ができませんでした +{timestamp} WARN voicevox_core::compatible_engine: falling back to `{onnxruntime_filename}` {windows-video-cards} {timestamp} INFO voicevox_core::synthesizer: CPUを利用します ''' stderr.unix = ''' +{timestamp} WARN voicevox_core::compatible_engine: ONNX Runtimeのロードまたは初期化ができませんでした +{timestamp} WARN voicevox_core::compatible_engine: falling back to `{onnxruntime_filename}` {timestamp} INFO voicevox_core::synthesizer: CPUを利用します ''' diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine.rs index badf165fd..6e31f557e 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine.rs @@ -171,7 +171,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine_load_model_before_initialize.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine_load_model_before_initialize.rs index 7b709a83d..2d7ade9fd 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine_load_model_before_initialize.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/compatible_engine_load_model_before_initialize.rs @@ -33,7 +33,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/double_delete_synthesizer.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/double_delete_synthesizer.rs index 170ee718f..f03583613 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/double_delete_synthesizer.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/double_delete_synthesizer.rs @@ -1,13 +1,21 @@ //! `voicevox_synthesizer_delete`を二度呼ぶとクラッシュすることを確認する。 -use std::{ffi::CString, mem::MaybeUninit, sync::LazyLock}; +use std::{ + env, + ffi::{CStr, CString}, + mem::MaybeUninit, + sync::LazyLock, +}; use assert_cmd::assert::AssertResult; +use const_format::concatcp; use indexmap::IndexSet; use libloading::Library; use serde::{Deserialize, Serialize}; use test_util::{ - c_api::{self, CApi, VoicevoxInitializeOptions, VoicevoxResultCode}, + c_api::{ + self, CApi, VoicevoxInitializeOptions, VoicevoxLoadOnnxruntimeOptions, VoicevoxResultCode, + }, OPEN_JTALK_DIC_DIR, }; @@ -28,10 +36,24 @@ impl assert_cdylib::TestCase for TestCase { let onnxruntime = { let mut onnxruntime = MaybeUninit::uninit(); - assert_ok(lib.voicevox_onnxruntime_load_once( - lib.voicevox_make_default_load_onnxruntime_options(), - onnxruntime.as_mut_ptr(), - )); + assert_ok( + lib.voicevox_onnxruntime_load_once( + VoicevoxLoadOnnxruntimeOptions { + filename: CStr::from_bytes_with_nul( + concatcp!( + env::consts::DLL_PREFIX, + "onnxruntime", + env::consts::DLL_SUFFIX, + '\0' + ) + .as_ref(), + ) + .expect("this ends with nul") + .as_ptr(), + }, + onnxruntime.as_mut_ptr(), + ), + ); onnxruntime.assume_init() }; 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 a36a7d9bd..fe9d518a1 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 @@ -1,10 +1,11 @@ -use std::{collections::HashMap, ffi::CStr, mem::MaybeUninit, str, sync::LazyLock}; +use std::{collections::HashMap, env, ffi::CStr, mem::MaybeUninit, str, sync::LazyLock}; use assert_cmd::assert::AssertResult; +use const_format::concatcp; use libloading::Library; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DisplayFromStr}; -use test_util::c_api::{self, CApi, VoicevoxResultCode}; +use test_util::c_api::{self, CApi, VoicevoxLoadOnnxruntimeOptions, VoicevoxResultCode}; use voicevox_core::SupportedDevices; use crate::{ @@ -29,10 +30,31 @@ impl assert_cdylib::TestCase for TestCase { let onnxruntime = { let mut onnxruntime = MaybeUninit::uninit(); - assert_ok(lib.voicevox_onnxruntime_load_once( - lib.voicevox_make_default_load_onnxruntime_options(), - onnxruntime.as_mut_ptr(), - )); + let _ = const { + if true { + 0 + } else { + panic!(); + } + }; + assert_ok( + lib.voicevox_onnxruntime_load_once( + VoicevoxLoadOnnxruntimeOptions { + filename: CStr::from_bytes_with_nul( + concatcp!( + env::consts::DLL_PREFIX, + "onnxruntime", + env::consts::DLL_SUFFIX, + '\0' + ) + .as_ref(), + ) + .expect("this ends with nul") + .as_ptr(), + }, + onnxruntime.as_mut_ptr(), + ), + ); onnxruntime.assume_init() }; @@ -89,7 +111,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? 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 1997d30e9..28e734ea4 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 @@ -1,10 +1,19 @@ -use std::{collections::HashMap, ffi::CString, mem::MaybeUninit, sync::LazyLock}; +use std::{ + collections::HashMap, + env, + ffi::{CStr, CString}, + mem::MaybeUninit, + sync::LazyLock, +}; use assert_cmd::assert::AssertResult; +use const_format::concatcp; use libloading::Library; use serde::{Deserialize, Serialize}; use test_util::{ - c_api::{self, CApi, VoicevoxInitializeOptions, VoicevoxResultCode}, + c_api::{ + self, CApi, VoicevoxInitializeOptions, VoicevoxLoadOnnxruntimeOptions, VoicevoxResultCode, + }, OPEN_JTALK_DIC_DIR, }; @@ -38,10 +47,24 @@ impl assert_cdylib::TestCase for TestCase { let onnxruntime = { let mut onnxruntime = MaybeUninit::uninit(); - assert_ok(lib.voicevox_onnxruntime_load_once( - lib.voicevox_make_default_load_onnxruntime_options(), - onnxruntime.as_mut_ptr(), - )); + assert_ok( + lib.voicevox_onnxruntime_load_once( + VoicevoxLoadOnnxruntimeOptions { + filename: CStr::from_bytes_with_nul( + concatcp!( + env::consts::DLL_PREFIX, + "onnxruntime", + env::consts::DLL_SUFFIX, + '\0' + ) + .as_ref(), + ) + .expect("this ends with nul") + .as_ptr(), + }, + onnxruntime.as_mut_ptr(), + ), + ); onnxruntime.assume_init() }; @@ -105,7 +128,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_output_json.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_output_json.rs index ac662d06e..ecaced0c4 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_output_json.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_output_json.rs @@ -1,15 +1,19 @@ use std::{ + env, ffi::{CStr, CString}, mem::MaybeUninit, sync::LazyLock, }; use assert_cmd::assert::AssertResult; +use const_format::concatcp; use libloading::Library; use serde::{Deserialize, Serialize}; use test_util::{ - c_api::{self, CApi, VoicevoxInitializeOptions, VoicevoxResultCode}, + c_api::{ + self, CApi, VoicevoxInitializeOptions, VoicevoxLoadOnnxruntimeOptions, VoicevoxResultCode, + }, OPEN_JTALK_DIC_DIR, }; @@ -30,10 +34,24 @@ impl assert_cdylib::TestCase for TestCase { let onnxruntime = { let mut onnxruntime = MaybeUninit::uninit(); - assert_ok(lib.voicevox_onnxruntime_load_once( - lib.voicevox_make_default_load_onnxruntime_options(), - onnxruntime.as_mut_ptr(), - )); + assert_ok( + lib.voicevox_onnxruntime_load_once( + VoicevoxLoadOnnxruntimeOptions { + filename: CStr::from_bytes_with_nul( + concatcp!( + env::consts::DLL_PREFIX, + "onnxruntime", + env::consts::DLL_SUFFIX, + '\0' + ) + .as_ref(), + ) + .expect("this ends with nul") + .as_ptr(), + }, + onnxruntime.as_mut_ptr(), + ), + ); onnxruntime.assume_init() }; @@ -95,7 +113,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? 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 2536a73d3..32fabe3f4 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 @@ -1,10 +1,19 @@ -use std::{collections::HashMap, ffi::CString, mem::MaybeUninit, sync::LazyLock}; +use std::{ + collections::HashMap, + env, + ffi::{CStr, CString}, + mem::MaybeUninit, + sync::LazyLock, +}; use assert_cmd::assert::AssertResult; +use const_format::concatcp; use libloading::Library; use serde::{Deserialize, Serialize}; use test_util::{ - c_api::{self, CApi, VoicevoxInitializeOptions, VoicevoxResultCode}, + c_api::{ + self, CApi, VoicevoxInitializeOptions, VoicevoxLoadOnnxruntimeOptions, VoicevoxResultCode, + }, OPEN_JTALK_DIC_DIR, }; @@ -38,10 +47,24 @@ impl assert_cdylib::TestCase for TestCase { let onnxruntime = { let mut onnxruntime = MaybeUninit::uninit(); - assert_ok(lib.voicevox_onnxruntime_load_once( - lib.voicevox_make_default_load_onnxruntime_options(), - onnxruntime.as_mut_ptr(), - )); + assert_ok( + lib.voicevox_onnxruntime_load_once( + VoicevoxLoadOnnxruntimeOptions { + filename: CStr::from_bytes_with_nul( + concatcp!( + env::consts::DLL_PREFIX, + "onnxruntime", + env::consts::DLL_SUFFIX, + '\0' + ) + .as_ref(), + ) + .expect("this ends with nul") + .as_ptr(), + }, + onnxruntime.as_mut_ptr(), + ), + ); onnxruntime.assume_init() }; @@ -117,7 +140,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? 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 25915bc10..a6e234eaa 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 @@ -1,14 +1,18 @@ // ユーザー辞書の登録によって読みが変化することを確認するテスト。 // 辞書ロード前後でAudioQueryのkanaが変化するかどうかで確認する。 +use std::env; use std::ffi::{CStr, CString}; use std::mem::MaybeUninit; use std::sync::LazyLock; use assert_cmd::assert::AssertResult; +use const_format::concatcp; use libloading::Library; use serde::{Deserialize, Serialize}; -use test_util::c_api::{self, CApi, VoicevoxInitializeOptions, VoicevoxResultCode}; +use test_util::c_api::{ + self, CApi, VoicevoxInitializeOptions, VoicevoxLoadOnnxruntimeOptions, VoicevoxResultCode, +}; use test_util::OPEN_JTALK_DIC_DIR; use crate::{ @@ -55,10 +59,24 @@ impl assert_cdylib::TestCase for TestCase { let onnxruntime = { let mut onnxruntime = MaybeUninit::uninit(); - assert_ok(lib.voicevox_onnxruntime_load_once( - lib.voicevox_make_default_load_onnxruntime_options(), - onnxruntime.as_mut_ptr(), - )); + assert_ok( + lib.voicevox_onnxruntime_load_once( + VoicevoxLoadOnnxruntimeOptions { + filename: CStr::from_bytes_with_nul( + concatcp!( + env::consts::DLL_PREFIX, + "onnxruntime", + env::consts::DLL_SUFFIX, + '\0' + ) + .as_ref(), + ) + .expect("this ends with nul") + .as_ptr(), + }, + onnxruntime.as_mut_ptr(), + ), + ); onnxruntime.assume_init() }; @@ -134,7 +152,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? diff --git a/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_manipulate.rs b/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_manipulate.rs index 14245444f..85494ddd0 100644 --- a/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_manipulate.rs +++ b/crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_manipulate.rs @@ -137,7 +137,7 @@ impl assert_cdylib::TestCase for TestCase { fn assert_output(&self, output: Utf8Output) -> AssertResult { output .mask_timestamps() - .mask_onnxruntime_version() + .mask_onnxruntime_filename() .mask_windows_video_cards() .assert() .try_success()? diff --git a/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/blocking/Onnxruntime.java b/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/blocking/Onnxruntime.java index 5dc0430c9..90c02a670 100644 --- a/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/blocking/Onnxruntime.java +++ b/crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/blocking/Onnxruntime.java @@ -25,7 +25,7 @@ public class Onnxruntime { } /** ONNX Runtimeのライブラリ名。 */ - public static final String LIB_NAME = "onnxruntime"; + public static final String LIB_NAME = "voicevox_onnxruntime"; /** 推奨されるONNX Runtimeのバージョン。 */ public static final String LIB_VERSION = "1.17.3"; diff --git a/crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/TestUtils.java b/crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/TestUtils.java index d73566b15..7355c8ba6 100644 --- a/crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/TestUtils.java +++ b/crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/TestUtils.java @@ -19,7 +19,9 @@ protected VoiceModelFile openModel() { } protected Onnxruntime loadOnnxruntime() { - final String FILENAME = "../../test_util/data/lib/" + Onnxruntime.LIB_VERSIONED_FILENAME; + final String FILENAME = + "../../test_util/data/lib/" + + Onnxruntime.LIB_VERSIONED_FILENAME.replace("voicevox_onnxruntime", "onnxruntime"); try { return Onnxruntime.loadOnce().filename(FILENAME).exec(); diff --git a/crates/voicevox_core_python_api/python/test/conftest.py b/crates/voicevox_core_python_api/python/test/conftest.py index 430e415c1..c55fcb4a4 100644 --- a/crates/voicevox_core_python_api/python/test/conftest.py +++ b/crates/voicevox_core_python_api/python/test/conftest.py @@ -13,7 +13,9 @@ / "test_util" / "data" / "lib" - / voicevox_core.blocking.Onnxruntime.LIB_VERSIONED_FILENAME + / voicevox_core.blocking.Onnxruntime.LIB_VERSIONED_FILENAME.replace( + "voicevox_onnxruntime", "onnxruntime" + ) ) open_jtalk_dic_dir = ( root_dir.parent.parent.parent / "test_util" / "data" / "open_jtalk_dic_utf_8-1.11" diff --git a/crates/voicevox_core_python_api/python/voicevox_core/_rust/asyncio.pyi b/crates/voicevox_core_python_api/python/voicevox_core/_rust/asyncio.pyi index 199ced742..0c0f3b23f 100644 --- a/crates/voicevox_core_python_api/python/voicevox_core/_rust/asyncio.pyi +++ b/crates/voicevox_core_python_api/python/voicevox_core/_rust/asyncio.pyi @@ -69,7 +69,7 @@ class Onnxruntime: # ここの定数値が本物と合致するかどうかは、test_type_stub_consts.pyで担保する。 - LIB_NAME: str = "onnxruntime" + LIB_NAME: str = "voicevox_onnxruntime" """ONNX Runtimeのライブラリ名。""" LIB_VERSION: str = "1.17.3" diff --git a/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi b/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi index 2db76bc7a..51e7a29aa 100644 --- a/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi +++ b/crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi @@ -69,7 +69,7 @@ class Onnxruntime: # ここの定数値が本物と合致するかどうかは、test_type_stub_consts.pyで担保する。 - LIB_NAME: str = "onnxruntime" + LIB_NAME: str = "voicevox_onnxruntime" """ONNX Runtimeのライブラリ名。""" LIB_VERSION: str = "1.17.3" diff --git a/model/sample.vvm/manifest.json b/model/sample.vvm/manifest.json index 6161d204a..6981f1506 100644 --- a/model/sample.vvm/manifest.json +++ b/model/sample.vvm/manifest.json @@ -3,25 +3,49 @@ "id": "018fa5b1-146c-71e9-b523-6f6dabcf05fe", "metas_filename": "metas.json", "talk": { - "predict_duration_filename": "predict_duration.onnx", - "predict_intonation_filename": "predict_intonation.onnx", - "generate_full_intermediate_filename": "predict_spectrogram.onnx", - "render_audio_segment_filename": "vocoder.onnx", + "predict_duration": { + "type": "onnx", + "filename": "predict_duration.onnx" + }, + "predict_intonation": { + "type": "onnx", + "filename": "predict_intonation.onnx" + }, + "generate_full_intermediate": { + "type": "onnx", + "filename": "predict_spectrogram.onnx" + }, + "render_audio_segment": { + "type": "onnx", + "filename": "vocoder.onnx" + }, "style_id_to_inner_voice_id": { "302": 2, "303": 3 } }, "singing_teacher": { - "predict_sing_consonant_length_filename": "predict_sing_consonant_length.onnx", - "predict_sing_f0_filename": "predict_sing_f0.onnx", - "predict_sing_volume_filename": "predict_sing_volume.onnx", + "predict_sing_consonant_length": { + "type": "onnx", + "filename": "predict_sing_consonant_length.onnx" + }, + "predict_sing_f0": { + "type": "onnx", + "filename": "predict_sing_f0.onnx" + }, + "predict_sing_volume": { + "type": "onnx", + "filename": "predict_sing_volume.onnx" + }, "style_id_to_inner_voice_id": { "6000": 0 } }, "frame_decode": { - "sf_decode_filename": "sf_decode.onnx", + "sf_decode": { + "type": "onnx", + "filename": "sf_decode.onnx" + }, "style_id_to_inner_voice_id": { "3000": 0 }