Skip to content

Update submodule #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 1, 2025
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
2 changes: 1 addition & 1 deletion binding/voicevox_core
Submodule voicevox_core updated 40 files
+33 −0 CONTRIBUTING.md
+1 −0 Cargo.lock
+0 −155 README.md
+3 −2 crates/voicevox_core/src/__internal/interop.rs
+20 −2 crates/voicevox_core/src/infer.rs
+6 −1 crates/voicevox_core/src/infer/runtimes/onnxruntime.rs
+2 −1 crates/voicevox_core/src/infer/session_set.rs
+72 −0 crates/voicevox_core/src/lib.rs
+2 −2 crates/voicevox_core/src/metas.rs
+2 −1 crates/voicevox_core/src/status.rs
+226 −45 crates/voicevox_core/src/synthesizer.rs
+4 −0 crates/voicevox_core/src/text_analyzer.rs
+34 −0 crates/voicevox_core_c_api/README.md
+61 −0 crates/voicevox_core_c_api/include/voicevox_core.h
+100 −1 crates/voicevox_core_c_api/src/lib.rs
+1 −1 crates/voicevox_core_c_api/tests/e2e/snapshots.toml
+1 −1 crates/voicevox_core_c_api/tests/e2e/testcases.rs
+347 −0 crates/voicevox_core_c_api/tests/e2e/testcases/tts.rs
+0 −164 crates/voicevox_core_c_api/tests/e2e/testcases/tts_via_audio_query.rs
+19 −0 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/AudioQuery.java
+17 −0 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/blocking/OpenJtalk.java
+27 −4 crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/blocking/Synthesizer.java
+57 −1 crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/blocking/SynthesizerTest.java
+26 −0 crates/voicevox_core_java_api/src/audio_query.rs
+1 −0 crates/voicevox_core_java_api/src/lib.rs
+22 −1 crates/voicevox_core_java_api/src/open_jtalk.rs
+1 −0 crates/voicevox_core_python_api/Cargo.toml
+39 −0 crates/voicevox_core_python_api/python/test/test_asyncio_object_identities.py
+93 −0 crates/voicevox_core_python_api/python/test/test_asyncio_tts.py
+37 −0 crates/voicevox_core_python_api/python/test/test_blocking_object_identities.py
+69 −0 crates/voicevox_core_python_api/python/test/test_blocking_tts.py
+9 −1 crates/voicevox_core_python_api/python/voicevox_core/_models/__init__.py
+4 −1 crates/voicevox_core_python_api/python/voicevox_core/_rust/__init__.pyi
+58 −0 crates/voicevox_core_python_api/python/voicevox_core/_rust/asyncio.pyi
+37 −0 crates/voicevox_core_python_api/python/voicevox_core/_rust/blocking.pyi
+94 −24 crates/voicevox_core_python_api/src/lib.rs
+14 −0 docs/guide/user/downloader.md
+33 −0 docs/guide/user/gpu.md
+47 −0 docs/guide/user/tts-process.md
+23 −1 docs/guide/user/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ internal static unsafe partial class CoreUnsafe
[DllImport(__DllName, EntryPoint = "voicevox_open_jtalk_rc_use_user_dict", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_open_jtalk_rc_use_user_dict(OpenJtalkRc* open_jtalk, VoicevoxUserDict* user_dict);

/// <summary>
/// 日本語のテキストを解析する。
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// @param [in] open_jtalk Open JTalkのオブジェクト
/// @param [in] text UTF-8の日本語テキスト
/// @param [out] output_accent_phrases_json 生成先
///
/// \orig-impl{voicevox_open_jtalk_rc_use_user_dict}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_open_jtalk_rc_analyze", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_open_jtalk_rc_analyze(OpenJtalkRc* open_jtalk, byte* text, byte** output_accent_phrases_json);

/// <summary>
/// ::OpenJtalkRc を&lt;b&gt;破棄&lt;/b&gt;(_destruct_)する。
///
Expand Down Expand Up @@ -197,6 +211,24 @@ internal static unsafe partial class CoreUnsafe
[DllImport(__DllName, EntryPoint = "voicevox_get_version", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern byte* voicevox_get_version();

/// <summary>
/// AccentPhraseの配列からAudioQueryを作る。
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// @param [in] accent_phrases_json AccentPhraseの配列のJSON文字列
/// @param [out] output_accent_phrases_json 生成先
///
/// \safety{
/// - `accent_phrases_json`はヌル終端文字列を指し、かつ&lt;a href="#voicevox-core-safety"&gt;読み込みについて有効&lt;/a&gt;でなければならない。
/// - `output_audio_query_json`は&lt;a href="#voicevox-core-safety"&gt;書き込みについて有効&lt;/a&gt;でなければならない。
/// }
///
/// \orig-impl{voicevox_audio_query_create_from_accent_phrases}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_audio_query_create_from_accent_phrases", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_audio_query_create_from_accent_phrases(byte* accent_phrases_json, byte** output_audio_query_json);

/// <summary>
/// VVMファイルを開く。
///
Expand Down Expand Up @@ -444,6 +476,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// ::voicevox_synthesizer_create_accent_phrases と ::voicevox_audio_query_create_from_accent_phrases
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] text UTF-8の日本語テキスト
/// @param [in] style_id スタイルID
Expand All @@ -466,6 +501,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_create_audio_query}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_create_audio_query", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_create_audio_query(VoicevoxSynthesizer* synthesizer, byte* text, uint style_id, byte** output_audio_query_json);
Expand Down Expand Up @@ -507,6 +544,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// ::voicevox_open_jtalk_rc_analyze と ::voicevox_synthesizer_replace_mora_data
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] text UTF-8の日本語テキスト
/// @param [in] style_id スタイルID
Expand All @@ -529,6 +569,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_create_accent_phrases}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_create_accent_phrases", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_create_accent_phrases(VoicevoxSynthesizer* synthesizer, byte* text, uint style_id, byte** output_accent_phrases_json);
Expand All @@ -538,6 +580,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// ::voicevox_synthesizer_replace_phoneme_length と ::voicevox_synthesizer_replace_mora_pitch
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] accent_phrases_json AccentPhraseの配列のJSON文字列
/// @param [in] style_id スタイルID
Expand All @@ -551,6 +596,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_replace_mora_data}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_replace_mora_data", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_replace_mora_data(VoicevoxSynthesizer* synthesizer, byte* accent_phrases_json, uint style_id, byte** output_accent_phrases_json);
Expand Down Expand Up @@ -672,6 +719,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したWAVデータを解放するには ::voicevox_wav_free を使う。
///
/// ::voicevox_synthesizer_create_audio_query と ::voicevox_synthesizer_synthesis
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer
/// @param [in] text UTF-8の日本語テキスト
/// @param [in] style_id スタイルID
Expand All @@ -688,6 +738,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_tts}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_tts", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_tts(VoicevoxSynthesizer* synthesizer, byte* text, uint style_id, VoicevoxTtsOptions options, nuint* output_wav_length, byte** output_wav);
Expand All @@ -699,8 +751,10 @@ internal static unsafe partial class CoreUnsafe
///
/// \safety{
/// - `json`は以下のAPIで得られたポインタでなくてはいけない。
/// - ::voicevox_audio_query_create_from_accent_phrases
/// - ::voicevox_onnxruntime_create_supported_devices_json
/// - ::voicevox_voice_model_file_create_metas_json
/// - ::voicevox_open_jtalk_rc_analyze
/// - ::voicevox_synthesizer_create_metas_json
/// - ::voicevox_synthesizer_create_audio_query
/// - ::voicevox_synthesizer_create_accent_phrases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ public static ResultCode New(string openJtalkDicDir, out OpenJtalk openJtalk)
}
}

