Skip to content

Commit

Permalink
Update submodule (#152)
Browse files Browse the repository at this point in the history
* Update submodule

* make generate

* 別のWorkflowで実体を使いたくなるので、unlinkする

* libonnxruntimeもcacheしたりrestoreしたりする

* このWorkflowから使いたいし、on: pull_requestにする

* voicevox_coreをビルドした時に使われたonnxruntimeを使うようにする

* dlopenで使うのはシステムの設定で、明示的にパスを渡さないと参照できないので、Defaultは使わずに使う時に明示する

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: yamachu <[email protected]>
  • Loading branch information
3 people authored Jan 28, 2025
1 parent 130dfd7 commit 413af2f
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 20 deletions.
13 changes: 13 additions & 0 deletions .github/composite/build-dev-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ runs:
shell: bash
working-directory: ./binding
run: make build/dev-library
- if: ${{ steps.restore-dev-library.outputs.cache-hit != 'true' }}
shell: bash
working-directory: ./binding/voicevox_core/target/release
# ライブラリのシンボリックリンクをコピーしてリンクを解除する
run: |
find . -type l | while read link; do
target=$(readlink "$link")
if [ -f "$target" ]; then
cp "$target" "$link".tmp
unlink "$link"
mv "$link".tmp "$link"
fi
done
- if: ${{ steps.restore-dev-library.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/csharp_test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI

on:
push:
pull_request:
branches-ignore:
- 'auto.**'
workflow_call:
Expand All @@ -24,7 +24,9 @@ jobs:
ref: ${{ inputs.checkout-ref || github.head_ref }}
- uses: ./.github/composite/build-dev-rust
with:
cache-path: ./binding/voicevox_core/target/release/libvoicevox_core.so
cache-path: |
./binding/voicevox_core/target/release/libvoicevox_core.so
./binding/voicevox_core/target/release/libonnxruntime.so
cache-key: ${{ runner.os }}-dev-library-${{ hashFiles('**/Cargo.lock', '**/VoicevoxCoreSharp.Core.Metas.props') }}

test-dotnet:
Expand All @@ -40,9 +42,13 @@ jobs:
dotnet-version: 6
- uses: actions/cache/restore@v4
with:
path: ./binding/voicevox_core/target/release/libvoicevox_core.so
path: |
./binding/voicevox_core/target/release/libvoicevox_core.so
./binding/voicevox_core/target/release/libonnxruntime.so
key: ${{ runner.os }}-dev-library-${{ hashFiles('**/Cargo.lock', '**/VoicevoxCoreSharp.Core.Metas.props') }}
- run: cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./tests/VoicevoxCoreSharp.Core.Tests/resources/libvoicevox_core.so
- run: |
cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./tests/VoicevoxCoreSharp.Core.Tests/resources/libvoicevox_core.so
cp ./binding/voicevox_core/target/release/libonnxruntime.so ./tests/VoicevoxCoreSharp.Core.Tests/resources/libonnxruntime.so
- uses: ./.github/composite/download-openjtalk-dict
with:
cache-path: open_jtalk_dic_utf_8-1.11.tar.gz
Expand All @@ -67,10 +73,14 @@ jobs:
dotnet-version: 8
- uses: actions/cache/restore@v4
with:
path: ./binding/voicevox_core/target/release/libvoicevox_core.so
path: |
./binding/voicevox_core/target/release/libvoicevox_core.so
./binding/voicevox_core/target/release/libonnxruntime.so
key: ${{ runner.os }}-dev-library-${{ hashFiles('**/Cargo.lock', '**/VoicevoxCoreSharp.Core.Metas.props') }}
- run: mkdir -p ./examples/cli/voicevox_core
- run: cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./examples/cli/voicevox_core/libvoicevox_core.so
- run: |
cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./examples/cli/voicevox_core/libvoicevox_core.so
cp ./binding/voicevox_core/target/release/libonnxruntime.so ./examples/cli/voicevox_core/libonnxruntime.so
- uses: ./.github/composite/download-openjtalk-dict
with:
cache-path: open_jtalk_dic_utf_8-1.11.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion binding/voicevox_core
Submodule voicevox_core updated 39 files
+11 −0 .github/actions/install-cargo-deny/action.yml
+24 −0 .github/workflows/audit.yml
+1 −1 .github/workflows/build_and_deploy_downloader.yml
+0 −16 .github/workflows/cargo-deny.yml
+22 −0 .github/workflows/licenses.yml
+1 −1 _typos.toml
+6 −8 crates/voicevox_core/src/__internal/doctest_fixtures.rs
+4 −1 crates/voicevox_core/src/__internal/interop.rs
+7 −0 crates/voicevox_core/src/blocking.rs
+17 −3 crates/voicevox_core/src/infer.rs
+81 −22 crates/voicevox_core/src/infer/domains.rs
+52 −0 crates/voicevox_core/src/infer/domains/frame_decode.rs
+95 −0 crates/voicevox_core/src/infer/domains/singing_teacher.rs
+7 −1 crates/voicevox_core/src/infer/runtimes/onnxruntime.rs
+1 −1 crates/voicevox_core/src/lib.rs
+71 −1 crates/voicevox_core/src/manifest.rs
+9 −0 crates/voicevox_core/src/nonblocking.rs
+30 −5 crates/voicevox_core/src/status.rs
+1,644 −1,141 crates/voicevox_core/src/synthesizer.rs
+143 −30 crates/voicevox_core/src/voice_model.rs
+0 −12 crates/voicevox_core_c_api/build.rs
+12 −9 crates/voicevox_core_c_api/src/c_impls.rs
+216 −12 crates/voicevox_core_c_api/src/compatible_engine.rs
+10 −35 crates/voicevox_core_c_api/src/helpers.rs
+28 −21 crates/voicevox_core_c_api/src/lib.rs
+1 −1 crates/voicevox_core_c_api/tests/e2e/log_mask.rs
+50 −10 crates/voicevox_core_c_api/tests/e2e/snapshots.toml
+1 −1 crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/blocking/SynthesizerTest.java
+29 −38 crates/voicevox_core_java_api/src/synthesizer.rs
+2 −1 crates/voicevox_core_python_api/python/voicevox_core/_rust/asyncio.pyi
+11 −0 crates/voicevox_core_python_api/python/voicevox_core/asyncio.py
+2 −0 crates/voicevox_core_python_api/python/voicevox_core/blocking.py
+59 −73 crates/voicevox_core_python_api/src/lib.rs
+14 −0 model/sample.vvm/manifest.json
+17 −0 model/sample.vvm/metas.json
+ model/sample.vvm/predict_sing_consonant_length.onnx
+ model/sample.vvm/predict_sing_f0.onnx
+ model/sample.vvm/predict_sing_volume.onnx
+ model/sample.vvm/sf_decode.onnx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VoicevoxOnnxRuntimeVersion>1.17.3</VoicevoxOnnxRuntimeVersion>
<VoicevoxCoreCommitHash>66582bd052a17c67ee77833d12ac531a4f1b158b</VoicevoxCoreCommitHash>
<VoicevoxCoreCommitHash>ef66cc2958a143ff45ceb46e8ba84f91898d66bc</VoicevoxCoreCommitHash>
</PropertyGroup>
</Project>
12 changes: 12 additions & 0 deletions tests/VoicevoxCoreSharp.Core.Tests/Helper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;

namespace VoicevoxCoreSharp.Core.Tests
{
Expand All @@ -27,5 +28,16 @@ public static string GetTestResultsDirectory()
{
return Path.Combine(GetProjectDirectory(), "results");
}

public static string GetOnnxruntimeAssemblyName()
{
return 0 switch
{
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.Windows) => "onnxruntime.dll",
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.Linux) => "libonnxruntime.so",
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.OSX) => "libonnxruntime.dylib",
_ => throw new PlatformNotSupportedException()
};
}
}
}
3 changes: 2 additions & 1 deletion tests/VoicevoxCoreSharp.Core.Tests/OnnxruntimeTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using VoicevoxCoreSharp.Core.Enum;
using VoicevoxCoreSharp.Core.Struct;
Expand All @@ -19,7 +20,7 @@ var _ when RuntimeInformation.IsOSPlatform(OSPlatform.Linux) => "libonnxruntime_
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.OSX) => "libonnxruntime_another_path.dylib",
_ => throw new PlatformNotSupportedException()
};
var option = new LoadOnnxruntimeOptions(libraryPath);
var option = new LoadOnnxruntimeOptions(Path.Join(AppContext.BaseDirectory, libraryPath));
var result = Onnxruntime.LoadOnce(option, out var onnruntime);

