Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions binding/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ generate:
$(MAKE) replace-hash

replace-hash:
$(eval VERSION := $(shell cat ../.git/modules/binding/voicevox_core/HEAD))
$(shell sed -i.bak 's/<VoicevoxCoreCommitHash>.*<\/VoicevoxCoreCommitHash>/<VoicevoxCoreCommitHash>$(VERSION)<\/VoicevoxCoreCommitHash>/' ../src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props)
$(eval VERSION := $(shell git -C voicevox_core rev-parse HEAD))
$(shell sed -i.bak 's|<VoicevoxCoreCommitHash>.*</VoicevoxCoreCommitHash>|<VoicevoxCoreCommitHash>$(VERSION)</VoicevoxCoreCommitHash>|' ../src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props)

build/dev-library:
cd voicevox_core; cargo build --release -p voicevox_core_c_api --features load-onnxruntime -F voicevox_core/buildtime-download-onnxruntime
Expand Down
2 changes: 1 addition & 1 deletion binding/voicevox_core
Submodule voicevox_core updated 48 files
+25 −6 .github/workflows/build.yml
+17 −21 CHANGELOG.md
+4 −4 build_util/make_ios_xcframework.bash
+124 −0 build_util/make_xcframework.bash
+5 −1 crates/test_util/Cargo.toml
+10 −10 crates/test_util/build.rs
+1 −0 crates/test_util/src/lib.rs
+1 −1 crates/voicevox_core/src/core/infer/domains/experimental_talk.rs
+15 −11 crates/voicevox_core/src/core/manifest.rs
+10 −0 crates/voicevox_core/src/core/metas.rs
+2 −1 crates/voicevox_core/src/core/status.rs
+3 −8 crates/voicevox_core/src/core/voice_model.rs
+1 −0 crates/voicevox_core/src/lib.rs
+1 −1 crates/voicevox_core_c_api/Cargo.toml
+53 −1 crates/voicevox_core_c_api/include/voicevox_core.h
+5 −1 crates/voicevox_core_c_api/src/c_impls.rs
+34 −3 crates/voicevox_core_c_api/src/helpers.rs
+43 −1 crates/voicevox_core_c_api/src/lib.rs
+2 −2 crates/voicevox_core_c_api/tests/e2e/snapshots.toml
+7 −1 crates/voicevox_core_c_api/tests/e2e/testcases/ensure_compatible.rs
+7 −1 crates/voicevox_core_c_api/tests/e2e/testcases/simple_tts.rs
+7 −1 crates/voicevox_core_c_api/tests/e2e/testcases/song.rs
+7 −1 crates/voicevox_core_c_api/tests/e2e/testcases/synthesizer_new_output_json.rs
+7 −1 crates/voicevox_core_c_api/tests/e2e/testcases/tts.rs
+7 −1 crates/voicevox_core_c_api/tests/e2e/testcases/user_dict_load.rs
+0 −0 crates/voicevox_core_c_api/xcframework/Frameworks/ios/voicevox_core.framework/Info.plist
+0 −0 crates/voicevox_core_c_api/xcframework/Frameworks/ios/voicevox_core.framework/Modules/module.modulemap
+46 −0 crates/voicevox_core_c_api/xcframework/Frameworks/macos/voicevox_core.framework/Info.plist
+6 −0 crates/voicevox_core_c_api/xcframework/Frameworks/macos/voicevox_core.framework/Modules/module.modulemap
+2 −2 crates/voicevox_core_c_api/xcframework/README.md
+36 −0 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/OnExistingVoiceModelId.java
+6 −1 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/StyleType.java
+41 −4 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/blocking/Synthesizer.java
+5 −5 crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/blocking/SynthesizerTest.java
+1 −1 crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/blocking/UserDictTest.java
+21 −1 crates/voicevox_core_java_api/src/synthesizer.rs
+2 −0 crates/voicevox_core_python_api/python/voicevox_core/__init__.py
+27 −1 crates/voicevox_core_python_api/python/voicevox_core/_python/__init__.py
+9 −1 crates/voicevox_core_python_api/python/voicevox_core/_rust/asyncio.pyi
+9 −1 crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi
+16 −2 crates/voicevox_core_python_api/src/convert.rs
+19 −6 crates/voicevox_core_python_api/src/lib.rs
+2 −1 example/cpp/unix/song.cpp
+2 −1 example/cpp/unix/talk.cpp
+3 −1 example/cpp/windows/simple_tts/simple_tts.cpp
+1 −1 example/kotlin/app/src/main/kotlin/app/App.kt
+1 −1 model/sample.vvm/manifest.json
+1 −0 model/sample.vvm/metas.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -50,7 +50,7 @@ void Start()
return;
}

