Committed by
GitHub
Add CreateOnlineStreamWithHotwords to C API (#323)
* add default visibility to SHERPA_ONNX_EXPORT * expose CreateOnlineStreamWithHotwords method via C API Co-authored-by: Nick Fisher <nick.fisher@polyvox.app>
正在显示
2 个修改的文件
包含
15 行增加
和
1 行删除
| @@ -107,6 +107,13 @@ SherpaOnnxOnlineStream *CreateOnlineStream( | @@ -107,6 +107,13 @@ SherpaOnnxOnlineStream *CreateOnlineStream( | ||
| 107 | return stream; | 107 | return stream; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | +SherpaOnnxOnlineStream *CreateOnlineStreamWithHotwords( | ||
| 111 | + const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords) { | ||
| 112 | + SherpaOnnxOnlineStream *stream = | ||
| 113 | + new SherpaOnnxOnlineStream(recognizer->impl->CreateStream(hotwords)); | ||
| 114 | + return stream; | ||
| 115 | +} | ||
| 116 | + | ||
| 110 | void DestroyOnlineStream(SherpaOnnxOnlineStream *stream) { delete stream; } | 117 | void DestroyOnlineStream(SherpaOnnxOnlineStream *stream) { delete stream; } |
| 111 | 118 | ||
| 112 | void AcceptWaveform(SherpaOnnxOnlineStream *stream, int32_t sample_rate, | 119 | void AcceptWaveform(SherpaOnnxOnlineStream *stream, int32_t sample_rate, |
| @@ -31,7 +31,7 @@ extern "C" { | @@ -31,7 +31,7 @@ extern "C" { | ||
| 31 | #define SHERPA_ONNX_IMPORT | 31 | #define SHERPA_ONNX_IMPORT |
| 32 | #endif | 32 | #endif |
| 33 | #else // WIN32 | 33 | #else // WIN32 |
| 34 | -#define SHERPA_ONNX_EXPORT | 34 | +#define SHERPA_ONNX_EXPORT __attribute__((visibility("default"))) |
| 35 | #define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT | 35 | #define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT |
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| @@ -178,6 +178,13 @@ SHERPA_ONNX_API void DestroyOnlineRecognizer( | @@ -178,6 +178,13 @@ SHERPA_ONNX_API void DestroyOnlineRecognizer( | ||
| 178 | SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateOnlineStream( | 178 | SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateOnlineStream( |
| 179 | const SherpaOnnxOnlineRecognizer *recognizer); | 179 | const SherpaOnnxOnlineRecognizer *recognizer); |
| 180 | 180 | ||
| 181 | +/// Create an online stream for accepting wave samples with the specified hot words. | ||
| 182 | +/// | ||
| 183 | +/// @param recognizer A pointer returned by CreateOnlineRecognizer() | ||
| 184 | +/// @return Return a pointer to an OnlineStream. The user has to invoke | ||
| 185 | +/// DestroyOnlineStream() to free it to avoid memory leak. | ||
| 186 | +SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateOnlineStreamWithHotwords(const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords); | ||
| 187 | + | ||
| 181 | /// Destroy an online stream. | 188 | /// Destroy an online stream. |
| 182 | /// | 189 | /// |
| 183 | /// @param stream A pointer returned by CreateOnlineStream() | 190 | /// @param stream A pointer returned by CreateOnlineStream() |
-
请 注册 或 登录 后发表评论