Assert.Equal(ResultCode.RESULT_OK, result);
Expand Down
3 changes: 2 additions & 1 deletion tests/VoicevoxCoreSharp.Core.Tests/SynthesizerTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using VoicevoxCoreSharp.Core.Enum;
using VoicevoxCoreSharp.Core.Struct;
using Xunit;
Expand All @@ -12,7 +13,7 @@ public void Tts()
{
OpenJtalk.New(Consts.OpenJTalkDictDir, out var openJtalk);
var initializeOptions = InitializeOptions.Default();
var onnxruntimeOptions = LoadOnnxruntimeOptions.Default();
var onnxruntimeOptions = new LoadOnnxruntimeOptions(Path.Join(AppContext.BaseDirectory, Helper.GetOnnxruntimeAssemblyName()));
if (Onnxruntime.LoadOnce(onnxruntimeOptions, out var onnruntime) != ResultCode.RESULT_OK)
{
Assert.Fail("Failed to initialize onnxruntime");
Expand Down
3 changes: 2 additions & 1 deletion tests/VoicevoxCoreSharp.Core.Tests/UtilsTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using VoicevoxCoreSharp.Core.Enum;
using VoicevoxCoreSharp.Core.Struct;
using Xunit;
Expand All @@ -10,7 +11,7 @@ public class UtilsTest
[Fact]
public void CreateSupportedDevicesJson()
{
var option = LoadOnnxruntimeOptions.Default();
var option = new LoadOnnxruntimeOptions(Path.Join(AppContext.BaseDirectory, Helper.GetOnnxruntimeAssemblyName()));
if (Onnxruntime.LoadOnce(option, out var onnruntime) != ResultCode.RESULT_OK)
{
Assert.Fail("Failed to initialize onnxruntime");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<Import Project="..\..\src\VoicevoxCoreSharp.Core\VoicevoxCoreSharp.Core.Metas.props" />

<ItemGroup>
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(VoicevoxOnnxRuntimeVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
Expand Down Expand Up @@ -66,18 +65,21 @@
</ItemGroup>

<ItemGroup>
<Content Include="resources\libvoicevox_core.dylib" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libvoicevox_core.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
<Content Include="resources\libvoicevox_core.so" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libvoicevox_core.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
<Content Include="resources\libvoicevox_core.dylib" TargetPath="libvoicevox_core.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
<Content Include="resources\libvoicevox_core.so" TargetPath="libvoicevox_core.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
<!-- CAUTION: Not tested on Windows, need help -->
<Content Include="resources\voicevox_core.dll" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\voicevox_core.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />

<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.dylib" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.$(VoicevoxOnnxRuntimeVersion).dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.so" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.so.$(VoicevoxOnnxRuntimeVersion)" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime.dll" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime.$(VoicevoxOnnxRuntimeVersion).dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
<Content Include="resources\libonnxruntime.dylib" TargetPath="libonnxruntime.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
<Content Include="resources\libonnxruntime.so" TargetPath="libonnxruntime.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
<!-- CAUTION: Not tested on Windows, need help -->
<Content Include="resources\onnxruntime.dll" TargetPath="onnxruntime.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />

<!-- for load testing -->
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.dylib" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime_another_path.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.so" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime_another_path.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime.dll" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime_another_path.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
<Content Include="resources\libonnxruntime.dylib" TargetPath="libonnxruntime_another_path.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
<Content Include="resources\libonnxruntime.so" TargetPath="libonnxruntime_another_path.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
<!-- CAUTION: Not tested on Windows, need help -->
<Content Include="resources\onnxruntime.dll" TargetPath="onnxruntime_another_path.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
</ItemGroup>

</Project>

0 comments on commit 413af2f

Please sign in to comment.