public ResultCode Analyze(string text, out string? outputAccentPhrasesJson)
{
unsafe
{
byte* output;
fixed (byte* ptr = System.Text.Encoding.UTF8.GetBytes(text))
{
var result = CoreUnsafe.voicevox_open_jtalk_rc_analyze((OpenJtalkRc*)Handle, ptr, &output);
if (result == VoicevoxResultCode.VOICEVOX_RESULT_OK)
{
outputAccentPhrasesJson = StringConvertCompat.ToUTF8String(output);
CoreUnsafe.voicevox_json_free(output);
}
else
{
outputAccentPhrasesJson = null;
}
return result.FromNative();
}
}
}

public ResultCode UseUserDict(UserDict userDict)
{
unsafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,27 @@ public static string GetVersion()
return StringConvertCompat.ToUTF8String(CoreUnsafe.voicevox_get_version());
}
}

public static ResultCode CreateAudioQueryFromAccentPhrases(string accentPhrasesJson, out string? outputAudioQueryJson)
{
unsafe
{
byte* outputAudioQueryJsonPtr;
fixed (byte* ptr = System.Text.Encoding.UTF8.GetBytes(accentPhrasesJson))
{
var result = CoreUnsafe.voicevox_audio_query_create_from_accent_phrases(ptr, &outputAudioQueryJsonPtr);
if (result == VoicevoxResultCode.VOICEVOX_RESULT_OK)
{
outputAudioQueryJson = StringConvertCompat.ToUTF8String(outputAudioQueryJsonPtr);
CoreUnsafe.voicevox_json_free(outputAudioQueryJsonPtr);
}
else
{
outputAudioQueryJson = null;
}
return result.FromNative();
}
}
}
}
}
54 changes: 54 additions & 0 deletions src/VoicevoxCoreSharp.Core/Native/CoreUnsafe.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ internal static unsafe partial class CoreUnsafe
[DllImport(__DllName, EntryPoint = "voicevox_open_jtalk_rc_use_user_dict", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_open_jtalk_rc_use_user_dict(OpenJtalkRc* open_jtalk, VoicevoxUserDict* user_dict);

/// <summary>
/// 日本語のテキストを解析する。
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// @param [in] open_jtalk Open JTalkのオブジェクト
/// @param [in] text UTF-8の日本語テキスト
/// @param [out] output_accent_phrases_json 生成先
///
/// \orig-impl{voicevox_open_jtalk_rc_use_user_dict}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_open_jtalk_rc_analyze", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_open_jtalk_rc_analyze(OpenJtalkRc* open_jtalk, byte* text, byte** output_accent_phrases_json);

/// <summary>
/// ::OpenJtalkRc を&lt;b&gt;破棄&lt;/b&gt;(_destruct_)する。
///
Expand Down Expand Up @@ -197,6 +211,24 @@ internal static unsafe partial class CoreUnsafe
[DllImport(__DllName, EntryPoint = "voicevox_get_version", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern byte* voicevox_get_version();

/// <summary>
/// AccentPhraseの配列からAudioQueryを作る。
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// @param [in] accent_phrases_json AccentPhraseの配列のJSON文字列
/// @param [out] output_accent_phrases_json 生成先
///
/// \safety{
/// - `accent_phrases_json`はヌル終端文字列を指し、かつ&lt;a href="#voicevox-core-safety"&gt;読み込みについて有効&lt;/a&gt;でなければならない。
/// - `output_audio_query_json`は&lt;a href="#voicevox-core-safety"&gt;書き込みについて有効&lt;/a&gt;でなければならない。
/// }
///
/// \orig-impl{voicevox_audio_query_create_from_accent_phrases}
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_audio_query_create_from_accent_phrases", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_audio_query_create_from_accent_phrases(byte* accent_phrases_json, byte** output_audio_query_json);

/// <summary>
/// VVMファイルを開く。
///
Expand Down Expand Up @@ -444,6 +476,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// ::voicevox_synthesizer_create_accent_phrases と ::voicevox_audio_query_create_from_accent_phrases
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] text UTF-8の日本語テキスト
/// @param [in] style_id スタイルID
Expand All @@ -466,6 +501,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_create_audio_query}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_create_audio_query", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_create_audio_query(VoicevoxSynthesizer* synthesizer, byte* text, uint style_id, byte** output_audio_query_json);
Expand Down Expand Up @@ -507,6 +544,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// ::voicevox_open_jtalk_rc_analyze と ::voicevox_synthesizer_replace_mora_data
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] text UTF-8の日本語テキスト
/// @param [in] style_id スタイルID
Expand All @@ -529,6 +569,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_create_accent_phrases}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_create_accent_phrases", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_create_accent_phrases(VoicevoxSynthesizer* synthesizer, byte* text, uint style_id, byte** output_accent_phrases_json);
Expand All @@ -538,6 +580,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したJSON文字列を解放するには ::voicevox_json_free を使う。
///
/// ::voicevox_synthesizer_replace_phoneme_length と ::voicevox_synthesizer_replace_mora_pitch
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer 音声シンセサイザ
/// @param [in] accent_phrases_json AccentPhraseの配列のJSON文字列
/// @param [in] style_id スタイルID
Expand All @@ -551,6 +596,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_replace_mora_data}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_replace_mora_data", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_replace_mora_data(VoicevoxSynthesizer* synthesizer, byte* accent_phrases_json, uint style_id, byte** output_accent_phrases_json);
Expand Down Expand Up @@ -672,6 +719,9 @@ internal static unsafe partial class CoreUnsafe
///
/// 生成したWAVデータを解放するには ::voicevox_wav_free を使う。
///
/// ::voicevox_synthesizer_create_audio_query と ::voicevox_synthesizer_synthesis
/// が一体になったショートハンド。詳細は[テキスト音声合成の流れ]を参照。
///
/// @param [in] synthesizer
/// @param [in] text UTF-8の日本語テキスト
/// @param [in] style_id スタイルID
Expand All @@ -688,6 +738,8 @@ internal static unsafe partial class CoreUnsafe
/// }
///
/// \orig-impl{voicevox_synthesizer_tts}
///
/// [テキスト音声合成の流れ]: https://github.com/VOICEVOX/voicevox_core/blob/main/docs/guide/user/tts-process.md
/// </summary>
[DllImport(__DllName, EntryPoint = "voicevox_synthesizer_tts", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern VoicevoxResultCode voicevox_synthesizer_tts(VoicevoxSynthesizer* synthesizer, byte* text, uint style_id, VoicevoxTtsOptions options, nuint* output_wav_length, byte** output_wav);
Expand All @@ -699,8 +751,10 @@ internal static unsafe partial class CoreUnsafe
///
/// \safety{
/// - `json`は以下のAPIで得られたポインタでなくてはいけない。
/// - ::voicevox_audio_query_create_from_accent_phrases
/// - ::voicevox_onnxruntime_create_supported_devices_json
/// - ::voicevox_voice_model_file_create_metas_json
/// - ::voicevox_open_jtalk_rc_analyze
/// - ::voicevox_synthesizer_create_metas_json
/// - ::voicevox_synthesizer_create_audio_query
/// - ::voicevox_synthesizer_create_accent_phrases
Expand Down
Loading
Loading