result = synthesizer.LoadVoiceModel(voiceModel);
result = synthesizer.LoadVoiceModel(voiceModel, LoadVoiceModelOptions.Default());
if (result != ResultCode.RESULT_OK)
{
Debug.LogError(result.ToMessage());
Expand Down
5 changes: 2 additions & 3 deletions examples/cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.CommandLine;
using System.CommandLine.Parsing;
using Microsoft.Extensions.FileSystemGlobbing;

using VoicevoxCoreSharp.Core;
using VoicevoxCoreSharp.Core.Struct;
using VoicevoxCoreSharp.Core.Enum;
using VoicevoxCoreSharp.Core.Struct;

const string OutputWavName = "audio.wav";
const uint StyleId = 0;
Expand Down Expand Up @@ -50,7 +49,7 @@ static int RunTts(string text, string? resourcePath = "voicevox_core")
return 1;
}

result = synthesizer.LoadVoiceModel(voiceModel);
result = synthesizer.LoadVoiceModel(voiceModel, LoadVoiceModelOptions.Default());
if (result != ResultCode.RESULT_OK)
{
Console.Error.WriteLine(result.ToMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using VoicevoxCoreSharp.Core.Native;

namespace VoicevoxCoreSharp.Core.Enum
{
/// <summary>
/// ::voicevox_synthesizer_load_voice_model の実行時に、同じIDの ::VoicevoxVoiceModelFile が既に読み込まれていたときのふるまい。
/// </summary>
public enum OnExistingVoiceModelId : int
{
/// <summary>
/// エラーにする。デフォルトのふるまい
/// </summary>
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR = 0,
/// <summary>
/// 再読み込みする。VOICEVOX COREでは、長文のテキストを一度に音声合成するとCPU/GPUメモリが大量に占有されたままになる。再読み込みを行うとメモリの使用量が元に戻る
/// </summary>
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD = 1,
/// <summary>
/// 何もしない
/// </summary>
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP = 2,
}

internal static class OnExistingVoiceModelIdExt
{
public static OnExistingVoiceModelId FromNative(this VoicevoxOnExistingVoiceModelId mode)
{
#pragma warning disable CS8524
return mode switch
{
VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR => OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR,
VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD => OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD,
VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP => OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP,
};
#pragma warning restore CS8524
}

public static VoicevoxOnExistingVoiceModelId ToNative(this OnExistingVoiceModelId mode)
{
#pragma warning disable CS8524
return mode switch
{
OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR => VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR,
OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD => VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD,
OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP => VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP,
};
#pragma warning restore CS8524
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,28 @@ internal static unsafe partial class CoreUnsafe
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern void voicevox_synthesizer_delete(VoicevoxSynthesizer* synthesizer);

/// <summary>
/// デフォルトの `voicevox_synthesizer_load_voice_model` のオプションを生成する
/// @return デフォルト値が設定された `voicevox_synthesizer_load_voice_model` のオプション
///
/// \no-orig-impl{voicevox_make_default_load_voice_model_options}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_make_default_load_voice_model_options", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxLoadVoiceModelOptions voicevox_make_default_load_voice_model_options();

/// <summary>
/// 音声モデルを読み込む。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] model 音声モデル
/// @param [in] options オプション
///
/// @returns 結果コード
///
/// \orig-impl{voicevox_synthesizer_load_voice_model}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_load_voice_model", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_load_voice_model(VoicevoxSynthesizer* synthesizer, VoicevoxVoiceModelFile* model);
internal static extern VoicevoxResultCode voicevox_synthesizer_load_voice_model(VoicevoxSynthesizer* synthesizer, VoicevoxVoiceModelFile* model, VoicevoxLoadVoiceModelOptions options);

/// <summary>
/// 音声モデルの読み込みを解除する。
Expand Down Expand Up @@ -1374,6 +1384,12 @@ internal unsafe partial struct VoicevoxSynthesizer
{
}

[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct VoicevoxLoadVoiceModelOptions
{
public VoicevoxOnExistingVoiceModelId on_existing;
}

[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct VoicevoxSynthesisOptions
{
Expand Down Expand Up @@ -1437,6 +1453,13 @@ internal enum VoicevoxResultCode : int
VOICEVOX_RESULT_INCOMPATIBLE_QUERIES_ERROR = 35,
}

internal enum VoicevoxOnExistingVoiceModelId : int
{
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR = 0,
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD = 1,
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP = 2,
}

internal enum VoicevoxAccelerationMode : int
{
VOICEVOX_ACCELERATION_MODE_AUTO = 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using VoicevoxCoreSharp.Core.Enum;
using VoicevoxCoreSharp.Core.Native;

namespace VoicevoxCoreSharp.Core.Struct
{
/// <summary>
/// ::voicevox_synthesizer_load_voice_model のオプション。
/// </summary>
public struct LoadVoiceModelOptions
{
/// <summary>
/// 同じIDの ::VoicevoxVoiceModelFile が既に読み込まれていたときのふるまい
/// </summary>
public OnExistingVoiceModelId OnExisting { get; set; }

public static LoadVoiceModelOptions Default()
{
return LoadVoiceModelOptionsDefault.Value;
}
}

internal static class LoadVoiceModelOptionsDefault
{
public static readonly LoadVoiceModelOptions Value = CoreUnsafe.voicevox_make_default_load_voice_model_options().FromNative();
}

internal static class LoadVoiceModelOptionsExt
{
internal static VoicevoxLoadVoiceModelOptions ToNative(this LoadVoiceModelOptions loadVoiceModelOptions)
{
return new VoicevoxLoadVoiceModelOptions
{
on_existing = loadVoiceModelOptions.OnExisting.ToNative()
};
}

internal static LoadVoiceModelOptions FromNative(this VoicevoxLoadVoiceModelOptions loadVoiceModelOptions)
{
return new LoadVoiceModelOptions
{
OnExisting = loadVoiceModelOptions.on_existing.FromNative()
};
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ public static ResultCode New(Onnxruntime onnxruntime, OpenJtalk openJtalk, Initi
}
}

public ResultCode LoadVoiceModel(VoiceModelFile voiceModel)
public ResultCode LoadVoiceModel(VoiceModelFile voiceModel, LoadVoiceModelOptions options)
{
unsafe
{
return CoreUnsafe.voicevox_synthesizer_load_voice_model((VoicevoxSynthesizer*)Handle, (VoicevoxVoiceModelFile*)voiceModel.Handle).FromNative();
var loadVoiceModelOptions = options.ToNative();
return CoreUnsafe.voicevox_synthesizer_load_voice_model((VoicevoxSynthesizer*)Handle, (VoicevoxVoiceModelFile*)voiceModel.Handle, loadVoiceModelOptions).FromNative();
}
}

Expand Down
51 changes: 51 additions & 0 deletions src/VoicevoxCoreSharp.Core/Enum/OnExistingVoiceModelId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using VoicevoxCoreSharp.Core.Native;

namespace VoicevoxCoreSharp.Core.Enum
{
/// <summary>
/// ::voicevox_synthesizer_load_voice_model の実行時に、同じIDの ::VoicevoxVoiceModelFile が既に読み込まれていたときのふるまい。
/// </summary>
public enum OnExistingVoiceModelId : int
{
/// <summary>
/// エラーにする。デフォルトのふるまい
/// </summary>
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR = 0,
/// <summary>
/// 再読み込みする。VOICEVOX COREでは、長文のテキストを一度に音声合成するとCPU/GPUメモリが大量に占有されたままになる。再読み込みを行うとメモリの使用量が元に戻る
/// </summary>
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD = 1,
/// <summary>
/// 何もしない
/// </summary>
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP = 2,
}

internal static class OnExistingVoiceModelIdExt
{
public static OnExistingVoiceModelId FromNative(this VoicevoxOnExistingVoiceModelId mode)
{
#pragma warning disable CS8524
return mode switch
{
VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR => OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR,
VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD => OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD,
VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP => OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP,
};
#pragma warning restore CS8524
}

public static VoicevoxOnExistingVoiceModelId ToNative(this OnExistingVoiceModelId mode)
{
#pragma warning disable CS8524
return mode switch
{
OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR => VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR,
OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD => VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD,
OnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP => VoicevoxOnExistingVoiceModelId.VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP,
};
#pragma warning restore CS8524
}
}
}
25 changes: 24 additions & 1 deletion src/VoicevoxCoreSharp.Core/Native/CoreUnsafe.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,28 @@ internal static unsafe partial class CoreUnsafe
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_delete", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern void voicevox_synthesizer_delete(VoicevoxSynthesizer* synthesizer);

/// <summary>
/// デフォルトの `voicevox_synthesizer_load_voice_model` のオプションを生成する
/// @return デフォルト値が設定された `voicevox_synthesizer_load_voice_model` のオプション
///
/// \no-orig-impl{voicevox_make_default_load_voice_model_options}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_make_default_load_voice_model_options", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxLoadVoiceModelOptions voicevox_make_default_load_voice_model_options();

/// <summary>
/// 音声モデルを読み込む。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] model 音声モデル
/// @param [in] options オプション
///
/// @returns 結果コード
///
/// \orig-impl{voicevox_synthesizer_load_voice_model}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_load_voice_model", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_load_voice_model(VoicevoxSynthesizer* synthesizer, VoicevoxVoiceModelFile* model);
internal static extern VoicevoxResultCode voicevox_synthesizer_load_voice_model(VoicevoxSynthesizer* synthesizer, VoicevoxVoiceModelFile* model, VoicevoxLoadVoiceModelOptions options);

/// <summary>
/// 音声モデルの読み込みを解除する。
Expand Down Expand Up @@ -1374,6 +1384,12 @@ internal unsafe partial struct VoicevoxSynthesizer
{
}

[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct VoicevoxLoadVoiceModelOptions
{
public VoicevoxOnExistingVoiceModelId on_existing;
}

[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct VoicevoxSynthesisOptions
{
Expand Down Expand Up @@ -1437,6 +1453,13 @@ internal enum VoicevoxResultCode : int
VOICEVOX_RESULT_INCOMPATIBLE_QUERIES_ERROR = 35,
}

internal enum VoicevoxOnExistingVoiceModelId : int
{
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_ERROR = 0,
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_RELOAD = 1,
VOICEVOX_ON_EXISTING_VOICE_MODEL_ID_SKIP = 2,
}

internal enum VoicevoxAccelerationMode : int
{
VOICEVOX_ACCELERATION_MODE_AUTO = 0,
Expand Down
Loading
Loading