Fixed the C api calls and created the TTS project file (#1324)

Co-authored-by: Michael Twohey <mtwohey@americanambulance.com>
This commit is contained in:
Michael Twohey
2024-09-07 08:25:02 -07:00
committed by GitHub
parent 888f74bf3c
commit b409b0a958
6 changed files with 54 additions and 8 deletions

View File

@@ -7,7 +7,7 @@ namespace TTS
{
public const string Filename = "sherpa-onnx-c-api";
[DllImport(Filename)]
[DllImport(Filename, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr SherpaOnnxCreateOfflineTts(SherpaOnnxOfflineTtsConfig handle);
[DllImport(Filename)]
@@ -23,7 +23,12 @@ namespace TTS
public TTSCore(SherpaOnnxOfflineTtsConfig modelConfig)
{
thisHandle = SherpaOnnxCreateOfflineTts(modelConfig);
IntPtr ttsHandle = SherpaOnnxCreateOfflineTts(modelConfig);
if (ttsHandle == IntPtr.Zero)
{
throw new InvalidOperationException("Failed to create SherpaOnnx TTS engine.");
}
thisHandle = ttsHandle;
}
/// <summary>