* enable hot-word boosting * more consistent ordering of CLI arguments * progress on review * use map instead of set for hot-words, move string logic to client.cc * typo bug * pointer things? * use map for hotwords, better string splitting * add the boost, not multiply * cleaning up * cleaning whitespace * remove <set> inclusion * change typo set-->map * rename boost_coefficient to boost X-DeepSpeech: NOBUILD * add hot_words to python bindings * missing hot_words * include map in swigwrapper.i * add Map template to swigwrapper.i * emacs intermediate file * map things * map-->unordered_map * typu * typu * use dict() not None * error out if hot_words without scorer * two new functions: remove hot-word and clear all hot-words * starting to work on better error messages X-DeepSpeech: NOBUILD * better error handling + .Net ERR codes * allow for negative boosts:) * adding TC test for hot-words * add hot-words to python client, make TC test hot-words everywhere * only run TC tests for C++ and Python * fully expose API in python bindings * expose API in Java (thanks spectie!) * expose API in dotnet (thanks spectie!) * expose API in javascript (thanks spectie!) * java lol * typo in javascript * commenting * java error codes from swig * java docs from SWIG * java and dotnet issues * add hotword test to android tests * dotnet fixes from carlos * add DS_BINARY_PREFIX to tc-asserts.sh for hotwords command * make sure lm is on android for hotword test * path to android model + nit * path * path
115 lines
5.2 KiB
C#
115 lines
5.2 KiB
C#
using DeepSpeechClient.Enums;
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace DeepSpeechClient
|
|
{
|
|
/// <summary>
|
|
/// Wrapper for the native implementation of "libdeepspeech.so"
|
|
/// </summary>
|
|
internal static class NativeImp
|
|
{
|
|
#region Native Implementation
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl,
|
|
CharSet = CharSet.Ansi, SetLastError = true)]
|
|
internal static extern IntPtr DS_Version();
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal unsafe static extern ErrorCodes DS_CreateModel(string aModelPath,
|
|
ref IntPtr** pint);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal unsafe static extern IntPtr DS_ErrorCodeToErrorMessage(int aErrorCode);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal unsafe static extern uint DS_GetModelBeamWidth(IntPtr** aCtx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal unsafe static extern ErrorCodes DS_SetModelBeamWidth(IntPtr** aCtx,
|
|
uint aBeamWidth);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal unsafe static extern ErrorCodes DS_CreateModel(string aModelPath,
|
|
uint aBeamWidth,
|
|
ref IntPtr** pint);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal unsafe static extern int DS_GetModelSampleRate(IntPtr** aCtx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern ErrorCodes DS_EnableExternalScorer(IntPtr** aCtx,
|
|
string aScorerPath);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern ErrorCodes DS_AddHotWord(IntPtr** aCtx,
|
|
string aWord,
|
|
float aBoost);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern ErrorCodes DS_EraseHotWord(IntPtr** aCtx,
|
|
string aWord);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern ErrorCodes DS_ClearHotWords(IntPtr** aCtx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern ErrorCodes DS_DisableExternalScorer(IntPtr** aCtx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern ErrorCodes DS_SetScorerAlphaBeta(IntPtr** aCtx,
|
|
float aAlpha,
|
|
float aBeta);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl,
|
|
CharSet = CharSet.Ansi, SetLastError = true)]
|
|
internal static unsafe extern IntPtr DS_SpeechToText(IntPtr** aCtx,
|
|
short[] aBuffer,
|
|
uint aBufferSize);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
|
|
internal static unsafe extern IntPtr DS_SpeechToTextWithMetadata(IntPtr** aCtx,
|
|
short[] aBuffer,
|
|
uint aBufferSize,
|
|
uint aNumResults);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern void DS_FreeModel(IntPtr** aCtx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern ErrorCodes DS_CreateStream(IntPtr** aCtx,
|
|
ref IntPtr** retval);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern void DS_FreeStream(IntPtr** aSctx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern void DS_FreeMetadata(IntPtr metadata);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern void DS_FreeString(IntPtr str);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl,
|
|
CharSet = CharSet.Ansi, SetLastError = true)]
|
|
internal static unsafe extern void DS_FeedAudioContent(IntPtr** aSctx,
|
|
short[] aBuffer,
|
|
uint aBufferSize);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern IntPtr DS_IntermediateDecode(IntPtr** aSctx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern IntPtr DS_IntermediateDecodeWithMetadata(IntPtr** aSctx,
|
|
uint aNumResults);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl,
|
|
CharSet = CharSet.Ansi, SetLastError = true)]
|
|
internal static unsafe extern IntPtr DS_FinishStream(IntPtr** aSctx);
|
|
|
|
[DllImport("libdeepspeech.so", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static unsafe extern IntPtr DS_FinishStreamWithMetadata(IntPtr** aSctx,
|
|
uint aNumResults);
|
|
#endregion
|
|
}
|
|
}
|