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:
@@ -14,9 +14,13 @@ internal class Program
|
|||||||
provider = "cpu",
|
provider = "cpu",
|
||||||
vits = new SherpaOnnxOfflineTtsVitsModelConfig
|
vits = new SherpaOnnxOfflineTtsVitsModelConfig
|
||||||
{
|
{
|
||||||
lexicon = "vits-zh-aishell3/lexicon.txt",
|
//lexicon = "vits-zh-aishell3/lexicon.txt",
|
||||||
model = "vits-zh-aishell3/vits-aishell3.onnx",
|
//model = "vits-zh-aishell3/vits-aishell3.onnx",
|
||||||
tokens = "vits-zh-aishell3/tokens.txt",
|
//tokens = "vits-zh-aishell3/tokens.txt",
|
||||||
|
model = @"C:\Services\Sherpa\model.onnx",
|
||||||
|
lexicon = "",
|
||||||
|
tokens = @"C:\Services\Sherpa\tokens.txt",
|
||||||
|
data_dir = @"C:\Services\Sherpa\espeak-ng-data",
|
||||||
|
|
||||||
noise_scale = 0.667f,
|
noise_scale = 0.667f,
|
||||||
noise_scale_w = 0.8f,
|
noise_scale_w = 0.8f,
|
||||||
|
|||||||
@@ -6,5 +6,13 @@ namespace TTS.Struct
|
|||||||
public struct SherpaOnnxOfflineTtsConfig
|
public struct SherpaOnnxOfflineTtsConfig
|
||||||
{
|
{
|
||||||
public SherpaOnnxOfflineTtsModelConfig model;
|
public SherpaOnnxOfflineTtsModelConfig model;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string rule_fsts;
|
||||||
|
|
||||||
|
public int max_num_sentences;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string rule_fars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ namespace TTS.Struct
|
|||||||
[MarshalAs(UnmanagedType.LPStr)]
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
public string tokens;
|
public string tokens;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string data_dir;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// VITS模型的noise_scale (float,默认值= 0.667)
|
/// VITS模型的noise_scale (float,默认值= 0.667)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -34,6 +37,9 @@ namespace TTS.Struct
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float length_scale = 1f;
|
public float length_scale = 1f;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string dict_dir;
|
||||||
|
|
||||||
public SherpaOnnxOfflineTtsVitsModelConfig()
|
public SherpaOnnxOfflineTtsVitsModelConfig()
|
||||||
{
|
{
|
||||||
noise_scale = 0.667f;
|
noise_scale = 0.667f;
|
||||||
@@ -43,6 +49,8 @@ namespace TTS.Struct
|
|||||||
model = "vits-zh-aishell3/vits-aishell3.onnx";
|
model = "vits-zh-aishell3/vits-aishell3.onnx";
|
||||||
lexicon = "vits-zh-aishell3/lexicon.txt";
|
lexicon = "vits-zh-aishell3/lexicon.txt";
|
||||||
tokens = "vits-zh-aishell3/tokens.txt";
|
tokens = "vits-zh-aishell3/tokens.txt";
|
||||||
|
data_dir = "";
|
||||||
|
dict_dir = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
dotnet-examples/TTS/TTS.csproj
Normal file
15
dotnet-examples/TTS/TTS.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NAudio" Version="2.2.1" />
|
||||||
|
<PackageReference Include="org.k2fsa.sherpa.onnx" Version="1.10.23" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -7,7 +7,7 @@ namespace TTS
|
|||||||
{
|
{
|
||||||
public const string Filename = "sherpa-onnx-c-api";
|
public const string Filename = "sherpa-onnx-c-api";
|
||||||
|
|
||||||
[DllImport(Filename)]
|
[DllImport(Filename, CallingConvention = CallingConvention.Cdecl)]
|
||||||
private static extern IntPtr SherpaOnnxCreateOfflineTts(SherpaOnnxOfflineTtsConfig handle);
|
private static extern IntPtr SherpaOnnxCreateOfflineTts(SherpaOnnxOfflineTtsConfig handle);
|
||||||
|
|
||||||
[DllImport(Filename)]
|
[DllImport(Filename)]
|
||||||
@@ -23,7 +23,12 @@ namespace TTS
|
|||||||
|
|
||||||
public TTSCore(SherpaOnnxOfflineTtsConfig modelConfig)
|
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>
|
/// <summary>
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "offline-punctuation", "offl
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vad-non-streaming-asr-paraformer", "vad-non-streaming-asr-paraformer\vad-non-streaming-asr-paraformer.csproj", "{8CD6B7E5-F59F-47B3-BB87-2B2E3678924D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vad-non-streaming-asr-paraformer", "vad-non-streaming-asr-paraformer\vad-non-streaming-asr-paraformer.csproj", "{8CD6B7E5-F59F-47B3-BB87-2B2E3678924D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{401E963F-E25A-43CE-987D-8DB2D4715756}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "Common\Common.csproj", "{401E963F-E25A-43CE-987D-8DB2D4715756}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "keyword-spotting-from-files", "keyword-spotting-from-files\keyword-spotting-from-files.csproj", "{A87EDD31-D654-4C9F-AED7-F6F2825659BD}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "keyword-spotting-from-files", "keyword-spotting-from-files\keyword-spotting-from-files.csproj", "{A87EDD31-D654-4C9F-AED7-F6F2825659BD}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "keyword-spotting-from-microphone", "keyword-spotting-from-microphone\keyword-spotting-from-microphone.csproj", "{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "keyword-spotting-from-microphone", "keyword-spotting-from-microphone\keyword-spotting-from-microphone.csproj", "{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TTS", "TTS\TTS.csproj", "{DACE4A18-4FC8-4437-92BF-5A90BA81286C}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -87,6 +89,10 @@ Global
|
|||||||
{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{AEE0ED2B-C86F-4952-863C-EAD3219CB4EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DACE4A18-4FC8-4437-92BF-5A90BA81286C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DACE4A18-4FC8-4437-92BF-5A90BA81286C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DACE4A18-4FC8-4437-92BF-5A90BA81286C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DACE4A18-4FC8-4437-92BF-5A90BA81286C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user