Expose and use model sample rate in .NET

This commit is contained in:
Reuben Morais 2019-10-10 22:04:44 +02:00
parent 5cb15ca6ed
commit 4dc18dd8ee
3 changed files with 18 additions and 0 deletions
native_client/dotnet/DeepSpeechClient

View File

@ -64,6 +64,15 @@ namespace DeepSpeechClient
EvaluateResultCode(resultCode); EvaluateResultCode(resultCode);
} }
/// <summary>
/// Return the sample rate expected by the model.
/// </summary>
/// <returns>Sample rate.</returns>
public unsafe int GetModelSampleRate()
{
return NativeImp.DS_GetModelSampleRate(_modelStatePP);
}
/// <summary> /// <summary>
/// Evaluate the result code and will raise an exception if necessary. /// Evaluate the result code and will raise an exception if necessary.
/// </summary> /// </summary>

View File

@ -24,6 +24,12 @@ namespace DeepSpeechClient.Interfaces
string aAlphabetConfigPath, string aAlphabetConfigPath,
uint aBeamWidth); uint aBeamWidth);
/// <summary>
/// Return the sample rate expected by the model.
/// </summary>
/// <returns>Sample rate.</returns>
unsafe int GetModelSampleRate();
/// <summary> /// <summary>
/// Enable decoding using beam scoring with a KenLM language model. /// Enable decoding using beam scoring with a KenLM language model.
/// </summary> /// </summary>

View File

@ -20,6 +20,9 @@ namespace DeepSpeechClient
uint aBeamWidth, uint aBeamWidth,
ref IntPtr** pint); ref IntPtr** pint);
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
internal unsafe static extern int DS_GetModelSampleRate(IntPtr** aCtx);
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)] [DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
internal static unsafe extern ErrorCodes DS_EnableDecoderWithLM(IntPtr** aCtx, internal static unsafe extern ErrorCodes DS_EnableDecoderWithLM(IntPtr** aCtx,
string aLMPath, string aLMPath,