Fangjun Kuang
Committed by GitHub

Refactor C API to prefix each API with SherpaOnnx. (#1171)

正在显示 47 个修改的文件 包含 667 行增加618 行删除
  1 +## 1.10.19
  2 +
  3 +* Prefix all C API functions with SherpaOnnx
  4 +
1 ## 1.10.18 5 ## 1.10.18
2 6
3 * Fix the case when recognition results contain the symbol `"`. It caused 7 * Fix the case when recognition results contain the symbol `"`. It caused
@@ -11,7 +11,7 @@ project(sherpa-onnx) @@ -11,7 +11,7 @@ project(sherpa-onnx)
11 # ./nodejs-addon-examples 11 # ./nodejs-addon-examples
12 # ./dart-api-examples/ 12 # ./dart-api-examples/
13 # ./CHANGELOG.md 13 # ./CHANGELOG.md
14 -set(SHERPA_ONNX_VERSION "1.10.18") 14 +set(SHERPA_ONNX_VERSION "1.10.19")
15 15
16 # Disable warning about 16 # Disable warning about
17 # 17 #
@@ -189,10 +189,11 @@ int32_t main(int32_t argc, char *argv[]) { @@ -189,10 +189,11 @@ int32_t main(int32_t argc, char *argv[]) {
189 } 189 }
190 190
191 const SherpaOnnxOnlineRecognizer *recognizer = 191 const SherpaOnnxOnlineRecognizer *recognizer =
192 - CreateOnlineRecognizer(&config);  
193 - const SherpaOnnxOnlineStream *stream = CreateOnlineStream(recognizer); 192 + SherpaOnnxCreateOnlineRecognizer(&config);
  193 + const SherpaOnnxOnlineStream *stream =
  194 + SherpaOnnxCreateOnlineStream(recognizer);
194 195
195 - const SherpaOnnxDisplay *display = CreateDisplay(50); 196 + const SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50);
196 int32_t segment_id = 0; 197 int32_t segment_id = 0;
197 198
198 const char *device_name = argv[context.index]; 199 const char *device_name = argv[context.index];
@@ -218,17 +219,17 @@ int32_t main(int32_t argc, char *argv[]) { @@ -218,17 +219,17 @@ int32_t main(int32_t argc, char *argv[]) {
218 219
219 while (!stop) { 220 while (!stop) {
220 const std::vector<float> &samples = alsa.Read(chunk); 221 const std::vector<float> &samples = alsa.Read(chunk);
221 - AcceptWaveform(stream, expected_sample_rate, samples.data(),  
222 - samples.size());  
223 - while (IsOnlineStreamReady(recognizer, stream)) {  
224 - DecodeOnlineStream(recognizer, stream); 222 + SherpaOnnxOnlineStreamAcceptWaveform(stream, expected_sample_rate,
  223 + samples.data(), samples.size());
  224 + while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  225 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
225 } 226 }
226 227
227 const SherpaOnnxOnlineRecognizerResult *r = 228 const SherpaOnnxOnlineRecognizerResult *r =
228 - GetOnlineStreamResult(recognizer, stream); 229 + SherpaOnnxGetOnlineStreamResult(recognizer, stream);
229 230
230 std::string text = r->text; 231 std::string text = r->text;
231 - DestroyOnlineRecognizerResult(r); 232 + SherpaOnnxDestroyOnlineRecognizerResult(r);
232 233
233 if (!text.empty() && last_text != text) { 234 if (!text.empty() && last_text != text) {
234 last_text = text; 235 last_text = text;
@@ -240,18 +241,18 @@ int32_t main(int32_t argc, char *argv[]) { @@ -240,18 +241,18 @@ int32_t main(int32_t argc, char *argv[]) {
240 fflush(stderr); 241 fflush(stderr);
241 } 242 }
242 243
243 - if (IsEndpoint(recognizer, stream)) { 244 + if (SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream)) {
244 if (!text.empty()) { 245 if (!text.empty()) {
245 ++segment_index; 246 ++segment_index;
246 } 247 }
247 - Reset(recognizer, stream); 248 + SherpaOnnxOnlineStreamReset(recognizer, stream);
248 } 249 }
249 } 250 }
250 251
251 // free allocated resources 252 // free allocated resources
252 - DestroyDisplay(display);  
253 - DestroyOnlineStream(stream);  
254 - DestroyOnlineRecognizer(recognizer); 253 + SherpaOnnxDestroyDisplay(display);
  254 + SherpaOnnxDestroyOnlineStream(stream);
  255 + SherpaOnnxDestroyOnlineRecognizer(recognizer);
255 fprintf(stderr, "\n"); 256 fprintf(stderr, "\n");
256 257
257 return 0; 258 return 0;
@@ -54,8 +54,8 @@ int32_t main() { @@ -54,8 +54,8 @@ int32_t main() {
54 const SherpaOnnxOfflineStream *stream = 54 const SherpaOnnxOfflineStream *stream =
55 SherpaOnnxAudioTaggingCreateOfflineStream(tagger); 55 SherpaOnnxAudioTaggingCreateOfflineStream(tagger);
56 56
57 - AcceptWaveformOffline(stream, wave->sample_rate, wave->samples,  
58 - wave->num_samples); 57 + SherpaOnnxAcceptWaveformOffline(stream, wave->sample_rate, wave->samples,
  58 + wave->num_samples);
59 59
60 int32_t top_k = 5; 60 int32_t top_k = 5;
61 const SherpaOnnxAudioEvent *const *results = 61 const SherpaOnnxAudioEvent *const *results =
@@ -71,7 +71,7 @@ int32_t main() { @@ -71,7 +71,7 @@ int32_t main() {
71 fprintf(stderr, "--------------------------------------------------\n"); 71 fprintf(stderr, "--------------------------------------------------\n");
72 72
73 SherpaOnnxAudioTaggingFreeResults(results); 73 SherpaOnnxAudioTaggingFreeResults(results);
74 - DestroyOfflineStream(stream); 74 + SherpaOnnxDestroyOfflineStream(stream);
75 SherpaOnnxFreeWave(wave); 75 SherpaOnnxFreeWave(wave);
76 SherpaOnnxDestroyAudioTagging(tagger); 76 SherpaOnnxDestroyAudioTagging(tagger);
77 77
@@ -163,10 +163,11 @@ int32_t main(int32_t argc, char *argv[]) { @@ -163,10 +163,11 @@ int32_t main(int32_t argc, char *argv[]) {
163 } 163 }
164 164
165 const SherpaOnnxOnlineRecognizer *recognizer = 165 const SherpaOnnxOnlineRecognizer *recognizer =
166 - CreateOnlineRecognizer(&config);  
167 - const SherpaOnnxOnlineStream *stream = CreateOnlineStream(recognizer); 166 + SherpaOnnxCreateOnlineRecognizer(&config);
  167 + const SherpaOnnxOnlineStream *stream =
  168 + SherpaOnnxCreateOnlineStream(recognizer);
168 169
169 - const SherpaOnnxDisplay *display = CreateDisplay(50); 170 + const SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50);
170 int32_t segment_id = 0; 171 int32_t segment_id = 0;
171 172
172 const char *wav_filename = argv[context.index]; 173 const char *wav_filename = argv[context.index];
@@ -190,52 +191,53 @@ int32_t main(int32_t argc, char *argv[]) { @@ -190,52 +191,53 @@ int32_t main(int32_t argc, char *argv[]) {
190 (start + N > wave->num_samples) ? wave->num_samples : (start + N); 191 (start + N > wave->num_samples) ? wave->num_samples : (start + N);
191 k += N; 192 k += N;
192 193
193 - AcceptWaveform(stream, wave->sample_rate, wave->samples + start,  
194 - end - start);  
195 - while (IsOnlineStreamReady(recognizer, stream)) {  
196 - DecodeOnlineStream(recognizer, stream); 194 + SherpaOnnxOnlineStreamAcceptWaveform(stream, wave->sample_rate,
  195 + wave->samples + start, end - start);
  196 + while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  197 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
197 } 198 }
198 199
199 const SherpaOnnxOnlineRecognizerResult *r = 200 const SherpaOnnxOnlineRecognizerResult *r =
200 - GetOnlineStreamResult(recognizer, stream); 201 + SherpaOnnxGetOnlineStreamResult(recognizer, stream);
201 202
202 if (strlen(r->text)) { 203 if (strlen(r->text)) {
203 SherpaOnnxPrint(display, segment_id, r->text); 204 SherpaOnnxPrint(display, segment_id, r->text);
204 } 205 }
205 206
206 - if (IsEndpoint(recognizer, stream)) { 207 + if (SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream)) {
207 if (strlen(r->text)) { 208 if (strlen(r->text)) {
208 ++segment_id; 209 ++segment_id;
209 } 210 }
210 - Reset(recognizer, stream); 211 + SherpaOnnxOnlineStreamReset(recognizer, stream);
211 } 212 }
212 213
213 - DestroyOnlineRecognizerResult(r); 214 + SherpaOnnxDestroyOnlineRecognizerResult(r);
214 } 215 }
215 216
216 // add some tail padding 217 // add some tail padding
217 float tail_paddings[4800] = {0}; // 0.3 seconds at 16 kHz sample rate 218 float tail_paddings[4800] = {0}; // 0.3 seconds at 16 kHz sample rate
218 - AcceptWaveform(stream, wave->sample_rate, tail_paddings, 4800); 219 + SherpaOnnxOnlineStreamAcceptWaveform(stream, wave->sample_rate, tail_paddings,
  220 + 4800);
219 221
220 SherpaOnnxFreeWave(wave); 222 SherpaOnnxFreeWave(wave);
221 223
222 - InputFinished(stream);  
223 - while (IsOnlineStreamReady(recognizer, stream)) {  
224 - DecodeOnlineStream(recognizer, stream); 224 + SherpaOnnxOnlineStreamInputFinished(stream);
  225 + while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  226 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
225 } 227 }
226 228
227 const SherpaOnnxOnlineRecognizerResult *r = 229 const SherpaOnnxOnlineRecognizerResult *r =
228 - GetOnlineStreamResult(recognizer, stream); 230 + SherpaOnnxGetOnlineStreamResult(recognizer, stream);
229 231
230 if (strlen(r->text)) { 232 if (strlen(r->text)) {
231 SherpaOnnxPrint(display, segment_id, r->text); 233 SherpaOnnxPrint(display, segment_id, r->text);
232 } 234 }
233 235
234 - DestroyOnlineRecognizerResult(r); 236 + SherpaOnnxDestroyOnlineRecognizerResult(r);
235 237
236 - DestroyDisplay(display);  
237 - DestroyOnlineStream(stream);  
238 - DestroyOnlineRecognizer(recognizer); 238 + SherpaOnnxDestroyDisplay(display);
  239 + SherpaOnnxDestroyOnlineStream(stream);
  240 + SherpaOnnxDestroyOnlineRecognizer(recognizer);
239 fprintf(stderr, "\n"); 241 fprintf(stderr, "\n");
240 242
241 return 0; 243 return 0;
@@ -59,7 +59,7 @@ int32_t main() { @@ -59,7 +59,7 @@ int32_t main() {
59 recognizer_config.model_config = offline_model_config; 59 recognizer_config.model_config = offline_model_config;
60 60
61 SherpaOnnxOfflineRecognizer *recognizer = 61 SherpaOnnxOfflineRecognizer *recognizer =
62 - CreateOfflineRecognizer(&recognizer_config); 62 + SherpaOnnxCreateOfflineRecognizer(&recognizer_config);
63 63
64 if (recognizer == NULL) { 64 if (recognizer == NULL) {
65 fprintf(stderr, "Please check your config!\n"); 65 fprintf(stderr, "Please check your config!\n");
@@ -67,19 +67,19 @@ int32_t main() { @@ -67,19 +67,19 @@ int32_t main() {
67 return -1; 67 return -1;
68 } 68 }
69 69
70 - SherpaOnnxOfflineStream *stream = CreateOfflineStream(recognizer); 70 + SherpaOnnxOfflineStream *stream = SherpaOnnxCreateOfflineStream(recognizer);
71 71
72 - AcceptWaveformOffline(stream, wave->sample_rate, wave->samples,  
73 - wave->num_samples);  
74 - DecodeOfflineStream(recognizer, stream); 72 + SherpaOnnxAcceptWaveformOffline(stream, wave->sample_rate, wave->samples,
  73 + wave->num_samples);
  74 + SherpaOnnxDecodeOfflineStream(recognizer, stream);
75 const SherpaOnnxOfflineRecognizerResult *result = 75 const SherpaOnnxOfflineRecognizerResult *result =
76 - GetOfflineStreamResult(stream); 76 + SherpaOnnxGetOfflineStreamResult(stream);
77 77
78 fprintf(stderr, "Decoded text: %s\n", result->text); 78 fprintf(stderr, "Decoded text: %s\n", result->text);
79 79
80 - DestroyOfflineRecognizerResult(result);  
81 - DestroyOfflineStream(stream);  
82 - DestroyOfflineRecognizer(recognizer); 80 + SherpaOnnxDestroyOfflineRecognizerResult(result);
  81 + SherpaOnnxDestroyOfflineStream(stream);
  82 + SherpaOnnxDestroyOfflineRecognizer(recognizer);
83 SherpaOnnxFreeWave(wave); 83 SherpaOnnxFreeWave(wave);
84 84
85 return 0; 85 return 0;
@@ -37,8 +37,9 @@ static const float *ComputeEmbedding( @@ -37,8 +37,9 @@ static const float *ComputeEmbedding(
37 const SherpaOnnxOnlineStream *stream = 37 const SherpaOnnxOnlineStream *stream =
38 SherpaOnnxSpeakerEmbeddingExtractorCreateStream(ex); 38 SherpaOnnxSpeakerEmbeddingExtractorCreateStream(ex);
39 39
40 - AcceptWaveform(stream, wave->sample_rate, wave->samples, wave->num_samples);  
41 - InputFinished(stream); 40 + SherpaOnnxOnlineStreamAcceptWaveform(stream, wave->sample_rate, wave->samples,
  41 + wave->num_samples);
  42 + SherpaOnnxOnlineStreamInputFinished(stream);
42 43
43 if (!SherpaOnnxSpeakerEmbeddingExtractorIsReady(ex, stream)) { 44 if (!SherpaOnnxSpeakerEmbeddingExtractorIsReady(ex, stream)) {
44 fprintf(stderr, "The input wave file %s is too short!\n", wav_filename); 45 fprintf(stderr, "The input wave file %s is too short!\n", wav_filename);
@@ -49,7 +50,7 @@ static const float *ComputeEmbedding( @@ -49,7 +50,7 @@ static const float *ComputeEmbedding(
49 const float *v = 50 const float *v =
50 SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding(ex, stream); 51 SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding(ex, stream);
51 52
52 - DestroyOnlineStream(stream); 53 + SherpaOnnxDestroyOnlineStream(stream);
53 SherpaOnnxFreeWave(wave); 54 SherpaOnnxFreeWave(wave);
54 55
55 // Remeber to free v to avoid memory leak 56 // Remeber to free v to avoid memory leak
@@ -50,8 +50,8 @@ int32_t main() { @@ -50,8 +50,8 @@ int32_t main() {
50 SherpaOnnxOfflineStream *stream = 50 SherpaOnnxOfflineStream *stream =
51 SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream(slid); 51 SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream(slid);
52 52
53 - AcceptWaveformOffline(stream, wave->sample_rate, wave->samples,  
54 - wave->num_samples); 53 + SherpaOnnxAcceptWaveformOffline(stream, wave->sample_rate, wave->samples,
  54 + wave->num_samples);
55 55
56 const SherpaOnnxSpokenLanguageIdentificationResult *result = 56 const SherpaOnnxSpokenLanguageIdentificationResult *result =
57 SherpaOnnxSpokenLanguageIdentificationCompute(slid, stream); 57 SherpaOnnxSpokenLanguageIdentificationCompute(slid, stream);
@@ -60,7 +60,7 @@ int32_t main() { @@ -60,7 +60,7 @@ int32_t main() {
60 fprintf(stderr, "Detected language: %s\n", result->lang); 60 fprintf(stderr, "Detected language: %s\n", result->lang);
61 61
62 SherpaOnnxDestroySpokenLanguageIdentificationResult(result); 62 SherpaOnnxDestroySpokenLanguageIdentificationResult(result);
63 - DestroyOfflineStream(stream); 63 + SherpaOnnxDestroyOfflineStream(stream);
64 SherpaOnnxFreeWave(wave); 64 SherpaOnnxFreeWave(wave);
65 SherpaOnnxDestroySpokenLanguageIdentification(slid); 65 SherpaOnnxDestroySpokenLanguageIdentification(slid);
66 66
@@ -45,15 +45,16 @@ int32_t main() { @@ -45,15 +45,16 @@ int32_t main() {
45 config.model_config.debug = 0; 45 config.model_config.debug = 0;
46 config.ctc_fst_decoder_config.graph = graph; 46 config.ctc_fst_decoder_config.graph = graph;
47 const SherpaOnnxOnlineRecognizer *recognizer = 47 const SherpaOnnxOnlineRecognizer *recognizer =
48 - CreateOnlineRecognizer(&config); 48 + SherpaOnnxCreateOnlineRecognizer(&config);
49 if (!recognizer) { 49 if (!recognizer) {
50 fprintf(stderr, "Failed to create recognizer"); 50 fprintf(stderr, "Failed to create recognizer");
51 exit(-1); 51 exit(-1);
52 } 52 }
53 53
54 - const SherpaOnnxOnlineStream *stream = CreateOnlineStream(recognizer); 54 + const SherpaOnnxOnlineStream *stream =
  55 + SherpaOnnxCreateOnlineStream(recognizer);
55 56
56 - const SherpaOnnxDisplay *display = CreateDisplay(50); 57 + const SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50);
57 int32_t segment_id = 0; 58 int32_t segment_id = 0;
58 59
59 const SherpaOnnxWave *wave = SherpaOnnxReadWave(wav_filename); 60 const SherpaOnnxWave *wave = SherpaOnnxReadWave(wav_filename);
@@ -76,52 +77,53 @@ int32_t main() { @@ -76,52 +77,53 @@ int32_t main() {
76 (start + N > wave->num_samples) ? wave->num_samples : (start + N); 77 (start + N > wave->num_samples) ? wave->num_samples : (start + N);
77 k += N; 78 k += N;
78 79
79 - AcceptWaveform(stream, wave->sample_rate, wave->samples + start,  
80 - end - start);  
81 - while (IsOnlineStreamReady(recognizer, stream)) {  
82 - DecodeOnlineStream(recognizer, stream); 80 + SherpaOnnxOnlineStreamAcceptWaveform(stream, wave->sample_rate,
  81 + wave->samples + start, end - start);
  82 + while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  83 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
83 } 84 }
84 85
85 const SherpaOnnxOnlineRecognizerResult *r = 86 const SherpaOnnxOnlineRecognizerResult *r =
86 - GetOnlineStreamResult(recognizer, stream); 87 + SherpaOnnxGetOnlineStreamResult(recognizer, stream);
87 88
88 if (strlen(r->text)) { 89 if (strlen(r->text)) {
89 SherpaOnnxPrint(display, segment_id, r->text); 90 SherpaOnnxPrint(display, segment_id, r->text);
90 } 91 }
91 92
92 - if (IsEndpoint(recognizer, stream)) { 93 + if (SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream)) {
93 if (strlen(r->text)) { 94 if (strlen(r->text)) {
94 ++segment_id; 95 ++segment_id;
95 } 96 }
96 - Reset(recognizer, stream); 97 + SherpaOnnxOnlineStreamReset(recognizer, stream);
97 } 98 }
98 99
99 - DestroyOnlineRecognizerResult(r); 100 + SherpaOnnxDestroyOnlineRecognizerResult(r);
100 } 101 }
101 102
102 // add some tail padding 103 // add some tail padding
103 float tail_paddings[4800] = {0}; // 0.3 seconds at 16 kHz sample rate 104 float tail_paddings[4800] = {0}; // 0.3 seconds at 16 kHz sample rate
104 - AcceptWaveform(stream, wave->sample_rate, tail_paddings, 4800); 105 + SherpaOnnxOnlineStreamAcceptWaveform(stream, wave->sample_rate, tail_paddings,
  106 + 4800);
105 107
106 SherpaOnnxFreeWave(wave); 108 SherpaOnnxFreeWave(wave);
107 109
108 - InputFinished(stream);  
109 - while (IsOnlineStreamReady(recognizer, stream)) {  
110 - DecodeOnlineStream(recognizer, stream); 110 + SherpaOnnxOnlineStreamInputFinished(stream);
  111 + while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  112 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
111 } 113 }
112 114
113 const SherpaOnnxOnlineRecognizerResult *r = 115 const SherpaOnnxOnlineRecognizerResult *r =
114 - GetOnlineStreamResult(recognizer, stream); 116 + SherpaOnnxGetOnlineStreamResult(recognizer, stream);
115 117
116 if (strlen(r->text)) { 118 if (strlen(r->text)) {
117 SherpaOnnxPrint(display, segment_id, r->text); 119 SherpaOnnxPrint(display, segment_id, r->text);
118 } 120 }
119 121
120 - DestroyOnlineRecognizerResult(r); 122 + SherpaOnnxDestroyOnlineRecognizerResult(r);
121 123
122 - DestroyDisplay(display);  
123 - DestroyOnlineStream(stream);  
124 - DestroyOnlineRecognizer(recognizer); 124 + SherpaOnnxDestroyDisplay(display);
  125 + SherpaOnnxDestroyOnlineStream(stream);
  126 + SherpaOnnxDestroyOnlineRecognizer(recognizer);
125 fprintf(stderr, "\n"); 127 fprintf(stderr, "\n");
126 128
127 return 0; 129 return 0;
@@ -59,7 +59,7 @@ int32_t main() { @@ -59,7 +59,7 @@ int32_t main() {
59 recognizer_config.model_config = offline_model_config; 59 recognizer_config.model_config = offline_model_config;
60 60
61 SherpaOnnxOfflineRecognizer *recognizer = 61 SherpaOnnxOfflineRecognizer *recognizer =
62 - CreateOfflineRecognizer(&recognizer_config); 62 + SherpaOnnxCreateOfflineRecognizer(&recognizer_config);
63 63
64 if (recognizer == NULL) { 64 if (recognizer == NULL) {
65 fprintf(stderr, "Please check your config!\n"); 65 fprintf(stderr, "Please check your config!\n");
@@ -69,19 +69,19 @@ int32_t main() { @@ -69,19 +69,19 @@ int32_t main() {
69 return -1; 69 return -1;
70 } 70 }
71 71
72 - SherpaOnnxOfflineStream *stream = CreateOfflineStream(recognizer); 72 + SherpaOnnxOfflineStream *stream = SherpaOnnxCreateOfflineStream(recognizer);
73 73
74 - AcceptWaveformOffline(stream, wave->sample_rate, wave->samples,  
75 - wave->num_samples);  
76 - DecodeOfflineStream(recognizer, stream); 74 + SherpaOnnxAcceptWaveformOffline(stream, wave->sample_rate, wave->samples,
  75 + wave->num_samples);
  76 + SherpaOnnxDecodeOfflineStream(recognizer, stream);
77 const SherpaOnnxOfflineRecognizerResult *result = 77 const SherpaOnnxOfflineRecognizerResult *result =
78 - GetOfflineStreamResult(stream); 78 + SherpaOnnxGetOfflineStreamResult(stream);
79 79
80 fprintf(stderr, "Decoded text: %s\n", result->text); 80 fprintf(stderr, "Decoded text: %s\n", result->text);
81 81
82 - DestroyOfflineRecognizerResult(result);  
83 - DestroyOfflineStream(stream);  
84 - DestroyOfflineRecognizer(recognizer); 82 + SherpaOnnxDestroyOfflineRecognizerResult(result);
  83 + SherpaOnnxDestroyOfflineStream(stream);
  84 + SherpaOnnxDestroyOfflineRecognizer(recognizer);
85 SherpaOnnxFreeWave(wave); 85 SherpaOnnxFreeWave(wave);
86 86
87 return 0; 87 return 0;
@@ -9,7 +9,7 @@ environment: @@ -9,7 +9,7 @@ environment:
9 sdk: ^3.4.0 9 sdk: ^3.4.0
10 10
11 dependencies: 11 dependencies:
12 - sherpa_onnx: ^1.10.18 12 + sherpa_onnx: ^1.10.19
13 # sherpa_onnx: 13 # sherpa_onnx:
14 # path: ../../flutter/sherpa_onnx 14 # path: ../../flutter/sherpa_onnx
15 path: ^1.9.0 15 path: ^1.9.0
@@ -10,7 +10,7 @@ environment: @@ -10,7 +10,7 @@ environment:
10 10
11 # Add regular dependencies here. 11 # Add regular dependencies here.
12 dependencies: 12 dependencies:
13 - sherpa_onnx: ^1.10.18 13 + sherpa_onnx: ^1.10.19
14 path: ^1.9.0 14 path: ^1.9.0
15 args: ^2.5.0 15 args: ^2.5.0
16 16
@@ -11,7 +11,7 @@ environment: @@ -11,7 +11,7 @@ environment:
11 11
12 # Add regular dependencies here. 12 # Add regular dependencies here.
13 dependencies: 13 dependencies:
14 - sherpa_onnx: ^1.10.18 14 + sherpa_onnx: ^1.10.19
15 path: ^1.9.0 15 path: ^1.9.0
16 args: ^2.5.0 16 args: ^2.5.0
17 17
@@ -8,7 +8,7 @@ environment: @@ -8,7 +8,7 @@ environment:
8 8
9 # Add regular dependencies here. 9 # Add regular dependencies here.
10 dependencies: 10 dependencies:
11 - sherpa_onnx: ^1.10.18 11 + sherpa_onnx: ^1.10.19
12 path: ^1.9.0 12 path: ^1.9.0
13 args: ^2.5.0 13 args: ^2.5.0
14 14
@@ -9,7 +9,7 @@ environment: @@ -9,7 +9,7 @@ environment:
9 sdk: ^3.4.0 9 sdk: ^3.4.0
10 10
11 dependencies: 11 dependencies:
12 - sherpa_onnx: ^1.10.18 12 + sherpa_onnx: ^1.10.19
13 path: ^1.9.0 13 path: ^1.9.0
14 args: ^2.5.0 14 args: ^2.5.0
15 15
@@ -224,25 +224,25 @@ static void sherpa_decode_frame(const AVFrame *frame, @@ -224,25 +224,25 @@ static void sherpa_decode_frame(const AVFrame *frame,
224 const int16_t *p = (int16_t *)frame->data[0]; 224 const int16_t *p = (int16_t *)frame->data[0];
225 225
226 if (frame->nb_samples + nb_samples > N) { 226 if (frame->nb_samples + nb_samples > N) {
227 - AcceptWaveform(stream, 16000, samples, nb_samples);  
228 - while (IsOnlineStreamReady(recognizer, stream)) {  
229 - DecodeOnlineStream(recognizer, stream); 227 + SherpaOnnxOnlineStreamAcceptWaveform(stream, 16000, samples, nb_samples);
  228 + while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  229 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
230 } 230 }
231 231
232 SherpaOnnxOnlineRecognizerResult *r = 232 SherpaOnnxOnlineRecognizerResult *r =
233 - GetOnlineStreamResult(recognizer, stream); 233 + SherpaOnnxGetOnlineStreamResult(recognizer, stream);
234 if (strlen(r->text)) { 234 if (strlen(r->text)) {
235 SherpaOnnxPrint(display, *segment_id, r->text); 235 SherpaOnnxPrint(display, *segment_id, r->text);
236 } 236 }
237 237
238 - if (IsEndpoint(recognizer, stream)) { 238 + if (SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream)) {
239 if (strlen(r->text)) { 239 if (strlen(r->text)) {
240 ++*segment_id; 240 ++*segment_id;
241 } 241 }
242 - Reset(recognizer, stream); 242 + SherpaOnnxOnlineStreamReset(recognizer, stream);
243 } 243 }
244 244
245 - DestroyOnlineRecognizerResult(r); 245 + SherpaOnnxDestroyOnlineRecognizerResult(r);
246 nb_samples = 0; 246 nb_samples = 0;
247 } 247 }
248 248
@@ -317,9 +317,10 @@ int main(int argc, char **argv) { @@ -317,9 +317,10 @@ int main(int argc, char **argv) {
317 config.rule2_min_trailing_silence = 1.2; 317 config.rule2_min_trailing_silence = 1.2;
318 config.rule3_min_utterance_length = 300; 318 config.rule3_min_utterance_length = 300;
319 319
320 - SherpaOnnxOnlineRecognizer *recognizer = CreateOnlineRecognizer(&config);  
321 - SherpaOnnxOnlineStream *stream = CreateOnlineStream(recognizer);  
322 - SherpaOnnxDisplay *display = CreateDisplay(50); 320 + SherpaOnnxOnlineRecognizer *recognizer =
  321 + SherpaOnnxCreateOnlineRecognizer(&config);
  322 + SherpaOnnxOnlineStream *stream = SherpaOnnxCreateOnlineStream(recognizer);
  323 + SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50);
323 int32_t segment_id = 0; 324 int32_t segment_id = 0;
324 325
325 if ((ret = open_input_file(argv[5])) < 0) exit(1); 326 if ((ret = open_input_file(argv[5])) < 0) exit(1);
@@ -375,24 +376,24 @@ int main(int argc, char **argv) { @@ -375,24 +376,24 @@ int main(int argc, char **argv) {
375 376
376 // add some tail padding 377 // add some tail padding
377 float tail_paddings[4800] = {0}; // 0.3 seconds at 16 kHz sample rate 378 float tail_paddings[4800] = {0}; // 0.3 seconds at 16 kHz sample rate
378 - AcceptWaveform(stream, 16000, tail_paddings, 4800);  
379 - InputFinished(stream); 379 + SherpaOnnxOnlineStreamAcceptWaveform(stream, 16000, tail_paddings, 4800);
  380 + SherpaOnnxOnlineStreamInputFinished(stream);
380 381
381 - while (IsOnlineStreamReady(recognizer, stream)) {  
382 - DecodeOnlineStream(recognizer, stream); 382 + while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  383 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
383 } 384 }
384 385
385 SherpaOnnxOnlineRecognizerResult *r = 386 SherpaOnnxOnlineRecognizerResult *r =
386 - GetOnlineStreamResult(recognizer, stream); 387 + SherpaOnnxGetOnlineStreamResult(recognizer, stream);
387 if (strlen(r->text)) { 388 if (strlen(r->text)) {
388 SherpaOnnxPrint(display, segment_id, r->text); 389 SherpaOnnxPrint(display, segment_id, r->text);
389 } 390 }
390 391
391 - DestroyOnlineRecognizerResult(r); 392 + SherpaOnnxDestroyOnlineRecognizerResult(r);
392 393
393 - DestroyDisplay(display);  
394 - DestroyOnlineStream(stream);  
395 - DestroyOnlineRecognizer(recognizer); 394 + SherpaOnnxDestroyDisplay(display);
  395 + SherpaOnnxDestroyOnlineStream(stream);
  396 + SherpaOnnxDestroyOnlineRecognizer(recognizer);
396 397
397 avfilter_graph_free(&filter_graph); 398 avfilter_graph_free(&filter_graph);
398 avcodec_free_context(&dec_ctx); 399 avcodec_free_context(&dec_ctx);
@@ -5,7 +5,7 @@ description: > @@ -5,7 +5,7 @@ description: >
5 5
6 publish_to: 'none' 6 publish_to: 'none'
7 7
8 -version: 1.10.18 8 +version: 1.10.19
9 9
10 topics: 10 topics:
11 - speech-recognition 11 - speech-recognition
@@ -30,7 +30,7 @@ dependencies: @@ -30,7 +30,7 @@ dependencies:
30 record: ^5.1.0 30 record: ^5.1.0
31 url_launcher: ^6.2.6 31 url_launcher: ^6.2.6
32 32
33 - sherpa_onnx: ^1.10.18 33 + sherpa_onnx: ^1.10.19
34 # sherpa_onnx: 34 # sherpa_onnx:
35 # path: ../../flutter/sherpa_onnx 35 # path: ../../flutter/sherpa_onnx
36 36
@@ -5,7 +5,7 @@ description: > @@ -5,7 +5,7 @@ description: >
5 5
6 publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 publish_to: 'none' # Remove this line if you wish to publish to pub.dev
7 7
8 -version: 1.10.18 8 +version: 1.10.19
9 9
10 environment: 10 environment:
11 sdk: '>=3.4.0 <4.0.0' 11 sdk: '>=3.4.0 <4.0.0'
@@ -17,7 +17,7 @@ dependencies: @@ -17,7 +17,7 @@ dependencies:
17 cupertino_icons: ^1.0.6 17 cupertino_icons: ^1.0.6
18 path_provider: ^2.1.3 18 path_provider: ^2.1.3
19 path: ^1.9.0 19 path: ^1.9.0
20 - sherpa_onnx: ^1.10.18 20 + sherpa_onnx: ^1.10.19
21 url_launcher: ^6.2.6 21 url_launcher: ^6.2.6
22 audioplayers: ^5.0.0 22 audioplayers: ^5.0.0
23 23
@@ -461,26 +461,30 @@ typedef DestroyOfflineStreamResultJsonNative = Void Function(Pointer<Utf8>); @@ -461,26 +461,30 @@ typedef DestroyOfflineStreamResultJsonNative = Void Function(Pointer<Utf8>);
461 461
462 typedef DestroyOfflineStreamResultJson = void Function(Pointer<Utf8>); 462 typedef DestroyOfflineStreamResultJson = void Function(Pointer<Utf8>);
463 463
464 -typedef CreateOnlineRecognizerNative = Pointer<SherpaOnnxOnlineRecognizer>  
465 - Function(Pointer<SherpaOnnxOnlineRecognizerConfig>); 464 +typedef SherpaOnnxCreateOnlineRecognizerNative
  465 + = Pointer<SherpaOnnxOnlineRecognizer> Function(
  466 + Pointer<SherpaOnnxOnlineRecognizerConfig>);
466 467
467 -typedef CreateOnlineRecognizer = CreateOnlineRecognizerNative; 468 +typedef SherpaOnnxCreateOnlineRecognizer
  469 + = SherpaOnnxCreateOnlineRecognizerNative;
468 470
469 -typedef DestroyOnlineRecognizerNative = Void Function( 471 +typedef SherpaOnnxDestroyOnlineRecognizerNative = Void Function(
470 Pointer<SherpaOnnxOnlineRecognizer>); 472 Pointer<SherpaOnnxOnlineRecognizer>);
471 473
472 -typedef DestroyOnlineRecognizer = void Function( 474 +typedef SherpaOnnxDestroyOnlineRecognizer = void Function(
473 Pointer<SherpaOnnxOnlineRecognizer>); 475 Pointer<SherpaOnnxOnlineRecognizer>);
474 476
475 -typedef CreateOnlineStreamNative = Pointer<SherpaOnnxOnlineStream> Function(  
476 - Pointer<SherpaOnnxOnlineRecognizer>); 477 +typedef SherpaOnnxCreateOnlineStreamNative = Pointer<SherpaOnnxOnlineStream>
  478 + Function(Pointer<SherpaOnnxOnlineRecognizer>);
477 479
478 -typedef CreateOnlineStream = CreateOnlineStreamNative; 480 +typedef SherpaOnnxCreateOnlineStream = SherpaOnnxCreateOnlineStreamNative;
479 481
480 -typedef CreateOnlineStreamWithHotwordsNative = Pointer<SherpaOnnxOnlineStream>  
481 - Function(Pointer<SherpaOnnxOnlineRecognizer>, Pointer<Utf8>); 482 +typedef SherpaOnnxCreateOnlineStreamWithHotwordsNative
  483 + = Pointer<SherpaOnnxOnlineStream> Function(
  484 + Pointer<SherpaOnnxOnlineRecognizer>, Pointer<Utf8>);
482 485
483 -typedef CreateOnlineStreamWithHotwords = CreateOnlineStreamWithHotwordsNative; 486 +typedef SherpaOnnxCreateOnlineStreamWithHotwords
  487 + = SherpaOnnxCreateOnlineStreamWithHotwordsNative;
484 488
485 typedef IsOnlineStreamReadyNative = Int32 Function( 489 typedef IsOnlineStreamReadyNative = Int32 Function(
486 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); 490 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
@@ -488,10 +492,10 @@ typedef IsOnlineStreamReadyNative = Int32 Function( @@ -488,10 +492,10 @@ typedef IsOnlineStreamReadyNative = Int32 Function(
488 typedef IsOnlineStreamReady = int Function( 492 typedef IsOnlineStreamReady = int Function(
489 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); 493 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
490 494
491 -typedef DecodeOnlineStreamNative = Void Function( 495 +typedef SherpaOnnxDecodeOnlineStreamNative = Void Function(
492 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); 496 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
493 497
494 -typedef DecodeOnlineStream = void Function( 498 +typedef SherpaOnnxDecodeOnlineStream = void Function(
495 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>); 499 Pointer<SherpaOnnxOnlineRecognizer>, Pointer<SherpaOnnxOnlineStream>);
496 500
497 typedef GetOnlineStreamResultAsJsonNative = Pointer<Utf8> Function( 501 typedef GetOnlineStreamResultAsJsonNative = Pointer<Utf8> Function(
@@ -745,10 +749,11 @@ typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative @@ -745,10 +749,11 @@ typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative
745 typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStream 749 typedef SherpaOnnxSpeakerEmbeddingExtractorCreateStream
746 = SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative; 750 = SherpaOnnxSpeakerEmbeddingExtractorCreateStreamNative;
747 751
748 -typedef DestroyOnlineStreamNative = Void Function( 752 +typedef SherpaOnnxDestroyOnlineStreamNative = Void Function(
749 Pointer<SherpaOnnxOnlineStream>); 753 Pointer<SherpaOnnxOnlineStream>);
750 754
751 -typedef DestroyOnlineStream = void Function(Pointer<SherpaOnnxOnlineStream>); 755 +typedef SherpaOnnxDestroyOnlineStream = void Function(
  756 + Pointer<SherpaOnnxOnlineStream>);
752 757
753 typedef OnlineStreamAcceptWaveformNative = Void Function( 758 typedef OnlineStreamAcceptWaveformNative = Void Function(
754 Pointer<SherpaOnnxOnlineStream>, Int32, Pointer<Float>, Int32); 759 Pointer<SherpaOnnxOnlineStream>, Int32, Pointer<Float>, Int32);
@@ -827,17 +832,18 @@ class SherpaOnnxBindings { @@ -827,17 +832,18 @@ class SherpaOnnxBindings {
827 static GetOfflineStreamResultAsJson? getOfflineStreamResultAsJson; 832 static GetOfflineStreamResultAsJson? getOfflineStreamResultAsJson;
828 static DestroyOfflineStreamResultJson? destroyOfflineStreamResultJson; 833 static DestroyOfflineStreamResultJson? destroyOfflineStreamResultJson;
829 834
830 - static CreateOnlineRecognizer? createOnlineRecognizer; 835 + static SherpaOnnxCreateOnlineRecognizer? createOnlineRecognizer;
831 836
832 - static DestroyOnlineRecognizer? destroyOnlineRecognizer; 837 + static SherpaOnnxDestroyOnlineRecognizer? destroyOnlineRecognizer;
833 838
834 - static CreateOnlineStream? createOnlineStream; 839 + static SherpaOnnxCreateOnlineStream? createOnlineStream;
835 840
836 - static CreateOnlineStreamWithHotwords? createOnlineStreamWithHotwords; 841 + static SherpaOnnxCreateOnlineStreamWithHotwords?
  842 + createOnlineStreamWithHotwords;
837 843
838 static IsOnlineStreamReady? isOnlineStreamReady; 844 static IsOnlineStreamReady? isOnlineStreamReady;
839 845
840 - static DecodeOnlineStream? decodeOnlineStream; 846 + static SherpaOnnxDecodeOnlineStream? decodeOnlineStream;
841 847
842 static GetOnlineStreamResultAsJson? getOnlineStreamResultAsJson; 848 static GetOnlineStreamResultAsJson? getOnlineStreamResultAsJson;
843 849
@@ -905,7 +911,7 @@ class SherpaOnnxBindings { @@ -905,7 +911,7 @@ class SherpaOnnxBindings {
905 static SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding? 911 static SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding?
906 speakerEmbeddingExtractorDestroyEmbedding; 912 speakerEmbeddingExtractorDestroyEmbedding;
907 913
908 - static DestroyOnlineStream? destroyOnlineStream; 914 + static SherpaOnnxDestroyOnlineStream? destroyOnlineStream;
909 915
910 static OnlineStreamAcceptWaveform? onlineStreamAcceptWaveform; 916 static OnlineStreamAcceptWaveform? onlineStreamAcceptWaveform;
911 917
@@ -954,42 +960,42 @@ class SherpaOnnxBindings { @@ -954,42 +960,42 @@ class SherpaOnnxBindings {
954 static void init(DynamicLibrary dynamicLibrary) { 960 static void init(DynamicLibrary dynamicLibrary) {
955 createKeywordSpotter ??= dynamicLibrary 961 createKeywordSpotter ??= dynamicLibrary
956 .lookup<NativeFunction<CreateKeywordSpotterNative>>( 962 .lookup<NativeFunction<CreateKeywordSpotterNative>>(
957 - 'CreateKeywordSpotter') 963 + 'SherpaOnnxCreateKeywordSpotter')
958 .asFunction(); 964 .asFunction();
959 965
960 destroyKeywordSpotter ??= dynamicLibrary 966 destroyKeywordSpotter ??= dynamicLibrary
961 .lookup<NativeFunction<DestroyKeywordSpotterNative>>( 967 .lookup<NativeFunction<DestroyKeywordSpotterNative>>(
962 - 'DestroyKeywordSpotter') 968 + 'SherpaOnnxDestroyKeywordSpotter')
963 .asFunction(); 969 .asFunction();
964 970
965 createKeywordStream ??= dynamicLibrary 971 createKeywordStream ??= dynamicLibrary
966 .lookup<NativeFunction<CreateKeywordStreamNative>>( 972 .lookup<NativeFunction<CreateKeywordStreamNative>>(
967 - 'CreateKeywordStream') 973 + 'SherpaOnnxCreateKeywordStream')
968 .asFunction(); 974 .asFunction();
969 975
970 createKeywordStreamWithKeywords ??= dynamicLibrary 976 createKeywordStreamWithKeywords ??= dynamicLibrary
971 .lookup<NativeFunction<CreateKeywordStreamWithKeywordsNative>>( 977 .lookup<NativeFunction<CreateKeywordStreamWithKeywordsNative>>(
972 - 'CreateKeywordStreamWithKeywords') 978 + 'SherpaOnnxCreateKeywordStreamWithKeywords')
973 .asFunction(); 979 .asFunction();
974 980
975 isKeywordStreamReady ??= dynamicLibrary 981 isKeywordStreamReady ??= dynamicLibrary
976 .lookup<NativeFunction<IsKeywordStreamReadyNative>>( 982 .lookup<NativeFunction<IsKeywordStreamReadyNative>>(
977 - 'IsKeywordStreamReady') 983 + 'SherpaOnnxIsKeywordStreamReady')
978 .asFunction(); 984 .asFunction();
979 985
980 decodeKeywordStream ??= dynamicLibrary 986 decodeKeywordStream ??= dynamicLibrary
981 .lookup<NativeFunction<DecodeKeywordStreamNative>>( 987 .lookup<NativeFunction<DecodeKeywordStreamNative>>(
982 - 'DecodeKeywordStream') 988 + 'SherpaOnnxDecodeKeywordStream')
983 .asFunction(); 989 .asFunction();
984 990
985 getKeywordResultAsJson ??= dynamicLibrary 991 getKeywordResultAsJson ??= dynamicLibrary
986 .lookup<NativeFunction<GetKeywordResultAsJsonNative>>( 992 .lookup<NativeFunction<GetKeywordResultAsJsonNative>>(
987 - 'GetKeywordResultAsJson') 993 + 'SherpaOnnxGetKeywordResultAsJson')
988 .asFunction(); 994 .asFunction();
989 995
990 freeKeywordResultJson ??= dynamicLibrary 996 freeKeywordResultJson ??= dynamicLibrary
991 .lookup<NativeFunction<FreeKeywordResultJsonNative>>( 997 .lookup<NativeFunction<FreeKeywordResultJsonNative>>(
992 - 'FreeKeywordResultJson') 998 + 'SherpaOnnxFreeKeywordResultJson')
993 .asFunction(); 999 .asFunction();
994 1000
995 createOfflineTts ??= dynamicLibrary 1001 createOfflineTts ??= dynamicLibrary
@@ -1031,88 +1037,91 @@ class SherpaOnnxBindings { @@ -1031,88 +1037,91 @@ class SherpaOnnxBindings {
1031 1037
1032 createOfflineRecognizer ??= dynamicLibrary 1038 createOfflineRecognizer ??= dynamicLibrary
1033 .lookup<NativeFunction<CreateOfflineRecognizerNative>>( 1039 .lookup<NativeFunction<CreateOfflineRecognizerNative>>(
1034 - 'CreateOfflineRecognizer') 1040 + 'SherpaOnnxCreateOfflineRecognizer')
1035 .asFunction(); 1041 .asFunction();
1036 1042
1037 destroyOfflineRecognizer ??= dynamicLibrary 1043 destroyOfflineRecognizer ??= dynamicLibrary
1038 .lookup<NativeFunction<DestroyOfflineRecognizerNative>>( 1044 .lookup<NativeFunction<DestroyOfflineRecognizerNative>>(
1039 - 'DestroyOfflineRecognizer') 1045 + 'SherpaOnnxDestroyOfflineRecognizer')
1040 .asFunction(); 1046 .asFunction();
1041 1047
1042 createOfflineStream ??= dynamicLibrary 1048 createOfflineStream ??= dynamicLibrary
1043 .lookup<NativeFunction<CreateOfflineStreamNative>>( 1049 .lookup<NativeFunction<CreateOfflineStreamNative>>(
1044 - 'CreateOfflineStream') 1050 + 'SherpaOnnxCreateOfflineStream')
1045 .asFunction(); 1051 .asFunction();
1046 1052
1047 destroyOfflineStream ??= dynamicLibrary 1053 destroyOfflineStream ??= dynamicLibrary
1048 .lookup<NativeFunction<DestroyOfflineStreamNative>>( 1054 .lookup<NativeFunction<DestroyOfflineStreamNative>>(
1049 - 'DestroyOfflineStream') 1055 + 'SherpaOnnxDestroyOfflineStream')
1050 .asFunction(); 1056 .asFunction();
1051 1057
1052 acceptWaveformOffline ??= dynamicLibrary 1058 acceptWaveformOffline ??= dynamicLibrary
1053 .lookup<NativeFunction<AcceptWaveformOfflineNative>>( 1059 .lookup<NativeFunction<AcceptWaveformOfflineNative>>(
1054 - 'AcceptWaveformOffline') 1060 + 'SherpaOnnxAcceptWaveformOffline')
1055 .asFunction(); 1061 .asFunction();
1056 1062
1057 decodeOfflineStream ??= dynamicLibrary 1063 decodeOfflineStream ??= dynamicLibrary
1058 .lookup<NativeFunction<DecodeOfflineStreamNative>>( 1064 .lookup<NativeFunction<DecodeOfflineStreamNative>>(
1059 - 'DecodeOfflineStream') 1065 + 'SherpaOnnxDecodeOfflineStream')
1060 .asFunction(); 1066 .asFunction();
1061 1067
1062 getOfflineStreamResultAsJson ??= dynamicLibrary 1068 getOfflineStreamResultAsJson ??= dynamicLibrary
1063 .lookup<NativeFunction<GetOfflineStreamResultAsJsonNative>>( 1069 .lookup<NativeFunction<GetOfflineStreamResultAsJsonNative>>(
1064 - 'GetOfflineStreamResultAsJson') 1070 + 'SherpaOnnxGetOfflineStreamResultAsJson')
1065 .asFunction(); 1071 .asFunction();
1066 1072
1067 destroyOfflineStreamResultJson ??= dynamicLibrary 1073 destroyOfflineStreamResultJson ??= dynamicLibrary
1068 .lookup<NativeFunction<DestroyOfflineStreamResultJsonNative>>( 1074 .lookup<NativeFunction<DestroyOfflineStreamResultJsonNative>>(
1069 - 'DestroyOfflineStreamResultJson') 1075 + 'SherpaOnnxDestroyOfflineStreamResultJson')
1070 .asFunction(); 1076 .asFunction();
1071 1077
1072 createOnlineRecognizer ??= dynamicLibrary 1078 createOnlineRecognizer ??= dynamicLibrary
1073 - .lookup<NativeFunction<CreateOnlineRecognizerNative>>(  
1074 - 'CreateOnlineRecognizer') 1079 + .lookup<NativeFunction<SherpaOnnxCreateOnlineRecognizerNative>>(
  1080 + 'SherpaOnnxCreateOnlineRecognizer')
1075 .asFunction(); 1081 .asFunction();
1076 1082
1077 destroyOnlineRecognizer ??= dynamicLibrary 1083 destroyOnlineRecognizer ??= dynamicLibrary
1078 - .lookup<NativeFunction<DestroyOnlineRecognizerNative>>(  
1079 - 'DestroyOnlineRecognizer') 1084 + .lookup<NativeFunction<SherpaOnnxDestroyOnlineRecognizerNative>>(
  1085 + 'SherpaOnnxDestroyOnlineRecognizer')
1080 .asFunction(); 1086 .asFunction();
1081 1087
1082 createOnlineStream ??= dynamicLibrary 1088 createOnlineStream ??= dynamicLibrary
1083 - .lookup<NativeFunction<CreateOnlineStreamNative>>('CreateOnlineStream') 1089 + .lookup<NativeFunction<SherpaOnnxCreateOnlineStreamNative>>(
  1090 + 'SherpaOnnxCreateOnlineStream')
1084 .asFunction(); 1091 .asFunction();
1085 1092
1086 createOnlineStreamWithHotwords ??= dynamicLibrary 1093 createOnlineStreamWithHotwords ??= dynamicLibrary
1087 - .lookup<NativeFunction<CreateOnlineStreamWithHotwordsNative>>(  
1088 - 'CreateOnlineStreamWithHotwords') 1094 + .lookup<NativeFunction<SherpaOnnxCreateOnlineStreamWithHotwordsNative>>(
  1095 + 'SherpaOnnxCreateOnlineStreamWithHotwords')
1089 .asFunction(); 1096 .asFunction();
1090 1097
1091 isOnlineStreamReady ??= dynamicLibrary 1098 isOnlineStreamReady ??= dynamicLibrary
1092 .lookup<NativeFunction<IsOnlineStreamReadyNative>>( 1099 .lookup<NativeFunction<IsOnlineStreamReadyNative>>(
1093 - 'IsOnlineStreamReady') 1100 + 'SherpaOnnxIsOnlineStreamReady')
1094 .asFunction(); 1101 .asFunction();
1095 1102
1096 decodeOnlineStream ??= dynamicLibrary 1103 decodeOnlineStream ??= dynamicLibrary
1097 - .lookup<NativeFunction<DecodeOnlineStreamNative>>('DecodeOnlineStream') 1104 + .lookup<NativeFunction<SherpaOnnxDecodeOnlineStreamNative>>(
  1105 + 'SherpaOnnxDecodeOnlineStream')
1098 .asFunction(); 1106 .asFunction();
1099 1107
1100 getOnlineStreamResultAsJson ??= dynamicLibrary 1108 getOnlineStreamResultAsJson ??= dynamicLibrary
1101 .lookup<NativeFunction<GetOnlineStreamResultAsJsonNative>>( 1109 .lookup<NativeFunction<GetOnlineStreamResultAsJsonNative>>(
1102 - 'GetOnlineStreamResultAsJson') 1110 + 'SherpaOnnxGetOnlineStreamResultAsJson')
1103 .asFunction(); 1111 .asFunction();
1104 1112
1105 reset ??= dynamicLibrary 1113 reset ??= dynamicLibrary
1106 - .lookup<NativeFunction<ResetNative>>('Reset') 1114 + .lookup<NativeFunction<ResetNative>>('SherpaOnnxOnlineStreamReset')
1107 .asFunction(); 1115 .asFunction();
1108 1116
1109 isEndpoint ??= dynamicLibrary 1117 isEndpoint ??= dynamicLibrary
1110 - .lookup<NativeFunction<IsEndpointNative>>('IsEndpoint') 1118 + .lookup<NativeFunction<IsEndpointNative>>(
  1119 + 'SherpaOnnxOnlineStreamIsEndpoint')
1111 .asFunction(); 1120 .asFunction();
1112 1121
1113 destroyOnlineStreamResultJson ??= dynamicLibrary 1122 destroyOnlineStreamResultJson ??= dynamicLibrary
1114 .lookup<NativeFunction<DestroyOnlineStreamResultJsonNative>>( 1123 .lookup<NativeFunction<DestroyOnlineStreamResultJsonNative>>(
1115 - 'DestroyOnlineStreamResultJson') 1124 + 'SherpaOnnxDestroyOnlineStreamResultJson')
1116 .asFunction(); 1125 .asFunction();
1117 1126
1118 createVoiceActivityDetector ??= dynamicLibrary 1127 createVoiceActivityDetector ??= dynamicLibrary
@@ -1258,18 +1267,18 @@ class SherpaOnnxBindings { @@ -1258,18 +1267,18 @@ class SherpaOnnxBindings {
1258 .asFunction(); 1267 .asFunction();
1259 1268
1260 destroyOnlineStream ??= dynamicLibrary 1269 destroyOnlineStream ??= dynamicLibrary
1261 - .lookup<NativeFunction<DestroyOnlineStreamNative>>(  
1262 - 'DestroyOnlineStream') 1270 + .lookup<NativeFunction<SherpaOnnxDestroyOnlineStreamNative>>(
  1271 + 'SherpaOnnxDestroyOnlineStream')
1263 .asFunction(); 1272 .asFunction();
1264 1273
1265 onlineStreamAcceptWaveform ??= dynamicLibrary 1274 onlineStreamAcceptWaveform ??= dynamicLibrary
1266 .lookup<NativeFunction<OnlineStreamAcceptWaveformNative>>( 1275 .lookup<NativeFunction<OnlineStreamAcceptWaveformNative>>(
1267 - 'AcceptWaveform') 1276 + 'SherpaOnnxOnlineStreamAcceptWaveform')
1268 .asFunction(); 1277 .asFunction();
1269 1278
1270 onlineStreamInputFinished ??= dynamicLibrary 1279 onlineStreamInputFinished ??= dynamicLibrary
1271 .lookup<NativeFunction<OnlineStreamInputFinishedNative>>( 1280 .lookup<NativeFunction<OnlineStreamInputFinishedNative>>(
1272 - 'InputFinished') 1281 + 'SherpaOnnxOnlineStreamInputFinished')
1273 .asFunction(); 1282 .asFunction();
1274 1283
1275 speakerEmbeddingExtractorIsReady ??= dynamicLibrary 1284 speakerEmbeddingExtractorIsReady ??= dynamicLibrary
@@ -17,7 +17,7 @@ topics: @@ -17,7 +17,7 @@ topics:
17 - voice-activity-detection 17 - voice-activity-detection
18 18
19 # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec 19 # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx_macos.podspec
20 -version: 1.10.18 20 +version: 1.10.19
21 21
22 homepage: https://github.com/k2-fsa/sherpa-onnx 22 homepage: https://github.com/k2-fsa/sherpa-onnx
23 23
@@ -30,23 +30,23 @@ dependencies: @@ -30,23 +30,23 @@ dependencies:
30 flutter: 30 flutter:
31 sdk: flutter 31 sdk: flutter
32 32
33 - sherpa_onnx_android: ^1.10.18 33 + sherpa_onnx_android: ^1.10.19
34 # sherpa_onnx_android: 34 # sherpa_onnx_android:
35 # path: ../sherpa_onnx_android 35 # path: ../sherpa_onnx_android
36 36
37 - sherpa_onnx_macos: ^1.10.18 37 + sherpa_onnx_macos: ^1.10.19
38 # sherpa_onnx_macos: 38 # sherpa_onnx_macos:
39 # path: ../sherpa_onnx_macos 39 # path: ../sherpa_onnx_macos
40 40
41 - sherpa_onnx_linux: ^1.10.18 41 + sherpa_onnx_linux: ^1.10.19
42 # sherpa_onnx_linux: 42 # sherpa_onnx_linux:
43 # path: ../sherpa_onnx_linux 43 # path: ../sherpa_onnx_linux
44 # 44 #
45 - sherpa_onnx_windows: ^1.10.18 45 + sherpa_onnx_windows: ^1.10.19
46 # sherpa_onnx_windows: 46 # sherpa_onnx_windows:
47 # path: ../sherpa_onnx_windows 47 # path: ../sherpa_onnx_windows
48 48
49 - sherpa_onnx_ios: ^1.10.18 49 + sherpa_onnx_ios: ^1.10.19
50 # sherpa_onnx_ios: 50 # sherpa_onnx_ios:
51 # path: ../sherpa_onnx_ios 51 # path: ../sherpa_onnx_ios
52 52
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 # https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c 7 # https://groups.google.com/g/dart-ffi/c/nUATMBy7r0c
8 Pod::Spec.new do |s| 8 Pod::Spec.new do |s|
9 s.name = 'sherpa_onnx_ios' 9 s.name = 'sherpa_onnx_ios'
10 - s.version = '1.10.18' 10 + s.version = '1.10.19'
11 s.summary = 'A new Flutter FFI plugin project.' 11 s.summary = 'A new Flutter FFI plugin project.'
12 s.description = <<-DESC 12 s.description = <<-DESC
13 A new Flutter FFI plugin project. 13 A new Flutter FFI plugin project.
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 # 4 #
5 Pod::Spec.new do |s| 5 Pod::Spec.new do |s|
6 s.name = 'sherpa_onnx_macos' 6 s.name = 'sherpa_onnx_macos'
7 - s.version = '1.10.18' 7 + s.version = '1.10.19'
8 s.summary = 'sherpa-onnx Flutter FFI plugin project.' 8 s.summary = 'sherpa-onnx Flutter FFI plugin project.'
9 s.description = <<-DESC 9 s.description = <<-DESC
10 sherpa-onnx Flutter FFI plugin project. 10 sherpa-onnx Flutter FFI plugin project.
@@ -111,7 +111,7 @@ CNonStreamingSpeechRecognitionDlg::CNonStreamingSpeechRecognitionDlg( @@ -111,7 +111,7 @@ CNonStreamingSpeechRecognitionDlg::CNonStreamingSpeechRecognitionDlg(
111 111
112 CNonStreamingSpeechRecognitionDlg::~CNonStreamingSpeechRecognitionDlg() { 112 CNonStreamingSpeechRecognitionDlg::~CNonStreamingSpeechRecognitionDlg() {
113 if (recognizer_) { 113 if (recognizer_) {
114 - DestroyOfflineRecognizer(recognizer_); 114 + SherpaOnnxDestroyOfflineRecognizer(recognizer_);
115 recognizer_ = nullptr; 115 recognizer_ = nullptr;
116 } 116 }
117 } 117 }
@@ -256,12 +256,12 @@ void CNonStreamingSpeechRecognitionDlg::OnBnClickedOk() { @@ -256,12 +256,12 @@ void CNonStreamingSpeechRecognitionDlg::OnBnClickedOk() {
256 } 256 }
257 pa_stream_ = nullptr; 257 pa_stream_ = nullptr;
258 258
259 - SherpaOnnxOfflineStream *stream = CreateOfflineStream(recognizer_); 259 + SherpaOnnxOfflineStream *stream = SherpaOnnxCreateOfflineStream(recognizer_);
260 260
261 - AcceptWaveformOffline(stream, config_.feat_config.sample_rate, 261 + SherpaOnnxAcceptWaveformOffline(stream, config_.feat_config.sample_rate,
262 samples_.data(), static_cast<int32_t>(samples_.size())); 262 samples_.data(), static_cast<int32_t>(samples_.size()));
263 - DecodeOfflineStream(recognizer_, stream);  
264 - auto r = GetOfflineStreamResult(stream); 263 + SherpaOnnxDecodeOfflineStream(recognizer_, stream);
  264 + auto r = SherpaOnnxGetOfflineStreamResult(stream);
265 results_.emplace_back(r->text); 265 results_.emplace_back(r->text);
266 266
267 auto str = Utf8ToUtf16(Cat(results_).c_str()); 267 auto str = Utf8ToUtf16(Cat(results_).c_str());
@@ -269,9 +269,9 @@ void CNonStreamingSpeechRecognitionDlg::OnBnClickedOk() { @@ -269,9 +269,9 @@ void CNonStreamingSpeechRecognitionDlg::OnBnClickedOk() {
269 my_text_.SetFocus(); 269 my_text_.SetFocus();
270 my_text_.SetSel(-1); 270 my_text_.SetSel(-1);
271 271
272 - DestroyOfflineRecognizerResult(r); 272 + SherpaOnnxDestroyOfflineRecognizerResult(r);
273 273
274 - DestroyOfflineStream(stream); 274 + SherpaOnnxDestroyOfflineStream(stream);
275 // AfxMessageBox("Stopped", MB_OK); 275 // AfxMessageBox("Stopped", MB_OK);
276 my_btn_.SetWindowText(_T("Start")); 276 my_btn_.SetWindowText(_T("Start"));
277 AppendLineToMultilineEditCtrl("\r\nStopped. Please click start and speak"); 277 AppendLineToMultilineEditCtrl("\r\nStopped. Please click start and speak");
@@ -417,7 +417,7 @@ void CNonStreamingSpeechRecognitionDlg::InitWhisper() { @@ -417,7 +417,7 @@ void CNonStreamingSpeechRecognitionDlg::InitWhisper() {
417 config_.decoding_method = "greedy_search"; 417 config_.decoding_method = "greedy_search";
418 config_.max_active_paths = 4; 418 config_.max_active_paths = 4;
419 419
420 - recognizer_ = CreateOfflineRecognizer(&config_); 420 + recognizer_ = SherpaOnnxCreateOfflineRecognizer(&config_);
421 } 421 }
422 422
423 void CNonStreamingSpeechRecognitionDlg::InitParaformer() { 423 void CNonStreamingSpeechRecognitionDlg::InitParaformer() {
@@ -459,7 +459,7 @@ void CNonStreamingSpeechRecognitionDlg::InitParaformer() { @@ -459,7 +459,7 @@ void CNonStreamingSpeechRecognitionDlg::InitParaformer() {
459 config_.decoding_method = "greedy_search"; 459 config_.decoding_method = "greedy_search";
460 config_.max_active_paths = 4; 460 config_.max_active_paths = 4;
461 461
462 - recognizer_ = CreateOfflineRecognizer(&config_); 462 + recognizer_ = SherpaOnnxCreateOfflineRecognizer(&config_);
463 } 463 }
464 464
465 void CNonStreamingSpeechRecognitionDlg::InitRecognizer() { 465 void CNonStreamingSpeechRecognitionDlg::InitRecognizer() {
@@ -525,7 +525,7 @@ void CNonStreamingSpeechRecognitionDlg::InitRecognizer() { @@ -525,7 +525,7 @@ void CNonStreamingSpeechRecognitionDlg::InitRecognizer() {
525 config_.decoding_method = "greedy_search"; 525 config_.decoding_method = "greedy_search";
526 config_.max_active_paths = 4; 526 config_.max_active_paths = 4;
527 527
528 - recognizer_ = CreateOfflineRecognizer(&config_); 528 + recognizer_ = SherpaOnnxCreateOfflineRecognizer(&config_);
529 } 529 }
530 530
531 void CNonStreamingSpeechRecognitionDlg::AppendTextToEditCtrl( 531 void CNonStreamingSpeechRecognitionDlg::AppendTextToEditCtrl(
@@ -46,7 +46,7 @@ CStreamingSpeechRecognitionDlg::CStreamingSpeechRecognitionDlg( @@ -46,7 +46,7 @@ CStreamingSpeechRecognitionDlg::CStreamingSpeechRecognitionDlg(
46 46
47 CStreamingSpeechRecognitionDlg::~CStreamingSpeechRecognitionDlg() { 47 CStreamingSpeechRecognitionDlg::~CStreamingSpeechRecognitionDlg() {
48 if (recognizer_) { 48 if (recognizer_) {
49 - DestroyOnlineRecognizer(recognizer_); 49 + SherpaOnnxDestroyOnlineRecognizer(recognizer_);
50 recognizer_ = nullptr; 50 recognizer_ = nullptr;
51 } 51 }
52 } 52 }
@@ -123,7 +123,7 @@ static int32_t RecordCallback(const void *input_buffer, @@ -123,7 +123,7 @@ static int32_t RecordCallback(const void *input_buffer,
123 123
124 auto stream = dlg->stream_; 124 auto stream = dlg->stream_;
125 if (stream) { 125 if (stream) {
126 - AcceptWaveform(stream, 16000, reinterpret_cast<const float *>(input_buffer), 126 + SherpaOnnxOnlineStreamAcceptWaveform(stream, 16000, reinterpret_cast<const float *>(input_buffer),
127 frames_per_buffer); 127 frames_per_buffer);
128 } 128 }
129 129
@@ -146,11 +146,11 @@ void CStreamingSpeechRecognitionDlg::OnBnClickedOk() { @@ -146,11 +146,11 @@ void CStreamingSpeechRecognitionDlg::OnBnClickedOk() {
146 started_ = true; 146 started_ = true;
147 147
148 if (stream_) { 148 if (stream_) {
149 - DestroyOnlineStream(stream_); 149 + SherpaOnnxDestroyOnlineStream(stream_);
150 stream_ = nullptr; 150 stream_ = nullptr;
151 } 151 }
152 152
153 - stream_ = CreateOnlineStream(recognizer_); 153 + stream_ = SherpaOnnxCreateOnlineStream(recognizer_);
154 154
155 PaStreamParameters param; 155 PaStreamParameters param;
156 param.device = Pa_GetDefaultInputDevice(); 156 param.device = Pa_GetDefaultInputDevice();
@@ -356,7 +356,7 @@ void CStreamingSpeechRecognitionDlg::InitParaformer() { @@ -356,7 +356,7 @@ void CStreamingSpeechRecognitionDlg::InitParaformer() {
356 config.model_config.paraformer.encoder = paraformer_encoder.c_str(); 356 config.model_config.paraformer.encoder = paraformer_encoder.c_str();
357 config.model_config.paraformer.decoder = paraformer_decoder.c_str(); 357 config.model_config.paraformer.decoder = paraformer_decoder.c_str();
358 358
359 - recognizer_ = CreateOnlineRecognizer(&config); 359 + recognizer_ = SherpaOnnxCreateOnlineRecognizer(&config);
360 } 360 }
361 361
362 void CStreamingSpeechRecognitionDlg::InitRecognizer() { 362 void CStreamingSpeechRecognitionDlg::InitRecognizer() {
@@ -422,7 +422,7 @@ void CStreamingSpeechRecognitionDlg::InitRecognizer() { @@ -422,7 +422,7 @@ void CStreamingSpeechRecognitionDlg::InitRecognizer() {
422 config.model_config.transducer.decoder = decoder.c_str(); 422 config.model_config.transducer.decoder = decoder.c_str();
423 config.model_config.transducer.joiner = joiner.c_str(); 423 config.model_config.transducer.joiner = joiner.c_str();
424 424
425 - recognizer_ = CreateOnlineRecognizer(&config); 425 + recognizer_ = SherpaOnnxCreateOnlineRecognizer(&config);
426 } 426 }
427 427
428 // see 428 // see
@@ -519,13 +519,13 @@ int CStreamingSpeechRecognitionDlg::RunThread() { @@ -519,13 +519,13 @@ int CStreamingSpeechRecognitionDlg::RunThread() {
519 519
520 std::string last_text; 520 std::string last_text;
521 while (started_) { 521 while (started_) {
522 - while (IsOnlineStreamReady(recognizer_, stream_)) {  
523 - DecodeOnlineStream(recognizer_, stream_); 522 + while (SherpaOnnxIsOnlineStreamReady(recognizer_, stream_)) {
  523 + SherpaOnnxDecodeOnlineStream(recognizer_, stream_);
524 } 524 }
525 525
526 - auto r = GetOnlineStreamResult(recognizer_, stream_); 526 + auto r = SherpaOnnxGetOnlineStreamResult(recognizer_, stream_);
527 std::string text = r->text; 527 std::string text = r->text;
528 - DestroyOnlineRecognizerResult(r); 528 + SherpaOnnxDestroyOnlineRecognizer(r);
529 if (!text.empty() && last_text != text) { 529 if (!text.empty() && last_text != text) {
530 // CString str; 530 // CString str;
531 // str.Format(_T("%s"), Cat(results, text).c_str()); 531 // str.Format(_T("%s"), Cat(results, text).c_str());
@@ -535,9 +535,9 @@ int CStreamingSpeechRecognitionDlg::RunThread() { @@ -535,9 +535,9 @@ int CStreamingSpeechRecognitionDlg::RunThread() {
535 my_text_.SetSel(-1); 535 my_text_.SetSel(-1);
536 last_text = text; 536 last_text = text;
537 } 537 }
538 - int is_endpoint = IsEndpoint(recognizer_, stream_); 538 + int is_endpoint = SherpaOnnxOnlineStreamIsEndpoint(recognizer_, stream_);
539 if (is_endpoint) { 539 if (is_endpoint) {
540 - Reset(recognizer_, stream_); 540 + SherpaOnnxOnlineStreamReset(recognizer_, stream_);
541 if (!text.empty()) { 541 if (!text.empty()) {
542 results.push_back(std::move(text)); 542 results.push_back(std::move(text));
543 } 543 }
1 { 1 {
2 "dependencies": { 2 "dependencies": {
3 - "sherpa-onnx-node": "^1.10.18" 3 + "sherpa-onnx-node": "^1.10.19"
4 } 4 }
5 } 5 }
@@ -9,7 +9,6 @@ environment: @@ -9,7 +9,6 @@ environment:
9 sdk: ^3.4.0 9 sdk: ^3.4.0
10 10
11 dependencies: 11 dependencies:
12 - # sherpa_onnx: ^1.10.18  
13 sherpa_onnx: 12 sherpa_onnx:
14 path: ../../flutter/sherpa_onnx 13 path: ../../flutter/sherpa_onnx
15 path: ^1.9.0 14 path: ^1.9.0
@@ -17,7 +17,7 @@ topics: @@ -17,7 +17,7 @@ topics:
17 - voice-activity-detection 17 - voice-activity-detection
18 18
19 # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx.podspec 19 # remember to change the version in ../sherpa_onnx_macos/macos/sherpa_onnx.podspec
20 -version: 1.10.18 20 +version: 1.10.19
21 21
22 homepage: https://github.com/k2-fsa/sherpa-onnx 22 homepage: https://github.com/k2-fsa/sherpa-onnx
23 23
@@ -13,20 +13,20 @@ namespace SherpaOnnx @@ -13,20 +13,20 @@ namespace SherpaOnnx
13 { 13 {
14 public KeywordSpotter(KeywordSpotterConfig config) 14 public KeywordSpotter(KeywordSpotterConfig config)
15 { 15 {
16 - IntPtr h = CreateKeywordSpotter(ref config); 16 + IntPtr h = SherpaOnnxCreateKeywordSpotter(ref config);
17 _handle = new HandleRef(this, h); 17 _handle = new HandleRef(this, h);
18 } 18 }
19 19
20 public OnlineStream CreateStream() 20 public OnlineStream CreateStream()
21 { 21 {
22 - IntPtr p = CreateKeywordStream(_handle.Handle); 22 + IntPtr p = SherpaOnnxCreateKeywordStream(_handle.Handle);
23 return new OnlineStream(p); 23 return new OnlineStream(p);
24 } 24 }
25 25
26 public OnlineStream CreateStream(string keywords) 26 public OnlineStream CreateStream(string keywords)
27 { 27 {
28 byte[] utf8Bytes = Encoding.UTF8.GetBytes(keywords); 28 byte[] utf8Bytes = Encoding.UTF8.GetBytes(keywords);
29 - IntPtr p = CreateKeywordStreamWithKeywords(_handle.Handle, utf8Bytes); 29 + IntPtr p = SherpaOnnxCreateKeywordStreamWithKeywords(_handle.Handle, utf8Bytes);
30 return new OnlineStream(p); 30 return new OnlineStream(p);
31 } 31 }
32 32
@@ -81,7 +81,7 @@ namespace SherpaOnnx @@ -81,7 +81,7 @@ namespace SherpaOnnx
81 81
82 private void Cleanup() 82 private void Cleanup()
83 { 83 {
84 - DestroyKeywordSpotter(_handle.Handle); 84 + SherpaOnnxDestroyKeywordSpotter(_handle.Handle);
85 85
86 // Don't permit the handle to be used again. 86 // Don't permit the handle to be used again.
87 _handle = new HandleRef(this, IntPtr.Zero); 87 _handle = new HandleRef(this, IntPtr.Zero);
@@ -90,30 +90,30 @@ namespace SherpaOnnx @@ -90,30 +90,30 @@ namespace SherpaOnnx
90 private HandleRef _handle; 90 private HandleRef _handle;
91 91
92 [DllImport(Dll.Filename)] 92 [DllImport(Dll.Filename)]
93 - private static extern IntPtr CreateKeywordSpotter(ref KeywordSpotterConfig config); 93 + private static extern IntPtr SherpaOnnxCreateKeywordSpotter(ref KeywordSpotterConfig config);
94 94
95 [DllImport(Dll.Filename)] 95 [DllImport(Dll.Filename)]
96 - private static extern void DestroyKeywordSpotter(IntPtr handle); 96 + private static extern void SherpaOnnxDestroyKeywordSpotter(IntPtr handle);
97 97
98 [DllImport(Dll.Filename)] 98 [DllImport(Dll.Filename)]
99 - private static extern IntPtr CreateKeywordStream(IntPtr handle); 99 + private static extern IntPtr SherpaOnnxCreateKeywordStream(IntPtr handle);
100 100
101 [DllImport(Dll.Filename)] 101 [DllImport(Dll.Filename)]
102 - private static extern IntPtr CreateKeywordStreamWithKeywords(IntPtr handle, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] byte[] utf8Keywords); 102 + private static extern IntPtr SherpaOnnxCreateKeywordStreamWithKeywords(IntPtr handle, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] byte[] utf8Keywords);
103 103
104 - [DllImport(Dll.Filename, EntryPoint = "IsKeywordStreamReady")] 104 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxIsKeywordStreamReady")]
105 private static extern int IsReady(IntPtr handle, IntPtr stream); 105 private static extern int IsReady(IntPtr handle, IntPtr stream);
106 106
107 - [DllImport(Dll.Filename, EntryPoint = "DecodeKeywordStream")] 107 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeKeywordStream")]
108 private static extern void Decode(IntPtr handle, IntPtr stream); 108 private static extern void Decode(IntPtr handle, IntPtr stream);
109 109
110 - [DllImport(Dll.Filename, EntryPoint = "DecodeMultipleKeywordStreams")] 110 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeMultipleKeywordStreams")]
111 private static extern void Decode(IntPtr handle, IntPtr[] streams, int n); 111 private static extern void Decode(IntPtr handle, IntPtr[] streams, int n);
112 112
113 - [DllImport(Dll.Filename, EntryPoint = "GetKeywordResult")] 113 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxGetKeywordResult")]
114 private static extern IntPtr GetResult(IntPtr handle, IntPtr stream); 114 private static extern IntPtr GetResult(IntPtr handle, IntPtr stream);
115 115
116 - [DllImport(Dll.Filename, EntryPoint = "DestroyKeywordResult")] 116 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDestroyKeywordResult")]
117 private static extern void DestroyResult(IntPtr result); 117 private static extern void DestroyResult(IntPtr result);
118 } 118 }
119 } 119 }
@@ -10,13 +10,13 @@ namespace SherpaOnnx @@ -10,13 +10,13 @@ namespace SherpaOnnx
10 { 10 {
11 public OfflineRecognizer(OfflineRecognizerConfig config) 11 public OfflineRecognizer(OfflineRecognizerConfig config)
12 { 12 {
13 - IntPtr h = CreateOfflineRecognizer(ref config); 13 + IntPtr h = SherpaOnnxCreateOfflineRecognizer(ref config);
14 _handle = new HandleRef(this, h); 14 _handle = new HandleRef(this, h);
15 } 15 }
16 16
17 public OfflineStream CreateStream() 17 public OfflineStream CreateStream()
18 { 18 {
19 - IntPtr p = CreateOfflineStream(_handle.Handle); 19 + IntPtr p = SherpaOnnxCreateOfflineStream(_handle.Handle);
20 return new OfflineStream(p); 20 return new OfflineStream(p);
21 } 21 }
22 22
@@ -54,7 +54,7 @@ namespace SherpaOnnx @@ -54,7 +54,7 @@ namespace SherpaOnnx
54 54
55 private void Cleanup() 55 private void Cleanup()
56 { 56 {
57 - DestroyOfflineRecognizer(_handle.Handle); 57 + SherpaOnnxDestroyOfflineRecognizer(_handle.Handle);
58 58
59 // Don't permit the handle to be used again. 59 // Don't permit the handle to be used again.
60 _handle = new HandleRef(this, IntPtr.Zero); 60 _handle = new HandleRef(this, IntPtr.Zero);
@@ -63,18 +63,18 @@ namespace SherpaOnnx @@ -63,18 +63,18 @@ namespace SherpaOnnx
63 private HandleRef _handle; 63 private HandleRef _handle;
64 64
65 [DllImport(Dll.Filename)] 65 [DllImport(Dll.Filename)]
66 - private static extern IntPtr CreateOfflineRecognizer(ref OfflineRecognizerConfig config); 66 + private static extern IntPtr SherpaOnnxCreateOfflineRecognizer(ref OfflineRecognizerConfig config);
67 67
68 [DllImport(Dll.Filename)] 68 [DllImport(Dll.Filename)]
69 - private static extern void DestroyOfflineRecognizer(IntPtr handle); 69 + private static extern void SherpaOnnxDestroyOfflineRecognizer(IntPtr handle);
70 70
71 [DllImport(Dll.Filename)] 71 [DllImport(Dll.Filename)]
72 - private static extern IntPtr CreateOfflineStream(IntPtr handle); 72 + private static extern IntPtr SherpaOnnxCreateOfflineStream(IntPtr handle);
73 73
74 - [DllImport(Dll.Filename, EntryPoint = "DecodeOfflineStream")] 74 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeOfflineStream")]
75 private static extern void Decode(IntPtr handle, IntPtr stream); 75 private static extern void Decode(IntPtr handle, IntPtr stream);
76 76
77 - [DllImport(Dll.Filename, EntryPoint = "DecodeMultipleOfflineStreams")] 77 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeMultipleOfflineStreams")]
78 private static extern void Decode(IntPtr handle, IntPtr[] streams, int n); 78 private static extern void Decode(IntPtr handle, IntPtr[] streams, int n);
79 } 79 }
80 80
@@ -44,7 +44,7 @@ namespace SherpaOnnx @@ -44,7 +44,7 @@ namespace SherpaOnnx
44 44
45 private void Cleanup() 45 private void Cleanup()
46 { 46 {
47 - DestroyOfflineStream(Handle); 47 + SherpaOnnxDestroyOfflineStream(Handle);
48 48
49 // Don't permit the handle to be used again. 49 // Don't permit the handle to be used again.
50 _handle = new HandleRef(this, IntPtr.Zero); 50 _handle = new HandleRef(this, IntPtr.Zero);
@@ -54,15 +54,15 @@ namespace SherpaOnnx @@ -54,15 +54,15 @@ namespace SherpaOnnx
54 public IntPtr Handle => _handle.Handle; 54 public IntPtr Handle => _handle.Handle;
55 55
56 [DllImport(Dll.Filename)] 56 [DllImport(Dll.Filename)]
57 - private static extern void DestroyOfflineStream(IntPtr handle); 57 + private static extern void SherpaOnnxDestroyOfflineStream(IntPtr handle);
58 58
59 - [DllImport(Dll.Filename, EntryPoint = "AcceptWaveformOffline")] 59 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxAcceptWaveformOffline")]
60 private static extern void AcceptWaveform(IntPtr handle, int sampleRate, float[] samples, int n); 60 private static extern void AcceptWaveform(IntPtr handle, int sampleRate, float[] samples, int n);
61 61
62 - [DllImport(Dll.Filename, EntryPoint = "GetOfflineStreamResult")] 62 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxGetOfflineStreamResult")]
63 private static extern IntPtr GetResult(IntPtr handle); 63 private static extern IntPtr GetResult(IntPtr handle);
64 64
65 - [DllImport(Dll.Filename, EntryPoint = "DestroyOfflineRecognizerResult")] 65 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDestroyOfflineRecognizerResult")]
66 private static extern void DestroyResult(IntPtr handle); 66 private static extern void DestroyResult(IntPtr handle);
67 } 67 }
68 68
@@ -14,13 +14,13 @@ namespace SherpaOnnx @@ -14,13 +14,13 @@ namespace SherpaOnnx
14 { 14 {
15 public OnlineRecognizer(OnlineRecognizerConfig config) 15 public OnlineRecognizer(OnlineRecognizerConfig config)
16 { 16 {
17 - IntPtr h = CreateOnlineRecognizer(ref config); 17 + IntPtr h = SherpaOnnxCreateOnlineRecognizer(ref config);
18 _handle = new HandleRef(this, h); 18 _handle = new HandleRef(this, h);
19 } 19 }
20 20
21 public OnlineStream CreateStream() 21 public OnlineStream CreateStream()
22 { 22 {
23 - IntPtr p = CreateOnlineStream(_handle.Handle); 23 + IntPtr p = SherpaOnnxCreateOnlineStream(_handle.Handle);
24 return new OnlineStream(p); 24 return new OnlineStream(p);
25 } 25 }
26 26
@@ -35,7 +35,7 @@ namespace SherpaOnnx @@ -35,7 +35,7 @@ namespace SherpaOnnx
35 /// true. 35 /// true.
36 public bool IsEndpoint(OnlineStream stream) 36 public bool IsEndpoint(OnlineStream stream)
37 { 37 {
38 - return IsEndpoint(_handle.Handle, stream.Handle) != 0; 38 + return SherpaOnnxOnlineStreamIsEndpoint(_handle.Handle, stream.Handle) != 0;
39 } 39 }
40 40
41 /// You have to ensure that IsReady(stream) returns true before 41 /// You have to ensure that IsReady(stream) returns true before
@@ -71,7 +71,7 @@ namespace SherpaOnnx @@ -71,7 +71,7 @@ namespace SherpaOnnx
71 /// When this method returns, IsEndpoint(stream) will return false. 71 /// When this method returns, IsEndpoint(stream) will return false.
72 public void Reset(OnlineStream stream) 72 public void Reset(OnlineStream stream)
73 { 73 {
74 - Reset(_handle.Handle, stream.Handle); 74 + SherpaOnnxOnlineStreamReset(_handle.Handle, stream.Handle);
75 } 75 }
76 76
77 public void Dispose() 77 public void Dispose()
@@ -89,7 +89,7 @@ namespace SherpaOnnx @@ -89,7 +89,7 @@ namespace SherpaOnnx
89 89
90 private void Cleanup() 90 private void Cleanup()
91 { 91 {
92 - DestroyOnlineRecognizer(_handle.Handle); 92 + SherpaOnnxDestroyOnlineRecognizer(_handle.Handle);
93 93
94 // Don't permit the handle to be used again. 94 // Don't permit the handle to be used again.
95 _handle = new HandleRef(this, IntPtr.Zero); 95 _handle = new HandleRef(this, IntPtr.Zero);
@@ -98,33 +98,33 @@ namespace SherpaOnnx @@ -98,33 +98,33 @@ namespace SherpaOnnx
98 private HandleRef _handle; 98 private HandleRef _handle;
99 99
100 [DllImport(Dll.Filename)] 100 [DllImport(Dll.Filename)]
101 - private static extern IntPtr CreateOnlineRecognizer(ref OnlineRecognizerConfig config); 101 + private static extern IntPtr SherpaOnnxCreateOnlineRecognizer(ref OnlineRecognizerConfig config);
102 102
103 [DllImport(Dll.Filename)] 103 [DllImport(Dll.Filename)]
104 - private static extern void DestroyOnlineRecognizer(IntPtr handle); 104 + private static extern void SherpaOnnxDestroyOnlineRecognizer(IntPtr handle);
105 105
106 [DllImport(Dll.Filename)] 106 [DllImport(Dll.Filename)]
107 - private static extern IntPtr CreateOnlineStream(IntPtr handle); 107 + private static extern IntPtr SherpaOnnxCreateOnlineStream(IntPtr handle);
108 108
109 - [DllImport(Dll.Filename, EntryPoint = "IsOnlineStreamReady")] 109 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxIsOnlineStreamReady")]
110 private static extern int IsReady(IntPtr handle, IntPtr stream); 110 private static extern int IsReady(IntPtr handle, IntPtr stream);
111 111
112 - [DllImport(Dll.Filename, EntryPoint = "DecodeOnlineStream")] 112 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeOnlineStream")]
113 private static extern void Decode(IntPtr handle, IntPtr stream); 113 private static extern void Decode(IntPtr handle, IntPtr stream);
114 114
115 - [DllImport(Dll.Filename, EntryPoint = "DecodeMultipleOnlineStreams")] 115 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDecodeMultipleOnlineStreams")]
116 private static extern void Decode(IntPtr handle, IntPtr[] streams, int n); 116 private static extern void Decode(IntPtr handle, IntPtr[] streams, int n);
117 117
118 - [DllImport(Dll.Filename, EntryPoint = "GetOnlineStreamResult")] 118 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxGetOnlineStreamResult")]
119 private static extern IntPtr GetResult(IntPtr handle, IntPtr stream); 119 private static extern IntPtr GetResult(IntPtr handle, IntPtr stream);
120 120
121 - [DllImport(Dll.Filename, EntryPoint = "DestroyOnlineRecognizerResult")] 121 + [DllImport(Dll.Filename, EntryPoint = "SherpaOnnxDestroyOnlineRecognizerResult")]
122 private static extern void DestroyResult(IntPtr result); 122 private static extern void DestroyResult(IntPtr result);
123 123
124 [DllImport(Dll.Filename)] 124 [DllImport(Dll.Filename)]
125 - private static extern void Reset(IntPtr handle, IntPtr stream); 125 + private static extern void SherpaOnnxOnlineStreamReset(IntPtr handle, IntPtr stream);
126 126
127 [DllImport(Dll.Filename)] 127 [DllImport(Dll.Filename)]
128 - private static extern int IsEndpoint(IntPtr handle, IntPtr stream); 128 + private static extern int SherpaOnnxOnlineStreamIsEndpoint(IntPtr handle, IntPtr stream);
129 } 129 }
130 } 130 }
@@ -16,12 +16,12 @@ namespace SherpaOnnx @@ -16,12 +16,12 @@ namespace SherpaOnnx
16 16
17 public void AcceptWaveform(int sampleRate, float[] samples) 17 public void AcceptWaveform(int sampleRate, float[] samples)
18 { 18 {
19 - AcceptWaveform(Handle, sampleRate, samples, samples.Length); 19 + SherpaOnnxOnlineStreamAcceptWaveform(Handle, sampleRate, samples, samples.Length);
20 } 20 }
21 21
22 public void InputFinished() 22 public void InputFinished()
23 { 23 {
24 - InputFinished(Handle); 24 + SherpaOnnxOnlineStreamInputFinished(Handle);
25 } 25 }
26 26
27 ~OnlineStream() 27 ~OnlineStream()
@@ -39,7 +39,7 @@ namespace SherpaOnnx @@ -39,7 +39,7 @@ namespace SherpaOnnx
39 39
40 private void Cleanup() 40 private void Cleanup()
41 { 41 {
42 - DestroyOnlineStream(Handle); 42 + SherpaOnnxDestroyOnlineStream(Handle);
43 43
44 // Don't permit the handle to be used again. 44 // Don't permit the handle to be used again.
45 _handle = new HandleRef(this, IntPtr.Zero); 45 _handle = new HandleRef(this, IntPtr.Zero);
@@ -49,13 +49,13 @@ namespace SherpaOnnx @@ -49,13 +49,13 @@ namespace SherpaOnnx
49 public IntPtr Handle => _handle.Handle; 49 public IntPtr Handle => _handle.Handle;
50 50
51 [DllImport(Dll.Filename)] 51 [DllImport(Dll.Filename)]
52 - private static extern void DestroyOnlineStream(IntPtr handle); 52 + private static extern void SherpaOnnxDestroyOnlineStream(IntPtr handle);
53 53
54 [DllImport(Dll.Filename)] 54 [DllImport(Dll.Filename)]
55 - private static extern void AcceptWaveform(IntPtr handle, int sampleRate, float[] samples, int n); 55 + private static extern void SherpaOnnxOnlineStreamAcceptWaveform(IntPtr handle, int sampleRate, float[] samples, int n);
56 56
57 [DllImport(Dll.Filename)] 57 [DllImport(Dll.Filename)]
58 - private static extern void InputFinished(IntPtr handle); 58 + private static extern void SherpaOnnxOnlineStreamInputFinished(IntPtr handle);
59 } 59 }
60 60
61 } 61 }
@@ -151,7 +151,7 @@ type OnlineStream struct { @@ -151,7 +151,7 @@ type OnlineStream struct {
151 151
152 // Free the internal pointer inside the recognizer to avoid memory leak. 152 // Free the internal pointer inside the recognizer to avoid memory leak.
153 func DeleteOnlineRecognizer(recognizer *OnlineRecognizer) { 153 func DeleteOnlineRecognizer(recognizer *OnlineRecognizer) {
154 - C.DestroyOnlineRecognizer(recognizer.impl) 154 + C.SherpaOnnxDestroyOnlineRecognizer(recognizer.impl)
155 recognizer.impl = nil 155 recognizer.impl = nil
156 } 156 }
157 157
@@ -224,14 +224,14 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer { @@ -224,14 +224,14 @@ func NewOnlineRecognizer(config *OnlineRecognizerConfig) *OnlineRecognizer {
224 c.ctc_fst_decoder_config.max_active = C.int(config.CtcFstDecoderConfig.MaxActive) 224 c.ctc_fst_decoder_config.max_active = C.int(config.CtcFstDecoderConfig.MaxActive)
225 225
226 recognizer := &OnlineRecognizer{} 226 recognizer := &OnlineRecognizer{}
227 - recognizer.impl = C.CreateOnlineRecognizer(&c) 227 + recognizer.impl = C.SherpaOnnxCreateOnlineRecognizer(&c)
228 228
229 return recognizer 229 return recognizer
230 } 230 }
231 231
232 // Delete the internal pointer inside the stream to avoid memory leak. 232 // Delete the internal pointer inside the stream to avoid memory leak.
233 func DeleteOnlineStream(stream *OnlineStream) { 233 func DeleteOnlineStream(stream *OnlineStream) {
234 - C.DestroyOnlineStream(stream.impl) 234 + C.SherpaOnnxDestroyOnlineStream(stream.impl)
235 stream.impl = nil 235 stream.impl = nil
236 } 236 }
237 237
@@ -239,7 +239,7 @@ func DeleteOnlineStream(stream *OnlineStream) { @@ -239,7 +239,7 @@ func DeleteOnlineStream(stream *OnlineStream) {
239 // the returned stream to avoid memory leak 239 // the returned stream to avoid memory leak
240 func NewOnlineStream(recognizer *OnlineRecognizer) *OnlineStream { 240 func NewOnlineStream(recognizer *OnlineRecognizer) *OnlineStream {
241 stream := &OnlineStream{} 241 stream := &OnlineStream{}
242 - stream.impl = C.CreateOnlineStream(recognizer.impl) 242 + stream.impl = C.SherpaOnnxCreateOnlineStream(recognizer.impl)
243 return stream 243 return stream
244 } 244 }
245 245
@@ -251,7 +251,7 @@ func NewOnlineStream(recognizer *OnlineRecognizer) *OnlineStream { @@ -251,7 +251,7 @@ func NewOnlineStream(recognizer *OnlineRecognizer) *OnlineStream {
251 // 251 //
252 // samples contains audio samples. Each sample is in the range [-1, 1] 252 // samples contains audio samples. Each sample is in the range [-1, 1]
253 func (s *OnlineStream) AcceptWaveform(sampleRate int, samples []float32) { 253 func (s *OnlineStream) AcceptWaveform(sampleRate int, samples []float32) {
254 - C.AcceptWaveform(s.impl, C.int(sampleRate), (*C.float)(&samples[0]), C.int(len(samples))) 254 + C.SherpaOnnxOnlineStreamAcceptWaveform(s.impl, C.int(sampleRate), (*C.float)(&samples[0]), C.int(len(samples)))
255 } 255 }
256 256
257 // Signal that there will be no incoming audio samples. 257 // Signal that there will be no incoming audio samples.
@@ -260,7 +260,7 @@ func (s *OnlineStream) AcceptWaveform(sampleRate int, samples []float32) { @@ -260,7 +260,7 @@ func (s *OnlineStream) AcceptWaveform(sampleRate int, samples []float32) {
260 // The main purpose of this function is to flush the remaining audio samples 260 // The main purpose of this function is to flush the remaining audio samples
261 // buffered inside for feature extraction. 261 // buffered inside for feature extraction.
262 func (s *OnlineStream) InputFinished() { 262 func (s *OnlineStream) InputFinished() {
263 - C.InputFinished(s.impl) 263 + C.SherpaOnnxOnlineStreamInputFinished(s.impl)
264 } 264 }
265 265
266 // Check whether the stream has enough feature frames for decoding. 266 // Check whether the stream has enough feature frames for decoding.
@@ -272,7 +272,7 @@ func (s *OnlineStream) InputFinished() { @@ -272,7 +272,7 @@ func (s *OnlineStream) InputFinished() {
272 // recognizer.Decode(s) 272 // recognizer.Decode(s)
273 // } 273 // }
274 func (recognizer *OnlineRecognizer) IsReady(s *OnlineStream) bool { 274 func (recognizer *OnlineRecognizer) IsReady(s *OnlineStream) bool {
275 - return C.IsOnlineStreamReady(recognizer.impl, s.impl) == 1 275 + return C.SherpaOnnxIsOnlineStreamReady(recognizer.impl, s.impl) == 1
276 } 276 }
277 277
278 // Return true if an endpoint is detected. 278 // Return true if an endpoint is detected.
@@ -285,14 +285,14 @@ func (recognizer *OnlineRecognizer) IsReady(s *OnlineStream) bool { @@ -285,14 +285,14 @@ func (recognizer *OnlineRecognizer) IsReady(s *OnlineStream) bool {
285 // recognizer.Reset(s) 285 // recognizer.Reset(s)
286 // } 286 // }
287 func (recognizer *OnlineRecognizer) IsEndpoint(s *OnlineStream) bool { 287 func (recognizer *OnlineRecognizer) IsEndpoint(s *OnlineStream) bool {
288 - return C.IsEndpoint(recognizer.impl, s.impl) == 1 288 + return C.SherpaOnnxOnlineStreamIsEndpoint(recognizer.impl, s.impl) == 1
289 } 289 }
290 290
291 // After calling this function, the internal neural network model states 291 // After calling this function, the internal neural network model states
292 // are reset and IsEndpoint(s) would return false. GetResult(s) would also 292 // are reset and IsEndpoint(s) would return false. GetResult(s) would also
293 // return an empty string. 293 // return an empty string.
294 func (recognizer *OnlineRecognizer) Reset(s *OnlineStream) { 294 func (recognizer *OnlineRecognizer) Reset(s *OnlineStream) {
295 - C.Reset(recognizer.impl, s.impl) 295 + C.SherpaOnnxOnlineStreamReset(recognizer.impl, s.impl)
296 } 296 }
297 297
298 // Decode the stream. Before calling this function, you have to ensure 298 // Decode the stream. Before calling this function, you have to ensure
@@ -304,7 +304,7 @@ func (recognizer *OnlineRecognizer) Reset(s *OnlineStream) { @@ -304,7 +304,7 @@ func (recognizer *OnlineRecognizer) Reset(s *OnlineStream) {
304 // recognizer.Decode(s) 304 // recognizer.Decode(s)
305 // } 305 // }
306 func (recognizer *OnlineRecognizer) Decode(s *OnlineStream) { 306 func (recognizer *OnlineRecognizer) Decode(s *OnlineStream) {
307 - C.DecodeOnlineStream(recognizer.impl, s.impl) 307 + C.SherpaOnnxDecodeOnlineStream(recognizer.impl, s.impl)
308 } 308 }
309 309
310 // Decode multiple streams in parallel, i.e., in batch. 310 // Decode multiple streams in parallel, i.e., in batch.
@@ -316,13 +316,13 @@ func (recognizer *OnlineRecognizer) DecodeStreams(s []*OnlineStream) { @@ -316,13 +316,13 @@ func (recognizer *OnlineRecognizer) DecodeStreams(s []*OnlineStream) {
316 ss[i] = v.impl 316 ss[i] = v.impl
317 } 317 }
318 318
319 - C.DecodeMultipleOnlineStreams(recognizer.impl, &ss[0], C.int(len(s))) 319 + C.SherpaOnnxDecodeMultipleOnlineStreams(recognizer.impl, &ss[0], C.int(len(s)))
320 } 320 }
321 321
322 // Get the current result of stream since the last invoke of Reset() 322 // Get the current result of stream since the last invoke of Reset()
323 func (recognizer *OnlineRecognizer) GetResult(s *OnlineStream) *OnlineRecognizerResult { 323 func (recognizer *OnlineRecognizer) GetResult(s *OnlineStream) *OnlineRecognizerResult {
324 - p := C.GetOnlineStreamResult(recognizer.impl, s.impl)  
325 - defer C.DestroyOnlineRecognizerResult(p) 324 + p := C.SherpaOnnxGetOnlineStreamResult(recognizer.impl, s.impl)
  325 + defer C.SherpaOnnxDestroyOnlineRecognizerResult(p)
326 result := &OnlineRecognizerResult{} 326 result := &OnlineRecognizerResult{}
327 result.Text = C.GoString(p.text) 327 result.Text = C.GoString(p.text)
328 328
@@ -442,7 +442,7 @@ type OfflineRecognizerResult struct { @@ -442,7 +442,7 @@ type OfflineRecognizerResult struct {
442 442
443 // Frees the internal pointer of the recognition to avoid memory leak. 443 // Frees the internal pointer of the recognition to avoid memory leak.
444 func DeleteOfflineRecognizer(recognizer *OfflineRecognizer) { 444 func DeleteOfflineRecognizer(recognizer *OfflineRecognizer) {
445 - C.DestroyOfflineRecognizer(recognizer.impl) 445 + C.SherpaOnnxDestroyOfflineRecognizer(recognizer.impl)
446 recognizer.impl = nil 446 recognizer.impl = nil
447 } 447 }
448 448
@@ -537,14 +537,14 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer { @@ -537,14 +537,14 @@ func NewOfflineRecognizer(config *OfflineRecognizerConfig) *OfflineRecognizer {
537 defer C.free(unsafe.Pointer(c.rule_fars)) 537 defer C.free(unsafe.Pointer(c.rule_fars))
538 538
539 recognizer := &OfflineRecognizer{} 539 recognizer := &OfflineRecognizer{}
540 - recognizer.impl = C.CreateOfflineRecognizer(&c) 540 + recognizer.impl = C.SherpaOnnxCreateOfflineRecognizer(&c)
541 541
542 return recognizer 542 return recognizer
543 } 543 }
544 544
545 // Frees the internal pointer of the stream to avoid memory leak. 545 // Frees the internal pointer of the stream to avoid memory leak.
546 func DeleteOfflineStream(stream *OfflineStream) { 546 func DeleteOfflineStream(stream *OfflineStream) {
547 - C.DestroyOfflineStream(stream.impl) 547 + C.SherpaOnnxDestroyOfflineStream(stream.impl)
548 stream.impl = nil 548 stream.impl = nil
549 } 549 }
550 550
@@ -552,7 +552,7 @@ func DeleteOfflineStream(stream *OfflineStream) { @@ -552,7 +552,7 @@ func DeleteOfflineStream(stream *OfflineStream) {
552 // the returned stream to avoid memory leak 552 // the returned stream to avoid memory leak
553 func NewOfflineStream(recognizer *OfflineRecognizer) *OfflineStream { 553 func NewOfflineStream(recognizer *OfflineRecognizer) *OfflineStream {
554 stream := &OfflineStream{} 554 stream := &OfflineStream{}
555 - stream.impl = C.CreateOfflineStream(recognizer.impl) 555 + stream.impl = C.SherpaOnnxCreateOfflineStream(recognizer.impl)
556 return stream 556 return stream
557 } 557 }
558 558
@@ -564,12 +564,12 @@ func NewOfflineStream(recognizer *OfflineRecognizer) *OfflineStream { @@ -564,12 +564,12 @@ func NewOfflineStream(recognizer *OfflineRecognizer) *OfflineStream {
564 // 564 //
565 // samples contains the actual audio samples. Each sample is in the range [-1, 1]. 565 // samples contains the actual audio samples. Each sample is in the range [-1, 1].
566 func (s *OfflineStream) AcceptWaveform(sampleRate int, samples []float32) { 566 func (s *OfflineStream) AcceptWaveform(sampleRate int, samples []float32) {
567 - C.AcceptWaveformOffline(s.impl, C.int(sampleRate), (*C.float)(&samples[0]), C.int(len(samples))) 567 + C.SherpaOnnxAcceptWaveformOffline(s.impl, C.int(sampleRate), (*C.float)(&samples[0]), C.int(len(samples)))
568 } 568 }
569 569
570 // Decode the offline stream. 570 // Decode the offline stream.
571 func (recognizer *OfflineRecognizer) Decode(s *OfflineStream) { 571 func (recognizer *OfflineRecognizer) Decode(s *OfflineStream) {
572 - C.DecodeOfflineStream(recognizer.impl, s.impl) 572 + C.SherpaOnnxDecodeOfflineStream(recognizer.impl, s.impl)
573 } 573 }
574 574
575 // Decode multiple streams in parallel, i.e., in batch. 575 // Decode multiple streams in parallel, i.e., in batch.
@@ -579,13 +579,13 @@ func (recognizer *OfflineRecognizer) DecodeStreams(s []*OfflineStream) { @@ -579,13 +579,13 @@ func (recognizer *OfflineRecognizer) DecodeStreams(s []*OfflineStream) {
579 ss[i] = v.impl 579 ss[i] = v.impl
580 } 580 }
581 581
582 - C.DecodeMultipleOfflineStreams(recognizer.impl, &ss[0], C.int(len(s))) 582 + C.SherpaOnnxDecodeMultipleOfflineStreams(recognizer.impl, &ss[0], C.int(len(s)))
583 } 583 }
584 584
585 // Get the recognition result of the offline stream. 585 // Get the recognition result of the offline stream.
586 func (s *OfflineStream) GetResult() *OfflineRecognizerResult { 586 func (s *OfflineStream) GetResult() *OfflineRecognizerResult {
587 - p := C.GetOfflineStreamResult(s.impl)  
588 - defer C.DestroyOfflineRecognizerResult(p) 587 + p := C.SherpaOnnxGetOfflineStreamResult(s.impl)
  588 + defer C.SherpaOnnxDestroyOfflineRecognizerResult(p)
589 result := &OfflineRecognizerResult{} 589 result := &OfflineRecognizerResult{}
590 result.Text = C.GoString(p.text) 590 result.Text = C.GoString(p.text)
591 591
@@ -141,7 +141,7 @@ AudioTaggingCreateOfflineStreamWrapper(const Napi::CallbackInfo &info) { @@ -141,7 +141,7 @@ AudioTaggingCreateOfflineStreamWrapper(const Napi::CallbackInfo &info) {
141 return Napi::External<SherpaOnnxOfflineStream>::New( 141 return Napi::External<SherpaOnnxOfflineStream>::New(
142 env, const_cast<SherpaOnnxOfflineStream *>(stream), 142 env, const_cast<SherpaOnnxOfflineStream *>(stream),
143 [](Napi::Env env, SherpaOnnxOfflineStream *stream) { 143 [](Napi::Env env, SherpaOnnxOfflineStream *stream) {
144 - DestroyOfflineStream(stream); 144 + SherpaOnnxDestroyOfflineStream(stream);
145 }); 145 });
146 } 146 }
147 147
@@ -44,7 +44,7 @@ static Napi::External<SherpaOnnxKeywordSpotter> CreateKeywordSpotterWrapper( @@ -44,7 +44,7 @@ static Napi::External<SherpaOnnxKeywordSpotter> CreateKeywordSpotterWrapper(
44 SHERPA_ONNX_ASSIGN_ATTR_FLOAT(keywords_threshold, keywordsThreshold); 44 SHERPA_ONNX_ASSIGN_ATTR_FLOAT(keywords_threshold, keywordsThreshold);
45 SHERPA_ONNX_ASSIGN_ATTR_STR(keywords_file, keywordsFile); 45 SHERPA_ONNX_ASSIGN_ATTR_STR(keywords_file, keywordsFile);
46 46
47 - SherpaOnnxKeywordSpotter *kws = CreateKeywordSpotter(&c); 47 + SherpaOnnxKeywordSpotter *kws = SherpaOnnxCreateKeywordSpotter(&c);
48 48
49 if (c.model_config.transducer.encoder) { 49 if (c.model_config.transducer.encoder) {
50 delete[] c.model_config.transducer.encoder; 50 delete[] c.model_config.transducer.encoder;
@@ -95,7 +95,7 @@ static Napi::External<SherpaOnnxKeywordSpotter> CreateKeywordSpotterWrapper( @@ -95,7 +95,7 @@ static Napi::External<SherpaOnnxKeywordSpotter> CreateKeywordSpotterWrapper(
95 95
96 return Napi::External<SherpaOnnxKeywordSpotter>::New( 96 return Napi::External<SherpaOnnxKeywordSpotter>::New(
97 env, kws, [](Napi::Env env, SherpaOnnxKeywordSpotter *kws) { 97 env, kws, [](Napi::Env env, SherpaOnnxKeywordSpotter *kws) {
98 - DestroyKeywordSpotter(kws); 98 + SherpaOnnxDestroyKeywordSpotter(kws);
99 }); 99 });
100 } 100 }
101 101
@@ -122,11 +122,11 @@ static Napi::External<SherpaOnnxOnlineStream> CreateKeywordStreamWrapper( @@ -122,11 +122,11 @@ static Napi::External<SherpaOnnxOnlineStream> CreateKeywordStreamWrapper(
122 SherpaOnnxKeywordSpotter *kws = 122 SherpaOnnxKeywordSpotter *kws =
123 info[0].As<Napi::External<SherpaOnnxKeywordSpotter>>().Data(); 123 info[0].As<Napi::External<SherpaOnnxKeywordSpotter>>().Data();
124 124
125 - SherpaOnnxOnlineStream *stream = CreateKeywordStream(kws); 125 + SherpaOnnxOnlineStream *stream = SherpaOnnxCreateKeywordStream(kws);
126 126
127 return Napi::External<SherpaOnnxOnlineStream>::New( 127 return Napi::External<SherpaOnnxOnlineStream>::New(
128 env, stream, [](Napi::Env env, SherpaOnnxOnlineStream *stream) { 128 env, stream, [](Napi::Env env, SherpaOnnxOnlineStream *stream) {
129 - DestroyOnlineStream(stream); 129 + SherpaOnnxDestroyOnlineStream(stream);
130 }); 130 });
131 } 131 }
132 132
@@ -162,7 +162,7 @@ static Napi::Boolean IsKeywordStreamReadyWrapper( @@ -162,7 +162,7 @@ static Napi::Boolean IsKeywordStreamReadyWrapper(
162 SherpaOnnxOnlineStream *stream = 162 SherpaOnnxOnlineStream *stream =
163 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 163 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
164 164
165 - int32_t is_ready = IsKeywordStreamReady(kws, stream); 165 + int32_t is_ready = SherpaOnnxIsKeywordStreamReady(kws, stream);
166 166
167 return Napi::Boolean::New(env, is_ready); 167 return Napi::Boolean::New(env, is_ready);
168 } 168 }
@@ -198,7 +198,7 @@ static void DecodeKeywordStreamWrapper(const Napi::CallbackInfo &info) { @@ -198,7 +198,7 @@ static void DecodeKeywordStreamWrapper(const Napi::CallbackInfo &info) {
198 SherpaOnnxOnlineStream *stream = 198 SherpaOnnxOnlineStream *stream =
199 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 199 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
200 200
201 - DecodeKeywordStream(kws, stream); 201 + SherpaOnnxDecodeKeywordStream(kws, stream);
202 } 202 }
203 203
204 static Napi::String GetKeywordResultAsJsonWrapper( 204 static Napi::String GetKeywordResultAsJsonWrapper(
@@ -233,11 +233,11 @@ static Napi::String GetKeywordResultAsJsonWrapper( @@ -233,11 +233,11 @@ static Napi::String GetKeywordResultAsJsonWrapper(
233 SherpaOnnxOnlineStream *stream = 233 SherpaOnnxOnlineStream *stream =
234 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 234 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
235 235
236 - const char *json = GetKeywordResultAsJson(kws, stream); 236 + const char *json = SherpaOnnxGetKeywordResultAsJson(kws, stream);
237 237
238 Napi::String s = Napi::String::New(env, json); 238 Napi::String s = Napi::String::New(env, json);
239 239
240 - FreeKeywordResultJson(json); 240 + SherpaOnnxFreeKeywordResultJson(json);
241 241
242 return s; 242 return s;
243 } 243 }
@@ -202,7 +202,8 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) { @@ -202,7 +202,8 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) {
202 SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fsts, ruleFsts); 202 SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fsts, ruleFsts);
203 SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fars, ruleFars); 203 SHERPA_ONNX_ASSIGN_ATTR_STR(rule_fars, ruleFars);
204 204
205 - SherpaOnnxOfflineRecognizer *recognizer = CreateOfflineRecognizer(&c); 205 + SherpaOnnxOfflineRecognizer *recognizer =
  206 + SherpaOnnxCreateOfflineRecognizer(&c);
206 207
207 if (c.model_config.transducer.encoder) { 208 if (c.model_config.transducer.encoder) {
208 delete[] c.model_config.transducer.encoder; 209 delete[] c.model_config.transducer.encoder;
@@ -306,7 +307,7 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) { @@ -306,7 +307,7 @@ CreateOfflineRecognizerWrapper(const Napi::CallbackInfo &info) {
306 return Napi::External<SherpaOnnxOfflineRecognizer>::New( 307 return Napi::External<SherpaOnnxOfflineRecognizer>::New(
307 env, recognizer, 308 env, recognizer,
308 [](Napi::Env env, SherpaOnnxOfflineRecognizer *recognizer) { 309 [](Napi::Env env, SherpaOnnxOfflineRecognizer *recognizer) {
309 - DestroyOfflineRecognizer(recognizer); 310 + SherpaOnnxDestroyOfflineRecognizer(recognizer);
310 }); 311 });
311 } 312 }
312 313
@@ -334,11 +335,11 @@ static Napi::External<SherpaOnnxOfflineStream> CreateOfflineStreamWrapper( @@ -334,11 +335,11 @@ static Napi::External<SherpaOnnxOfflineStream> CreateOfflineStreamWrapper(
334 SherpaOnnxOfflineRecognizer *recognizer = 335 SherpaOnnxOfflineRecognizer *recognizer =
335 info[0].As<Napi::External<SherpaOnnxOfflineRecognizer>>().Data(); 336 info[0].As<Napi::External<SherpaOnnxOfflineRecognizer>>().Data();
336 337
337 - SherpaOnnxOfflineStream *stream = CreateOfflineStream(recognizer); 338 + SherpaOnnxOfflineStream *stream = SherpaOnnxCreateOfflineStream(recognizer);
338 339
339 return Napi::External<SherpaOnnxOfflineStream>::New( 340 return Napi::External<SherpaOnnxOfflineStream>::New(
340 env, stream, [](Napi::Env env, SherpaOnnxOfflineStream *stream) { 341 env, stream, [](Napi::Env env, SherpaOnnxOfflineStream *stream) {
341 - DestroyOfflineStream(stream); 342 + SherpaOnnxDestroyOfflineStream(stream);
342 }); 343 });
343 } 344 }
344 345
@@ -405,8 +406,8 @@ static void AcceptWaveformOfflineWrapper(const Napi::CallbackInfo &info) { @@ -405,8 +406,8 @@ static void AcceptWaveformOfflineWrapper(const Napi::CallbackInfo &info) {
405 Napi::Float32Array samples = obj.Get("samples").As<Napi::Float32Array>(); 406 Napi::Float32Array samples = obj.Get("samples").As<Napi::Float32Array>();
406 int32_t sample_rate = obj.Get("sampleRate").As<Napi::Number>().Int32Value(); 407 int32_t sample_rate = obj.Get("sampleRate").As<Napi::Number>().Int32Value();
407 408
408 - AcceptWaveformOffline(stream, sample_rate, samples.Data(),  
409 - samples.ElementLength()); 409 + SherpaOnnxAcceptWaveformOffline(stream, sample_rate, samples.Data(),
  410 + samples.ElementLength());
410 } 411 }
411 412
412 static void DecodeOfflineStreamWrapper(const Napi::CallbackInfo &info) { 413 static void DecodeOfflineStreamWrapper(const Napi::CallbackInfo &info) {
@@ -441,7 +442,7 @@ static void DecodeOfflineStreamWrapper(const Napi::CallbackInfo &info) { @@ -441,7 +442,7 @@ static void DecodeOfflineStreamWrapper(const Napi::CallbackInfo &info) {
441 SherpaOnnxOfflineStream *stream = 442 SherpaOnnxOfflineStream *stream =
442 info[1].As<Napi::External<SherpaOnnxOfflineStream>>().Data(); 443 info[1].As<Napi::External<SherpaOnnxOfflineStream>>().Data();
443 444
444 - DecodeOfflineStream(recognizer, stream); 445 + SherpaOnnxDecodeOfflineStream(recognizer, stream);
445 } 446 }
446 447
447 static Napi::String GetOfflineStreamResultAsJsonWrapper( 448 static Napi::String GetOfflineStreamResultAsJsonWrapper(
@@ -466,10 +467,10 @@ static Napi::String GetOfflineStreamResultAsJsonWrapper( @@ -466,10 +467,10 @@ static Napi::String GetOfflineStreamResultAsJsonWrapper(
466 SherpaOnnxOfflineStream *stream = 467 SherpaOnnxOfflineStream *stream =
467 info[0].As<Napi::External<SherpaOnnxOfflineStream>>().Data(); 468 info[0].As<Napi::External<SherpaOnnxOfflineStream>>().Data();
468 469
469 - const char *json = GetOfflineStreamResultAsJson(stream); 470 + const char *json = SherpaOnnxGetOfflineStreamResultAsJson(stream);
470 Napi::String s = Napi::String::New(env, json); 471 Napi::String s = Napi::String::New(env, json);
471 472
472 - DestroyOfflineStreamResultJson(json); 473 + SherpaOnnxDestroyOfflineStreamResultJson(json);
473 474
474 return s; 475 return s;
475 } 476 }
@@ -130,7 +130,7 @@ SpeakerEmbeddingExtractorCreateStreamWrapper(const Napi::CallbackInfo &info) { @@ -130,7 +130,7 @@ SpeakerEmbeddingExtractorCreateStreamWrapper(const Napi::CallbackInfo &info) {
130 return Napi::External<SherpaOnnxOnlineStream>::New( 130 return Napi::External<SherpaOnnxOnlineStream>::New(
131 env, const_cast<SherpaOnnxOnlineStream *>(stream), 131 env, const_cast<SherpaOnnxOnlineStream *>(stream),
132 [](Napi::Env env, SherpaOnnxOnlineStream *stream) { 132 [](Napi::Env env, SherpaOnnxOnlineStream *stream) {
133 - DestroyOnlineStream(stream); 133 + SherpaOnnxDestroyOnlineStream(stream);
134 }); 134 });
135 } 135 }
136 136
@@ -124,7 +124,7 @@ SpokenLanguageIdentificationCreateOfflineStreamWrapper( @@ -124,7 +124,7 @@ SpokenLanguageIdentificationCreateOfflineStreamWrapper(
124 124
125 return Napi::External<SherpaOnnxOfflineStream>::New( 125 return Napi::External<SherpaOnnxOfflineStream>::New(
126 env, stream, [](Napi::Env env, SherpaOnnxOfflineStream *stream) { 126 env, stream, [](Napi::Env env, SherpaOnnxOfflineStream *stream) {
127 - DestroyOfflineStream(stream); 127 + SherpaOnnxDestroyOfflineStream(stream);
128 }); 128 });
129 } 129 }
130 130
@@ -194,7 +194,7 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper( @@ -194,7 +194,7 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
194 194
195 c.ctc_fst_decoder_config = GetCtcFstDecoderConfig(o); 195 c.ctc_fst_decoder_config = GetCtcFstDecoderConfig(o);
196 196
197 - SherpaOnnxOnlineRecognizer *recognizer = CreateOnlineRecognizer(&c); 197 + SherpaOnnxOnlineRecognizer *recognizer = SherpaOnnxCreateOnlineRecognizer(&c);
198 198
199 if (c.model_config.transducer.encoder) { 199 if (c.model_config.transducer.encoder) {
200 delete[] c.model_config.transducer.encoder; 200 delete[] c.model_config.transducer.encoder;
@@ -270,7 +270,7 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper( @@ -270,7 +270,7 @@ static Napi::External<SherpaOnnxOnlineRecognizer> CreateOnlineRecognizerWrapper(
270 return Napi::External<SherpaOnnxOnlineRecognizer>::New( 270 return Napi::External<SherpaOnnxOnlineRecognizer>::New(
271 env, recognizer, 271 env, recognizer,
272 [](Napi::Env env, SherpaOnnxOnlineRecognizer *recognizer) { 272 [](Napi::Env env, SherpaOnnxOnlineRecognizer *recognizer) {
273 - DestroyOnlineRecognizer(recognizer); 273 + SherpaOnnxDestroyOnlineRecognizer(recognizer);
274 }); 274 });
275 } 275 }
276 276
@@ -298,11 +298,11 @@ static Napi::External<SherpaOnnxOnlineStream> CreateOnlineStreamWrapper( @@ -298,11 +298,11 @@ static Napi::External<SherpaOnnxOnlineStream> CreateOnlineStreamWrapper(
298 SherpaOnnxOnlineRecognizer *recognizer = 298 SherpaOnnxOnlineRecognizer *recognizer =
299 info[0].As<Napi::External<SherpaOnnxOnlineRecognizer>>().Data(); 299 info[0].As<Napi::External<SherpaOnnxOnlineRecognizer>>().Data();
300 300
301 - SherpaOnnxOnlineStream *stream = CreateOnlineStream(recognizer); 301 + SherpaOnnxOnlineStream *stream = SherpaOnnxCreateOnlineStream(recognizer);
302 302
303 return Napi::External<SherpaOnnxOnlineStream>::New( 303 return Napi::External<SherpaOnnxOnlineStream>::New(
304 env, stream, [](Napi::Env env, SherpaOnnxOnlineStream *stream) { 304 env, stream, [](Napi::Env env, SherpaOnnxOnlineStream *stream) {
305 - DestroyOnlineStream(stream); 305 + SherpaOnnxDestroyOnlineStream(stream);
306 }); 306 });
307 } 307 }
308 308
@@ -369,7 +369,8 @@ static void AcceptWaveformWrapper(const Napi::CallbackInfo &info) { @@ -369,7 +369,8 @@ static void AcceptWaveformWrapper(const Napi::CallbackInfo &info) {
369 Napi::Float32Array samples = obj.Get("samples").As<Napi::Float32Array>(); 369 Napi::Float32Array samples = obj.Get("samples").As<Napi::Float32Array>();
370 int32_t sample_rate = obj.Get("sampleRate").As<Napi::Number>().Int32Value(); 370 int32_t sample_rate = obj.Get("sampleRate").As<Napi::Number>().Int32Value();
371 371
372 - AcceptWaveform(stream, sample_rate, samples.Data(), samples.ElementLength()); 372 + SherpaOnnxOnlineStreamAcceptWaveform(stream, sample_rate, samples.Data(),
  373 + samples.ElementLength());
373 } 374 }
374 375
375 static Napi::Boolean IsOnlineStreamReadyWrapper( 376 static Napi::Boolean IsOnlineStreamReadyWrapper(
@@ -405,7 +406,7 @@ static Napi::Boolean IsOnlineStreamReadyWrapper( @@ -405,7 +406,7 @@ static Napi::Boolean IsOnlineStreamReadyWrapper(
405 SherpaOnnxOnlineStream *stream = 406 SherpaOnnxOnlineStream *stream =
406 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 407 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
407 408
408 - int32_t is_ready = IsOnlineStreamReady(recognizer, stream); 409 + int32_t is_ready = SherpaOnnxIsOnlineStreamReady(recognizer, stream);
409 410
410 return Napi::Boolean::New(env, is_ready); 411 return Napi::Boolean::New(env, is_ready);
411 } 412 }
@@ -442,7 +443,7 @@ static void DecodeOnlineStreamWrapper(const Napi::CallbackInfo &info) { @@ -442,7 +443,7 @@ static void DecodeOnlineStreamWrapper(const Napi::CallbackInfo &info) {
442 SherpaOnnxOnlineStream *stream = 443 SherpaOnnxOnlineStream *stream =
443 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 444 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
444 445
445 - DecodeOnlineStream(recognizer, stream); 446 + SherpaOnnxDecodeOnlineStream(recognizer, stream);
446 } 447 }
447 448
448 static Napi::String GetOnlineStreamResultAsJsonWrapper( 449 static Napi::String GetOnlineStreamResultAsJsonWrapper(
@@ -478,10 +479,10 @@ static Napi::String GetOnlineStreamResultAsJsonWrapper( @@ -478,10 +479,10 @@ static Napi::String GetOnlineStreamResultAsJsonWrapper(
478 SherpaOnnxOnlineStream *stream = 479 SherpaOnnxOnlineStream *stream =
479 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 480 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
480 481
481 - const char *json = GetOnlineStreamResultAsJson(recognizer, stream); 482 + const char *json = SherpaOnnxGetOnlineStreamResultAsJson(recognizer, stream);
482 Napi::String s = Napi::String::New(env, json); 483 Napi::String s = Napi::String::New(env, json);
483 484
484 - DestroyOnlineStreamResultJson(json); 485 + SherpaOnnxDestroyOnlineStreamResultJson(json);
485 486
486 return s; 487 return s;
487 } 488 }
@@ -508,7 +509,7 @@ static void InputFinishedWrapper(const Napi::CallbackInfo &info) { @@ -508,7 +509,7 @@ static void InputFinishedWrapper(const Napi::CallbackInfo &info) {
508 SherpaOnnxOnlineStream *stream = 509 SherpaOnnxOnlineStream *stream =
509 info[0].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 510 info[0].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
510 511
511 - InputFinished(stream); 512 + SherpaOnnxOnlineStreamInputFinished(stream);
512 } 513 }
513 514
514 static void ResetOnlineStreamWrapper(const Napi::CallbackInfo &info) { 515 static void ResetOnlineStreamWrapper(const Napi::CallbackInfo &info) {
@@ -543,7 +544,7 @@ static void ResetOnlineStreamWrapper(const Napi::CallbackInfo &info) { @@ -543,7 +544,7 @@ static void ResetOnlineStreamWrapper(const Napi::CallbackInfo &info) {
543 SherpaOnnxOnlineStream *stream = 544 SherpaOnnxOnlineStream *stream =
544 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 545 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
545 546
546 - Reset(recognizer, stream); 547 + SherpaOnnxOnlineStreamReset(recognizer, stream);
547 } 548 }
548 549
549 static Napi::Boolean IsEndpointWrapper(const Napi::CallbackInfo &info) { 550 static Napi::Boolean IsEndpointWrapper(const Napi::CallbackInfo &info) {
@@ -578,7 +579,7 @@ static Napi::Boolean IsEndpointWrapper(const Napi::CallbackInfo &info) { @@ -578,7 +579,7 @@ static Napi::Boolean IsEndpointWrapper(const Napi::CallbackInfo &info) {
578 SherpaOnnxOnlineStream *stream = 579 SherpaOnnxOnlineStream *stream =
579 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data(); 580 info[1].As<Napi::External<SherpaOnnxOnlineStream>>().Data();
580 581
581 - int32_t is_endpoint = IsEndpoint(recognizer, stream); 582 + int32_t is_endpoint = SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream);
582 583
583 return Napi::Boolean::New(env, is_endpoint); 584 return Napi::Boolean::New(env, is_endpoint);
584 } 585 }
@@ -603,12 +604,12 @@ static Napi::External<SherpaOnnxDisplay> CreateDisplayWrapper( @@ -603,12 +604,12 @@ static Napi::External<SherpaOnnxDisplay> CreateDisplayWrapper(
603 } 604 }
604 int32_t max_word_per_line = info[0].As<Napi::Number>().Int32Value(); 605 int32_t max_word_per_line = info[0].As<Napi::Number>().Int32Value();
605 606
606 - const SherpaOnnxDisplay *display = CreateDisplay(max_word_per_line); 607 + const SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(max_word_per_line);
607 608
608 return Napi::External<SherpaOnnxDisplay>::New( 609 return Napi::External<SherpaOnnxDisplay>::New(
609 env, const_cast<SherpaOnnxDisplay *>(display), 610 env, const_cast<SherpaOnnxDisplay *>(display),
610 [](Napi::Env env, SherpaOnnxDisplay *display) { 611 [](Napi::Env env, SherpaOnnxDisplay *display) {
611 - DestroyDisplay(display); 612 + SherpaOnnxDestroyDisplay(display);
612 }); 613 });
613 } 614 }
614 615
@@ -45,7 +45,7 @@ struct SherpaOnnxDisplay { @@ -45,7 +45,7 @@ struct SherpaOnnxDisplay {
45 45
46 #define SHERPA_ONNX_OR(x, y) (x ? x : y) 46 #define SHERPA_ONNX_OR(x, y) (x ? x : y)
47 47
48 -SherpaOnnxOnlineRecognizer *CreateOnlineRecognizer( 48 +SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer(
49 const SherpaOnnxOnlineRecognizerConfig *config) { 49 const SherpaOnnxOnlineRecognizerConfig *config) {
50 sherpa_onnx::OnlineRecognizerConfig recognizer_config; 50 sherpa_onnx::OnlineRecognizerConfig recognizer_config;
51 51
@@ -130,46 +130,49 @@ SherpaOnnxOnlineRecognizer *CreateOnlineRecognizer( @@ -130,46 +130,49 @@ SherpaOnnxOnlineRecognizer *CreateOnlineRecognizer(
130 return recognizer; 130 return recognizer;
131 } 131 }
132 132
133 -void DestroyOnlineRecognizer(const SherpaOnnxOnlineRecognizer *recognizer) { 133 +void SherpaOnnxDestroyOnlineRecognizer(
  134 + const SherpaOnnxOnlineRecognizer *recognizer) {
134 delete recognizer; 135 delete recognizer;
135 } 136 }
136 137
137 -SherpaOnnxOnlineStream *CreateOnlineStream( 138 +SherpaOnnxOnlineStream *SherpaOnnxCreateOnlineStream(
138 const SherpaOnnxOnlineRecognizer *recognizer) { 139 const SherpaOnnxOnlineRecognizer *recognizer) {
139 SherpaOnnxOnlineStream *stream = 140 SherpaOnnxOnlineStream *stream =
140 new SherpaOnnxOnlineStream(recognizer->impl->CreateStream()); 141 new SherpaOnnxOnlineStream(recognizer->impl->CreateStream());
141 return stream; 142 return stream;
142 } 143 }
143 144
144 -SherpaOnnxOnlineStream *CreateOnlineStreamWithHotwords( 145 +SherpaOnnxOnlineStream *SherpaOnnxCreateOnlineStreamWithHotwords(
145 const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords) { 146 const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords) {
146 SherpaOnnxOnlineStream *stream = 147 SherpaOnnxOnlineStream *stream =
147 new SherpaOnnxOnlineStream(recognizer->impl->CreateStream(hotwords)); 148 new SherpaOnnxOnlineStream(recognizer->impl->CreateStream(hotwords));
148 return stream; 149 return stream;
149 } 150 }
150 151
151 -void DestroyOnlineStream(const SherpaOnnxOnlineStream *stream) { 152 +void SherpaOnnxDestroyOnlineStream(const SherpaOnnxOnlineStream *stream) {
152 delete stream; 153 delete stream;
153 } 154 }
154 155
155 -void AcceptWaveform(const SherpaOnnxOnlineStream *stream, int32_t sample_rate,  
156 - const float *samples, int32_t n) { 156 +void SherpaOnnxOnlineStreamAcceptWaveform(const SherpaOnnxOnlineStream *stream,
  157 + int32_t sample_rate,
  158 + const float *samples, int32_t n) {
157 stream->impl->AcceptWaveform(sample_rate, samples, n); 159 stream->impl->AcceptWaveform(sample_rate, samples, n);
158 } 160 }
159 161
160 -int32_t IsOnlineStreamReady(const SherpaOnnxOnlineRecognizer *recognizer,  
161 - const SherpaOnnxOnlineStream *stream) { 162 +int32_t SherpaOnnxIsOnlineStreamReady(
  163 + const SherpaOnnxOnlineRecognizer *recognizer,
  164 + const SherpaOnnxOnlineStream *stream) {
162 return recognizer->impl->IsReady(stream->impl.get()); 165 return recognizer->impl->IsReady(stream->impl.get());
163 } 166 }
164 167
165 -void DecodeOnlineStream(const SherpaOnnxOnlineRecognizer *recognizer,  
166 - const SherpaOnnxOnlineStream *stream) { 168 +void SherpaOnnxDecodeOnlineStream(const SherpaOnnxOnlineRecognizer *recognizer,
  169 + const SherpaOnnxOnlineStream *stream) {
167 recognizer->impl->DecodeStream(stream->impl.get()); 170 recognizer->impl->DecodeStream(stream->impl.get());
168 } 171 }
169 172
170 -void DecodeMultipleOnlineStreams(const SherpaOnnxOnlineRecognizer *recognizer,  
171 - const SherpaOnnxOnlineStream **streams,  
172 - int32_t n) { 173 +void SherpaOnnxDecodeMultipleOnlineStreams(
  174 + const SherpaOnnxOnlineRecognizer *recognizer,
  175 + const SherpaOnnxOnlineStream **streams, int32_t n) {
173 std::vector<sherpa_onnx::OnlineStream *> ss(n); 176 std::vector<sherpa_onnx::OnlineStream *> ss(n);
174 for (int32_t i = 0; i != n; ++i) { 177 for (int32_t i = 0; i != n; ++i) {
175 ss[i] = streams[i]->impl.get(); 178 ss[i] = streams[i]->impl.get();
@@ -177,7 +180,7 @@ void DecodeMultipleOnlineStreams(const SherpaOnnxOnlineRecognizer *recognizer, @@ -177,7 +180,7 @@ void DecodeMultipleOnlineStreams(const SherpaOnnxOnlineRecognizer *recognizer,
177 recognizer->impl->DecodeStreams(ss.data(), n); 180 recognizer->impl->DecodeStreams(ss.data(), n);
178 } 181 }
179 182
180 -const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult( 183 +const SherpaOnnxOnlineRecognizerResult *SherpaOnnxGetOnlineStreamResult(
181 const SherpaOnnxOnlineRecognizer *recognizer, 184 const SherpaOnnxOnlineRecognizer *recognizer,
182 const SherpaOnnxOnlineStream *stream) { 185 const SherpaOnnxOnlineStream *stream) {
183 sherpa_onnx::OnlineRecognizerResult result = 186 sherpa_onnx::OnlineRecognizerResult result =
@@ -241,7 +244,8 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult( @@ -241,7 +244,8 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult(
241 return r; 244 return r;
242 } 245 }
243 246
244 -void DestroyOnlineRecognizerResult(const SherpaOnnxOnlineRecognizerResult *r) { 247 +void SherpaOnnxDestroyOnlineRecognizerResult(
  248 + const SherpaOnnxOnlineRecognizerResult *r) {
245 if (r) { 249 if (r) {
246 delete[] r->text; 250 delete[] r->text;
247 delete[] r->json; 251 delete[] r->json;
@@ -252,7 +256,7 @@ void DestroyOnlineRecognizerResult(const SherpaOnnxOnlineRecognizerResult *r) { @@ -252,7 +256,7 @@ void DestroyOnlineRecognizerResult(const SherpaOnnxOnlineRecognizerResult *r) {
252 } 256 }
253 } 257 }
254 258
255 -const char *GetOnlineStreamResultAsJson( 259 +const char *SherpaOnnxGetOnlineStreamResultAsJson(
256 const SherpaOnnxOnlineRecognizer *recognizer, 260 const SherpaOnnxOnlineRecognizer *recognizer,
257 const SherpaOnnxOnlineStream *stream) { 261 const SherpaOnnxOnlineStream *stream) {
258 sherpa_onnx::OnlineRecognizerResult result = 262 sherpa_onnx::OnlineRecognizerResult result =
@@ -264,29 +268,32 @@ const char *GetOnlineStreamResultAsJson( @@ -264,29 +268,32 @@ const char *GetOnlineStreamResultAsJson(
264 return pJson; 268 return pJson;
265 } 269 }
266 270
267 -void DestroyOnlineStreamResultJson(const char *s) { delete[] s; } 271 +void SherpaOnnxDestroyOnlineStreamResultJson(const char *s) { delete[] s; }
268 272
269 -void Reset(const SherpaOnnxOnlineRecognizer *recognizer,  
270 - const SherpaOnnxOnlineStream *stream) { 273 +void SherpaOnnxOnlineStreamReset(const SherpaOnnxOnlineRecognizer *recognizer,
  274 + const SherpaOnnxOnlineStream *stream) {
271 recognizer->impl->Reset(stream->impl.get()); 275 recognizer->impl->Reset(stream->impl.get());
272 } 276 }
273 277
274 -void InputFinished(const SherpaOnnxOnlineStream *stream) { 278 +void SherpaOnnxOnlineStreamInputFinished(const SherpaOnnxOnlineStream *stream) {
275 stream->impl->InputFinished(); 279 stream->impl->InputFinished();
276 } 280 }
277 281
278 -int32_t IsEndpoint(const SherpaOnnxOnlineRecognizer *recognizer,  
279 - const SherpaOnnxOnlineStream *stream) { 282 +int32_t SherpaOnnxOnlineStreamIsEndpoint(
  283 + const SherpaOnnxOnlineRecognizer *recognizer,
  284 + const SherpaOnnxOnlineStream *stream) {
280 return recognizer->impl->IsEndpoint(stream->impl.get()); 285 return recognizer->impl->IsEndpoint(stream->impl.get());
281 } 286 }
282 287
283 -const SherpaOnnxDisplay *CreateDisplay(int32_t max_word_per_line) { 288 +const SherpaOnnxDisplay *SherpaOnnxCreateDisplay(int32_t max_word_per_line) {
284 SherpaOnnxDisplay *ans = new SherpaOnnxDisplay; 289 SherpaOnnxDisplay *ans = new SherpaOnnxDisplay;
285 ans->impl = std::make_unique<sherpa_onnx::Display>(max_word_per_line); 290 ans->impl = std::make_unique<sherpa_onnx::Display>(max_word_per_line);
286 return ans; 291 return ans;
287 } 292 }
288 293
289 -void DestroyDisplay(const SherpaOnnxDisplay *display) { delete display; } 294 +void SherpaOnnxDestroyDisplay(const SherpaOnnxDisplay *display) {
  295 + delete display;
  296 +}
290 297
291 void SherpaOnnxPrint(const SherpaOnnxDisplay *display, int32_t idx, 298 void SherpaOnnxPrint(const SherpaOnnxDisplay *display, int32_t idx,
292 const char *s) { 299 const char *s) {
@@ -311,7 +318,7 @@ struct SherpaOnnxOfflineStream { @@ -311,7 +318,7 @@ struct SherpaOnnxOfflineStream {
311 static sherpa_onnx::OfflineRecognizerConfig convertConfig( 318 static sherpa_onnx::OfflineRecognizerConfig convertConfig(
312 const SherpaOnnxOfflineRecognizerConfig *config); 319 const SherpaOnnxOfflineRecognizerConfig *config);
313 320
314 -SherpaOnnxOfflineRecognizer *CreateOfflineRecognizer( 321 +SherpaOnnxOfflineRecognizer *SherpaOnnxCreateOfflineRecognizer(
315 const SherpaOnnxOfflineRecognizerConfig *config) { 322 const SherpaOnnxOfflineRecognizerConfig *config) {
316 sherpa_onnx::OfflineRecognizerConfig recognizer_config = 323 sherpa_onnx::OfflineRecognizerConfig recognizer_config =
317 convertConfig(config); 324 convertConfig(config);
@@ -438,35 +445,37 @@ void SherpaOnnxOfflineRecognizerSetConfig( @@ -438,35 +445,37 @@ void SherpaOnnxOfflineRecognizerSetConfig(
438 recognizer->impl->SetConfig(recognizer_config); 445 recognizer->impl->SetConfig(recognizer_config);
439 } 446 }
440 447
441 -void DestroyOfflineRecognizer(SherpaOnnxOfflineRecognizer *recognizer) { 448 +void SherpaOnnxDestroyOfflineRecognizer(
  449 + SherpaOnnxOfflineRecognizer *recognizer) {
442 delete recognizer; 450 delete recognizer;
443 } 451 }
444 452
445 -SherpaOnnxOfflineStream *CreateOfflineStream( 453 +SherpaOnnxOfflineStream *SherpaOnnxCreateOfflineStream(
446 const SherpaOnnxOfflineRecognizer *recognizer) { 454 const SherpaOnnxOfflineRecognizer *recognizer) {
447 SherpaOnnxOfflineStream *stream = 455 SherpaOnnxOfflineStream *stream =
448 new SherpaOnnxOfflineStream(recognizer->impl->CreateStream()); 456 new SherpaOnnxOfflineStream(recognizer->impl->CreateStream());
449 return stream; 457 return stream;
450 } 458 }
451 459
452 -void DestroyOfflineStream(const SherpaOnnxOfflineStream *stream) { 460 +void SherpaOnnxDestroyOfflineStream(const SherpaOnnxOfflineStream *stream) {
453 delete stream; 461 delete stream;
454 } 462 }
455 463
456 -void AcceptWaveformOffline(const SherpaOnnxOfflineStream *stream,  
457 - int32_t sample_rate, const float *samples,  
458 - int32_t n) { 464 +void SherpaOnnxAcceptWaveformOffline(const SherpaOnnxOfflineStream *stream,
  465 + int32_t sample_rate, const float *samples,
  466 + int32_t n) {
459 stream->impl->AcceptWaveform(sample_rate, samples, n); 467 stream->impl->AcceptWaveform(sample_rate, samples, n);
460 } 468 }
461 469
462 -void DecodeOfflineStream(const SherpaOnnxOfflineRecognizer *recognizer,  
463 - const SherpaOnnxOfflineStream *stream) { 470 +void SherpaOnnxDecodeOfflineStream(
  471 + const SherpaOnnxOfflineRecognizer *recognizer,
  472 + const SherpaOnnxOfflineStream *stream) {
464 recognizer->impl->DecodeStream(stream->impl.get()); 473 recognizer->impl->DecodeStream(stream->impl.get());
465 } 474 }
466 475
467 -void DecodeMultipleOfflineStreams(SherpaOnnxOfflineRecognizer *recognizer,  
468 - SherpaOnnxOfflineStream **streams,  
469 - int32_t n) { 476 +void SherpaOnnxDecodeMultipleOfflineStreams(
  477 + SherpaOnnxOfflineRecognizer *recognizer, SherpaOnnxOfflineStream **streams,
  478 + int32_t n) {
470 std::vector<sherpa_onnx::OfflineStream *> ss(n); 479 std::vector<sherpa_onnx::OfflineStream *> ss(n);
471 for (int32_t i = 0; i != n; ++i) { 480 for (int32_t i = 0; i != n; ++i) {
472 ss[i] = streams[i]->impl.get(); 481 ss[i] = streams[i]->impl.get();
@@ -474,7 +483,7 @@ void DecodeMultipleOfflineStreams(SherpaOnnxOfflineRecognizer *recognizer, @@ -474,7 +483,7 @@ void DecodeMultipleOfflineStreams(SherpaOnnxOfflineRecognizer *recognizer,
474 recognizer->impl->DecodeStreams(ss.data(), n); 483 recognizer->impl->DecodeStreams(ss.data(), n);
475 } 484 }
476 485
477 -const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult( 486 +const SherpaOnnxOfflineRecognizerResult *SherpaOnnxGetOfflineStreamResult(
478 const SherpaOnnxOfflineStream *stream) { 487 const SherpaOnnxOfflineStream *stream) {
479 const sherpa_onnx::OfflineRecognitionResult &result = 488 const sherpa_onnx::OfflineRecognitionResult &result =
480 stream->impl->GetResult(); 489 stream->impl->GetResult();
@@ -543,7 +552,7 @@ const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult( @@ -543,7 +552,7 @@ const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult(
543 return r; 552 return r;
544 } 553 }
545 554
546 -void DestroyOfflineRecognizerResult( 555 +void SherpaOnnxDestroyOfflineRecognizerResult(
547 const SherpaOnnxOfflineRecognizerResult *r) { 556 const SherpaOnnxOfflineRecognizerResult *r) {
548 if (r) { 557 if (r) {
549 delete[] r->text; 558 delete[] r->text;
@@ -556,7 +565,7 @@ void DestroyOfflineRecognizerResult( @@ -556,7 +565,7 @@ void DestroyOfflineRecognizerResult(
556 } 565 }
557 } 566 }
558 567
559 -const char *GetOfflineStreamResultAsJson( 568 +const char *SherpaOnnxGetOfflineStreamResultAsJson(
560 const SherpaOnnxOfflineStream *stream) { 569 const SherpaOnnxOfflineStream *stream) {
561 const sherpa_onnx::OfflineRecognitionResult &result = 570 const sherpa_onnx::OfflineRecognitionResult &result =
562 stream->impl->GetResult(); 571 stream->impl->GetResult();
@@ -567,7 +576,7 @@ const char *GetOfflineStreamResultAsJson( @@ -567,7 +576,7 @@ const char *GetOfflineStreamResultAsJson(
567 return pJson; 576 return pJson;
568 } 577 }
569 578
570 -void DestroyOfflineStreamResultJson(const char *s) { delete[] s; } 579 +void SherpaOnnxDestroyOfflineStreamResultJson(const char *s) { delete[] s; }
571 580
572 // ============================================================ 581 // ============================================================
573 // For Keyword Spot 582 // For Keyword Spot
@@ -577,7 +586,7 @@ struct SherpaOnnxKeywordSpotter { @@ -577,7 +586,7 @@ struct SherpaOnnxKeywordSpotter {
577 std::unique_ptr<sherpa_onnx::KeywordSpotter> impl; 586 std::unique_ptr<sherpa_onnx::KeywordSpotter> impl;
578 }; 587 };
579 588
580 -SherpaOnnxKeywordSpotter *CreateKeywordSpotter( 589 +SherpaOnnxKeywordSpotter *SherpaOnnxCreateKeywordSpotter(
581 const SherpaOnnxKeywordSpotterConfig *config) { 590 const SherpaOnnxKeywordSpotterConfig *config) {
582 sherpa_onnx::KeywordSpotterConfig spotter_config; 591 sherpa_onnx::KeywordSpotterConfig spotter_config;
583 592
@@ -640,36 +649,37 @@ SherpaOnnxKeywordSpotter *CreateKeywordSpotter( @@ -640,36 +649,37 @@ SherpaOnnxKeywordSpotter *CreateKeywordSpotter(
640 return spotter; 649 return spotter;
641 } 650 }
642 651
643 -void DestroyKeywordSpotter(SherpaOnnxKeywordSpotter *spotter) { 652 +void SherpaOnnxDestroyKeywordSpotter(SherpaOnnxKeywordSpotter *spotter) {
644 delete spotter; 653 delete spotter;
645 } 654 }
646 655
647 -SherpaOnnxOnlineStream *CreateKeywordStream( 656 +SherpaOnnxOnlineStream *SherpaOnnxCreateKeywordStream(
648 const SherpaOnnxKeywordSpotter *spotter) { 657 const SherpaOnnxKeywordSpotter *spotter) {
649 SherpaOnnxOnlineStream *stream = 658 SherpaOnnxOnlineStream *stream =
650 new SherpaOnnxOnlineStream(spotter->impl->CreateStream()); 659 new SherpaOnnxOnlineStream(spotter->impl->CreateStream());
651 return stream; 660 return stream;
652 } 661 }
653 662
654 -SherpaOnnxOnlineStream *CreateKeywordStreamWithKeywords( 663 +SherpaOnnxOnlineStream *SherpaOnnxCreateKeywordStreamWithKeywords(
655 const SherpaOnnxKeywordSpotter *spotter, const char *keywords) { 664 const SherpaOnnxKeywordSpotter *spotter, const char *keywords) {
656 SherpaOnnxOnlineStream *stream = 665 SherpaOnnxOnlineStream *stream =
657 new SherpaOnnxOnlineStream(spotter->impl->CreateStream(keywords)); 666 new SherpaOnnxOnlineStream(spotter->impl->CreateStream(keywords));
658 return stream; 667 return stream;
659 } 668 }
660 669
661 -int32_t IsKeywordStreamReady(SherpaOnnxKeywordSpotter *spotter,  
662 - SherpaOnnxOnlineStream *stream) { 670 +int32_t SherpaOnnxIsKeywordStreamReady(SherpaOnnxKeywordSpotter *spotter,
  671 + SherpaOnnxOnlineStream *stream) {
663 return spotter->impl->IsReady(stream->impl.get()); 672 return spotter->impl->IsReady(stream->impl.get());
664 } 673 }
665 674
666 -void DecodeKeywordStream(SherpaOnnxKeywordSpotter *spotter,  
667 - SherpaOnnxOnlineStream *stream) { 675 +void SherpaOnnxDecodeKeywordStream(SherpaOnnxKeywordSpotter *spotter,
  676 + SherpaOnnxOnlineStream *stream) {
668 return spotter->impl->DecodeStream(stream->impl.get()); 677 return spotter->impl->DecodeStream(stream->impl.get());
669 } 678 }
670 679
671 -void DecodeMultipleKeywordStreams(SherpaOnnxKeywordSpotter *spotter,  
672 - SherpaOnnxOnlineStream **streams, int32_t n) { 680 +void SherpaOnnxDecodeMultipleKeywordStreams(SherpaOnnxKeywordSpotter *spotter,
  681 + SherpaOnnxOnlineStream **streams,
  682 + int32_t n) {
673 std::vector<sherpa_onnx::OnlineStream *> ss(n); 683 std::vector<sherpa_onnx::OnlineStream *> ss(n);
674 for (int32_t i = 0; i != n; ++i) { 684 for (int32_t i = 0; i != n; ++i) {
675 ss[i] = streams[i]->impl.get(); 685 ss[i] = streams[i]->impl.get();
@@ -677,7 +687,7 @@ void DecodeMultipleKeywordStreams(SherpaOnnxKeywordSpotter *spotter, @@ -677,7 +687,7 @@ void DecodeMultipleKeywordStreams(SherpaOnnxKeywordSpotter *spotter,
677 spotter->impl->DecodeStreams(ss.data(), n); 687 spotter->impl->DecodeStreams(ss.data(), n);
678 } 688 }
679 689
680 -const SherpaOnnxKeywordResult *GetKeywordResult( 690 +const SherpaOnnxKeywordResult *SherpaOnnxGetKeywordResult(
681 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream) { 691 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream) {
682 const sherpa_onnx::KeywordResult &result = 692 const sherpa_onnx::KeywordResult &result =
683 spotter->impl->GetResult(stream->impl.get()); 693 spotter->impl->GetResult(stream->impl.get());
@@ -742,7 +752,7 @@ const SherpaOnnxKeywordResult *GetKeywordResult( @@ -742,7 +752,7 @@ const SherpaOnnxKeywordResult *GetKeywordResult(
742 return r; 752 return r;
743 } 753 }
744 754
745 -void DestroyKeywordResult(const SherpaOnnxKeywordResult *r) { 755 +void SherpaOnnxDestroyKeywordResult(const SherpaOnnxKeywordResult *r) {
746 if (r) { 756 if (r) {
747 delete[] r->keyword; 757 delete[] r->keyword;
748 delete[] r->json; 758 delete[] r->json;
@@ -753,8 +763,8 @@ void DestroyKeywordResult(const SherpaOnnxKeywordResult *r) { @@ -753,8 +763,8 @@ void DestroyKeywordResult(const SherpaOnnxKeywordResult *r) {
753 } 763 }
754 } 764 }
755 765
756 -const char *GetKeywordResultAsJson(SherpaOnnxKeywordSpotter *spotter,  
757 - SherpaOnnxOnlineStream *stream) { 766 +const char *SherpaOnnxGetKeywordResultAsJson(SherpaOnnxKeywordSpotter *spotter,
  767 + SherpaOnnxOnlineStream *stream) {
758 const sherpa_onnx::KeywordResult &result = 768 const sherpa_onnx::KeywordResult &result =
759 spotter->impl->GetResult(stream->impl.get()); 769 spotter->impl->GetResult(stream->impl.get());
760 770
@@ -765,7 +775,7 @@ const char *GetKeywordResultAsJson(SherpaOnnxKeywordSpotter *spotter, @@ -765,7 +775,7 @@ const char *GetKeywordResultAsJson(SherpaOnnxKeywordSpotter *spotter,
765 return pJson; 775 return pJson;
766 } 776 }
767 777
768 -void FreeKeywordResultJson(const char *s) { delete[] s; } 778 +void SherpaOnnxFreeKeywordResultJson(const char *s) { delete[] s; }
769 779
770 // ============================================================ 780 // ============================================================
771 // For VAD 781 // For VAD
@@ -193,148 +193,155 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineStream SherpaOnnxOnlineStream; @@ -193,148 +193,155 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineStream SherpaOnnxOnlineStream;
193 193
194 /// @param config Config for the recognizer. 194 /// @param config Config for the recognizer.
195 /// @return Return a pointer to the recognizer. The user has to invoke 195 /// @return Return a pointer to the recognizer. The user has to invoke
196 -// DestroyOnlineRecognizer() to free it to avoid memory leak.  
197 -SHERPA_ONNX_API SherpaOnnxOnlineRecognizer *CreateOnlineRecognizer( 196 +// SherpaOnnxDestroyOnlineRecognizer() to free it to avoid memory leak.
  197 +SHERPA_ONNX_API SherpaOnnxOnlineRecognizer *SherpaOnnxCreateOnlineRecognizer(
198 const SherpaOnnxOnlineRecognizerConfig *config); 198 const SherpaOnnxOnlineRecognizerConfig *config);
199 199
200 -/// Free a pointer returned by CreateOnlineRecognizer() 200 +/// Free a pointer returned by SherpaOnnxCreateOnlineRecognizer()
201 /// 201 ///
202 -/// @param p A pointer returned by CreateOnlineRecognizer()  
203 -SHERPA_ONNX_API void DestroyOnlineRecognizer( 202 +/// @param p A pointer returned by SherpaOnnxCreateOnlineRecognizer()
  203 +SHERPA_ONNX_API void SherpaOnnxDestroyOnlineRecognizer(
204 const SherpaOnnxOnlineRecognizer *recognizer); 204 const SherpaOnnxOnlineRecognizer *recognizer);
205 205
206 /// Create an online stream for accepting wave samples. 206 /// Create an online stream for accepting wave samples.
207 /// 207 ///
208 -/// @param recognizer A pointer returned by CreateOnlineRecognizer() 208 +/// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
209 /// @return Return a pointer to an OnlineStream. The user has to invoke 209 /// @return Return a pointer to an OnlineStream. The user has to invoke
210 -/// DestroyOnlineStream() to free it to avoid memory leak.  
211 -SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateOnlineStream( 210 +/// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
  211 +SHERPA_ONNX_API SherpaOnnxOnlineStream *SherpaOnnxCreateOnlineStream(
212 const SherpaOnnxOnlineRecognizer *recognizer); 212 const SherpaOnnxOnlineRecognizer *recognizer);
213 213
214 /// Create an online stream for accepting wave samples with the specified hot 214 /// Create an online stream for accepting wave samples with the specified hot
215 /// words. 215 /// words.
216 /// 216 ///
217 -/// @param recognizer A pointer returned by CreateOnlineRecognizer() 217 +/// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
218 /// @return Return a pointer to an OnlineStream. The user has to invoke 218 /// @return Return a pointer to an OnlineStream. The user has to invoke
219 -/// DestroyOnlineStream() to free it to avoid memory leak.  
220 -SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateOnlineStreamWithHotwords( 219 +/// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
  220 +SHERPA_ONNX_API SherpaOnnxOnlineStream *
  221 +SherpaOnnxCreateOnlineStreamWithHotwords(
221 const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords); 222 const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords);
222 223
223 /// Destroy an online stream. 224 /// Destroy an online stream.
224 /// 225 ///
225 -/// @param stream A pointer returned by CreateOnlineStream()  
226 -SHERPA_ONNX_API void DestroyOnlineStream(const SherpaOnnxOnlineStream *stream); 226 +/// @param stream A pointer returned by SherpaOnnxCreateOnlineStream()
  227 +SHERPA_ONNX_API void SherpaOnnxDestroyOnlineStream(
  228 + const SherpaOnnxOnlineStream *stream);
227 229
228 /// Accept input audio samples and compute the features. 230 /// Accept input audio samples and compute the features.
229 -/// The user has to invoke DecodeOnlineStream() to run the neural network and  
230 -/// decoding. 231 +/// The user has to invoke SherpaOnnxDecodeOnlineStream() to run the neural
  232 +/// network and decoding.
231 /// 233 ///
232 -/// @param stream A pointer returned by CreateOnlineStream(). 234 +/// @param stream A pointer returned by SherpaOnnxCreateOnlineStream().
233 /// @param sample_rate Sample rate of the input samples. If it is different 235 /// @param sample_rate Sample rate of the input samples. If it is different
234 /// from config.feat_config.sample_rate, we will do 236 /// from config.feat_config.sample_rate, we will do
235 /// resampling inside sherpa-onnx. 237 /// resampling inside sherpa-onnx.
236 /// @param samples A pointer to a 1-D array containing audio samples. 238 /// @param samples A pointer to a 1-D array containing audio samples.
237 /// The range of samples has to be normalized to [-1, 1]. 239 /// The range of samples has to be normalized to [-1, 1].
238 /// @param n Number of elements in the samples array. 240 /// @param n Number of elements in the samples array.
239 -SHERPA_ONNX_API void AcceptWaveform(const SherpaOnnxOnlineStream *stream,  
240 - int32_t sample_rate, const float *samples,  
241 - int32_t n); 241 +SHERPA_ONNX_API void SherpaOnnxOnlineStreamAcceptWaveform(
  242 + const SherpaOnnxOnlineStream *stream, int32_t sample_rate,
  243 + const float *samples, int32_t n);
242 244
243 /// Return 1 if there are enough number of feature frames for decoding. 245 /// Return 1 if there are enough number of feature frames for decoding.
244 /// Return 0 otherwise. 246 /// Return 0 otherwise.
245 /// 247 ///
246 -/// @param recognizer A pointer returned by CreateOnlineRecognizer  
247 -/// @param stream A pointer returned by CreateOnlineStream 248 +/// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer
  249 +/// @param stream A pointer returned by SherpaOnnxCreateOnlineStream
248 SHERPA_ONNX_API int32_t 250 SHERPA_ONNX_API int32_t
249 -IsOnlineStreamReady(const SherpaOnnxOnlineRecognizer *recognizer,  
250 - const SherpaOnnxOnlineStream *stream); 251 +SherpaOnnxIsOnlineStreamReady(const SherpaOnnxOnlineRecognizer *recognizer,
  252 + const SherpaOnnxOnlineStream *stream);
251 253
252 /// Call this function to run the neural network model and decoding. 254 /// Call this function to run the neural network model and decoding.
253 // 255 //
254 -/// Precondition for this function: IsOnlineStreamReady() MUST return 1. 256 +/// Precondition for this function: SherpaOnnxIsOnlineStreamReady() MUST
  257 +/// return 1.
255 /// 258 ///
256 /// Usage example: 259 /// Usage example:
257 /// 260 ///
258 -/// while (IsOnlineStreamReady(recognizer, stream)) {  
259 -/// DecodeOnlineStream(recognizer, stream); 261 +/// while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
  262 +/// SherpaOnnxDecodeOnlineStream(recognizer, stream);
260 /// } 263 /// }
261 /// 264 ///
262 -SHERPA_ONNX_API void DecodeOnlineStream( 265 +SHERPA_ONNX_API void SherpaOnnxDecodeOnlineStream(
263 const SherpaOnnxOnlineRecognizer *recognizer, 266 const SherpaOnnxOnlineRecognizer *recognizer,
264 const SherpaOnnxOnlineStream *stream); 267 const SherpaOnnxOnlineStream *stream);
265 268
266 -/// This function is similar to DecodeOnlineStream(). It decodes multiple  
267 -/// OnlineStream in parallel. 269 +/// This function is similar to SherpaOnnxDecodeOnlineStream(). It decodes
  270 +/// multiple OnlineStream in parallel.
268 /// 271 ///
269 /// Caution: The caller has to ensure each OnlineStream is ready, i.e., 272 /// Caution: The caller has to ensure each OnlineStream is ready, i.e.,
270 -/// IsOnlineStreamReady() for that stream should return 1. 273 +/// SherpaOnnxIsOnlineStreamReady() for that stream should return 1.
271 /// 274 ///
272 -/// @param recognizer A pointer returned by CreateOnlineRecognizer() 275 +/// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
273 /// @param streams A pointer array containing pointers returned by 276 /// @param streams A pointer array containing pointers returned by
274 -/// CreateOnlineRecognizer() 277 +/// SherpaOnnxCreateOnlineRecognizer()
275 /// @param n Number of elements in the given streams array. 278 /// @param n Number of elements in the given streams array.
276 -SHERPA_ONNX_API void DecodeMultipleOnlineStreams( 279 +SHERPA_ONNX_API void SherpaOnnxDecodeMultipleOnlineStreams(
277 const SherpaOnnxOnlineRecognizer *recognizer, 280 const SherpaOnnxOnlineRecognizer *recognizer,
278 const SherpaOnnxOnlineStream **streams, int32_t n); 281 const SherpaOnnxOnlineStream **streams, int32_t n);
279 282
280 /// Get the decoding results so far for an OnlineStream. 283 /// Get the decoding results so far for an OnlineStream.
281 /// 284 ///
282 -/// @param recognizer A pointer returned by CreateOnlineRecognizer().  
283 -/// @param stream A pointer returned by CreateOnlineStream(). 285 +/// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer().
  286 +/// @param stream A pointer returned by SherpaOnnxCreateOnlineStream().
284 /// @return A pointer containing the result. The user has to invoke 287 /// @return A pointer containing the result. The user has to invoke
285 -/// DestroyOnlineRecognizerResult() to free the returned pointer to  
286 -/// avoid memory leak.  
287 -SHERPA_ONNX_API const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult(  
288 - const SherpaOnnxOnlineRecognizer *recognizer,  
289 - const SherpaOnnxOnlineStream *stream); 288 +/// SherpaOnnxDestroyOnlineRecognizerResult() to free the returned
  289 +/// pointer to avoid memory leak.
  290 +SHERPA_ONNX_API const SherpaOnnxOnlineRecognizerResult *
  291 +SherpaOnnxGetOnlineStreamResult(const SherpaOnnxOnlineRecognizer *recognizer,
  292 + const SherpaOnnxOnlineStream *stream);
290 293
291 -/// Destroy the pointer returned by GetOnlineStreamResult(). 294 +/// Destroy the pointer returned by SherpaOnnxGetOnlineStreamResult().
292 /// 295 ///
293 -/// @param r A pointer returned by GetOnlineStreamResult()  
294 -SHERPA_ONNX_API void DestroyOnlineRecognizerResult( 296 +/// @param r A pointer returned by SherpaOnnxGetOnlineStreamResult()
  297 +SHERPA_ONNX_API void SherpaOnnxDestroyOnlineRecognizerResult(
295 const SherpaOnnxOnlineRecognizerResult *r); 298 const SherpaOnnxOnlineRecognizerResult *r);
296 299
297 /// Return the result as a json string. 300 /// Return the result as a json string.
298 /// The user has to invoke 301 /// The user has to invoke
299 -/// DestroyOnlineStreamResultJson() 302 +/// SherpaOnnxDestroyOnlineStreamResultJson()
300 /// to free the returned pointer to avoid memory leak 303 /// to free the returned pointer to avoid memory leak
301 -SHERPA_ONNX_API const char *GetOnlineStreamResultAsJson( 304 +SHERPA_ONNX_API const char *SherpaOnnxGetOnlineStreamResultAsJson(
302 const SherpaOnnxOnlineRecognizer *recognizer, 305 const SherpaOnnxOnlineRecognizer *recognizer,
303 const SherpaOnnxOnlineStream *stream); 306 const SherpaOnnxOnlineStream *stream);
304 307
305 -SHERPA_ONNX_API void DestroyOnlineStreamResultJson(const char *s); 308 +SHERPA_ONNX_API void SherpaOnnxDestroyOnlineStreamResultJson(const char *s);
306 309
307 -/// Reset an OnlineStream , which clears the neural network model state  
308 -/// and the state for decoding. 310 +/// SherpaOnnxOnlineStreamReset an OnlineStream , which clears the neural
  311 +/// network model state and the state for decoding.
309 /// 312 ///
310 -/// @param recognizer A pointer returned by CreateOnlineRecognizer().  
311 -/// @param stream A pointer returned by CreateOnlineStream  
312 -SHERPA_ONNX_API void Reset(const SherpaOnnxOnlineRecognizer *recognizer,  
313 - const SherpaOnnxOnlineStream *stream); 313 +/// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer().
  314 +/// @param stream A pointer returned by SherpaOnnxCreateOnlineStream
  315 +SHERPA_ONNX_API void SherpaOnnxOnlineStreamReset(
  316 + const SherpaOnnxOnlineRecognizer *recognizer,
  317 + const SherpaOnnxOnlineStream *stream);
314 318
315 /// Signal that no more audio samples would be available. 319 /// Signal that no more audio samples would be available.
316 -/// After this call, you cannot call AcceptWaveform() any more. 320 +/// After this call, you cannot call SherpaOnnxOnlineStreamAcceptWaveform() any
  321 +/// more.
317 /// 322 ///
318 -/// @param stream A pointer returned by CreateOnlineStream()  
319 -SHERPA_ONNX_API void InputFinished(const SherpaOnnxOnlineStream *stream); 323 +/// @param stream A pointer returned by SherpaOnnxCreateOnlineStream()
  324 +SHERPA_ONNX_API void SherpaOnnxOnlineStreamInputFinished(
  325 + const SherpaOnnxOnlineStream *stream);
320 326
321 /// Return 1 if an endpoint has been detected. 327 /// Return 1 if an endpoint has been detected.
322 /// 328 ///
323 -/// @param recognizer A pointer returned by CreateOnlineRecognizer()  
324 -/// @param stream A pointer returned by CreateOnlineStream() 329 +/// @param recognizer A pointer returned by SherpaOnnxCreateOnlineRecognizer()
  330 +/// @param stream A pointer returned by SherpaOnnxCreateOnlineStream()
325 /// @return Return 1 if an endpoint is detected. Return 0 otherwise. 331 /// @return Return 1 if an endpoint is detected. Return 0 otherwise.
326 -SHERPA_ONNX_API int32_t IsEndpoint(const SherpaOnnxOnlineRecognizer *recognizer,  
327 - const SherpaOnnxOnlineStream *stream); 332 +SHERPA_ONNX_API int32_t
  333 +SherpaOnnxOnlineStreamIsEndpoint(const SherpaOnnxOnlineRecognizer *recognizer,
  334 + const SherpaOnnxOnlineStream *stream);
328 335
329 // for displaying results on Linux/macOS. 336 // for displaying results on Linux/macOS.
330 SHERPA_ONNX_API typedef struct SherpaOnnxDisplay SherpaOnnxDisplay; 337 SHERPA_ONNX_API typedef struct SherpaOnnxDisplay SherpaOnnxDisplay;
331 338
332 -/// Create a display object. Must be freed using DestroyDisplay to avoid  
333 -/// memory leak.  
334 -SHERPA_ONNX_API const SherpaOnnxDisplay *CreateDisplay( 339 +/// Create a display object. Must be freed using SherpaOnnxDestroyDisplay to
  340 +/// avoid memory leak.
  341 +SHERPA_ONNX_API const SherpaOnnxDisplay *SherpaOnnxCreateDisplay(
335 int32_t max_word_per_line); 342 int32_t max_word_per_line);
336 343
337 -SHERPA_ONNX_API void DestroyDisplay(const SherpaOnnxDisplay *display); 344 +SHERPA_ONNX_API void SherpaOnnxDestroyDisplay(const SherpaOnnxDisplay *display);
338 345
339 /// Print the result. 346 /// Print the result.
340 SHERPA_ONNX_API void SherpaOnnxPrint(const SherpaOnnxDisplay *display, 347 SHERPA_ONNX_API void SherpaOnnxPrint(const SherpaOnnxDisplay *display,
@@ -431,8 +438,9 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineStream SherpaOnnxOfflineStream; @@ -431,8 +438,9 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineStream SherpaOnnxOfflineStream;
431 438
432 /// @param config Config for the recognizer. 439 /// @param config Config for the recognizer.
433 /// @return Return a pointer to the recognizer. The user has to invoke 440 /// @return Return a pointer to the recognizer. The user has to invoke
434 -// DestroyOfflineRecognizer() to free it to avoid memory leak.  
435 -SHERPA_ONNX_API SherpaOnnxOfflineRecognizer *CreateOfflineRecognizer( 441 +// SherpaOnnxDestroyOfflineRecognizer() to free it to avoid memory
  442 +// leak.
  443 +SHERPA_ONNX_API SherpaOnnxOfflineRecognizer *SherpaOnnxCreateOfflineRecognizer(
436 const SherpaOnnxOfflineRecognizerConfig *config); 444 const SherpaOnnxOfflineRecognizerConfig *config);
437 445
438 /// @param config Config for the recognizer. 446 /// @param config Config for the recognizer.
@@ -440,31 +448,31 @@ SHERPA_ONNX_API void SherpaOnnxOfflineRecognizerSetConfig( @@ -440,31 +448,31 @@ SHERPA_ONNX_API void SherpaOnnxOfflineRecognizerSetConfig(
440 const SherpaOnnxOfflineRecognizer *recognizer, 448 const SherpaOnnxOfflineRecognizer *recognizer,
441 const SherpaOnnxOfflineRecognizerConfig *config); 449 const SherpaOnnxOfflineRecognizerConfig *config);
442 450
443 -/// Free a pointer returned by CreateOfflineRecognizer() 451 +/// Free a pointer returned by SherpaOnnxCreateOfflineRecognizer()
444 /// 452 ///
445 -/// @param p A pointer returned by CreateOfflineRecognizer()  
446 -SHERPA_ONNX_API void DestroyOfflineRecognizer( 453 +/// @param p A pointer returned by SherpaOnnxCreateOfflineRecognizer()
  454 +SHERPA_ONNX_API void SherpaOnnxDestroyOfflineRecognizer(
447 SherpaOnnxOfflineRecognizer *recognizer); 455 SherpaOnnxOfflineRecognizer *recognizer);
448 456
449 /// Create an offline stream for accepting wave samples. 457 /// Create an offline stream for accepting wave samples.
450 /// 458 ///
451 -/// @param recognizer A pointer returned by CreateOfflineRecognizer() 459 +/// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer()
452 /// @return Return a pointer to an OfflineStream. The user has to invoke 460 /// @return Return a pointer to an OfflineStream. The user has to invoke
453 -/// DestroyOfflineStream() to free it to avoid memory leak.  
454 -SHERPA_ONNX_API SherpaOnnxOfflineStream *CreateOfflineStream( 461 +/// SherpaOnnxDestroyOfflineStream() to free it to avoid memory leak.
  462 +SHERPA_ONNX_API SherpaOnnxOfflineStream *SherpaOnnxCreateOfflineStream(
455 const SherpaOnnxOfflineRecognizer *recognizer); 463 const SherpaOnnxOfflineRecognizer *recognizer);
456 464
457 /// Destroy an offline stream. 465 /// Destroy an offline stream.
458 /// 466 ///
459 -/// @param stream A pointer returned by CreateOfflineStream()  
460 -SHERPA_ONNX_API void DestroyOfflineStream( 467 +/// @param stream A pointer returned by SherpaOnnxCreateOfflineStream()
  468 +SHERPA_ONNX_API void SherpaOnnxDestroyOfflineStream(
461 const SherpaOnnxOfflineStream *stream); 469 const SherpaOnnxOfflineStream *stream);
462 470
463 /// Accept input audio samples and compute the features. 471 /// Accept input audio samples and compute the features.
464 -/// The user has to invoke DecodeOfflineStream() to run the neural network and  
465 -/// decoding. 472 +/// The user has to invoke SherpaOnnxDecodeOfflineStream() to run the neural
  473 +/// network and decoding.
466 /// 474 ///
467 -/// @param stream A pointer returned by CreateOfflineStream(). 475 +/// @param stream A pointer returned by SherpaOnnxCreateOfflineStream().
468 /// @param sample_rate Sample rate of the input samples. If it is different 476 /// @param sample_rate Sample rate of the input samples. If it is different
469 /// from config.feat_config.sample_rate, we will do 477 /// from config.feat_config.sample_rate, we will do
470 /// resampling inside sherpa-onnx. 478 /// resampling inside sherpa-onnx.
@@ -473,30 +481,30 @@ SHERPA_ONNX_API void DestroyOfflineStream( @@ -473,30 +481,30 @@ SHERPA_ONNX_API void DestroyOfflineStream(
473 /// @param n Number of elements in the samples array. 481 /// @param n Number of elements in the samples array.
474 /// 482 ///
475 /// @caution: For each offline stream, please invoke this function only once! 483 /// @caution: For each offline stream, please invoke this function only once!
476 -SHERPA_ONNX_API void AcceptWaveformOffline( 484 +SHERPA_ONNX_API void SherpaOnnxAcceptWaveformOffline(
477 const SherpaOnnxOfflineStream *stream, int32_t sample_rate, 485 const SherpaOnnxOfflineStream *stream, int32_t sample_rate,
478 const float *samples, int32_t n); 486 const float *samples, int32_t n);
479 /// Decode an offline stream. 487 /// Decode an offline stream.
480 /// 488 ///
481 -/// We assume you have invoked AcceptWaveformOffline() for the given stream  
482 -/// before calling this function. 489 +/// We assume you have invoked SherpaOnnxAcceptWaveformOffline() for the given
  490 +/// stream before calling this function.
483 /// 491 ///
484 -/// @param recognizer A pointer returned by CreateOfflineRecognizer().  
485 -/// @param stream A pointer returned by CreateOfflineStream()  
486 -SHERPA_ONNX_API void DecodeOfflineStream( 492 +/// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer().
  493 +/// @param stream A pointer returned by SherpaOnnxCreateOfflineStream()
  494 +SHERPA_ONNX_API void SherpaOnnxDecodeOfflineStream(
487 const SherpaOnnxOfflineRecognizer *recognizer, 495 const SherpaOnnxOfflineRecognizer *recognizer,
488 const SherpaOnnxOfflineStream *stream); 496 const SherpaOnnxOfflineStream *stream);
489 497
490 /// Decode a list offline streams in parallel. 498 /// Decode a list offline streams in parallel.
491 /// 499 ///
492 -/// We assume you have invoked AcceptWaveformOffline() for each stream 500 +/// We assume you have invoked SherpaOnnxAcceptWaveformOffline() for each stream
493 /// before calling this function. 501 /// before calling this function.
494 /// 502 ///
495 -/// @param recognizer A pointer returned by CreateOfflineRecognizer(). 503 +/// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer().
496 /// @param streams A pointer pointer array containing pointers returned 504 /// @param streams A pointer pointer array containing pointers returned
497 -/// by CreateOfflineStream(). 505 +/// by SherpaOnnxCreateOfflineStream().
498 /// @param n Number of entries in the given streams. 506 /// @param n Number of entries in the given streams.
499 -SHERPA_ONNX_API void DecodeMultipleOfflineStreams( 507 +SHERPA_ONNX_API void SherpaOnnxDecodeMultipleOfflineStreams(
500 SherpaOnnxOfflineRecognizer *recognizer, SherpaOnnxOfflineStream **streams, 508 SherpaOnnxOfflineRecognizer *recognizer, SherpaOnnxOfflineStream **streams,
501 int32_t n); 509 int32_t n);
502 510
@@ -538,30 +546,30 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerResult { @@ -538,30 +546,30 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerResult {
538 546
539 /// Get the result of the offline stream. 547 /// Get the result of the offline stream.
540 /// 548 ///
541 -/// We assume you have called DecodeOfflineStream() or  
542 -/// DecodeMultipleOfflineStreams() with the given stream before calling  
543 -/// this function. 549 +/// We assume you have called SherpaOnnxDecodeOfflineStream() or
  550 +/// SherpaOnnxDecodeMultipleOfflineStreams() with the given stream before
  551 +/// calling this function.
544 /// 552 ///
545 -/// @param stream A pointer returned by CreateOfflineStream(). 553 +/// @param stream A pointer returned by SherpaOnnxCreateOfflineStream().
546 /// @return Return a pointer to the result. The user has to invoke 554 /// @return Return a pointer to the result. The user has to invoke
547 -/// DestroyOnlineRecognizerResult() to free the returned pointer to  
548 -/// avoid memory leak.  
549 -SHERPA_ONNX_API const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult(  
550 - const SherpaOnnxOfflineStream *stream); 555 +/// SherpaOnnxDestroyOnlineRecognizerResult() to free the returned
  556 +/// pointer to avoid memory leak.
  557 +SHERPA_ONNX_API const SherpaOnnxOfflineRecognizerResult *
  558 +SherpaOnnxGetOfflineStreamResult(const SherpaOnnxOfflineStream *stream);
551 559
552 -/// Destroy the pointer returned by GetOfflineStreamResult(). 560 +/// Destroy the pointer returned by SherpaOnnxGetOfflineStreamResult().
553 /// 561 ///
554 -/// @param r A pointer returned by GetOfflineStreamResult()  
555 -SHERPA_ONNX_API void DestroyOfflineRecognizerResult( 562 +/// @param r A pointer returned by SherpaOnnxGetOfflineStreamResult()
  563 +SHERPA_ONNX_API void SherpaOnnxDestroyOfflineRecognizerResult(
556 const SherpaOnnxOfflineRecognizerResult *r); 564 const SherpaOnnxOfflineRecognizerResult *r);
557 565
558 /// Return the result as a json string. 566 /// Return the result as a json string.
559 -/// The user has to use DestroyOfflineStreamResultJson() 567 +/// The user has to use SherpaOnnxDestroyOfflineStreamResultJson()
560 /// to free the returned pointer to avoid memory leak 568 /// to free the returned pointer to avoid memory leak
561 -SHERPA_ONNX_API const char *GetOfflineStreamResultAsJson( 569 +SHERPA_ONNX_API const char *SherpaOnnxGetOfflineStreamResultAsJson(
562 const SherpaOnnxOfflineStream *stream); 570 const SherpaOnnxOfflineStream *stream);
563 571
564 -SHERPA_ONNX_API void DestroyOfflineStreamResultJson(const char *s); 572 +SHERPA_ONNX_API void SherpaOnnxDestroyOfflineStreamResultJson(const char *s);
565 573
566 // ============================================================ 574 // ============================================================
567 // For Keyword Spot 575 // For Keyword Spot
@@ -618,82 +626,86 @@ SHERPA_ONNX_API typedef struct SherpaOnnxKeywordSpotter @@ -618,82 +626,86 @@ SHERPA_ONNX_API typedef struct SherpaOnnxKeywordSpotter
618 626
619 /// @param config Config for the keyword spotter. 627 /// @param config Config for the keyword spotter.
620 /// @return Return a pointer to the spotter. The user has to invoke 628 /// @return Return a pointer to the spotter. The user has to invoke
621 -/// DestroyKeywordSpotter() to free it to avoid memory leak.  
622 -SHERPA_ONNX_API SherpaOnnxKeywordSpotter *CreateKeywordSpotter( 629 +/// SherpaOnnxDestroyKeywordSpotter() to free it to avoid memory leak.
  630 +SHERPA_ONNX_API SherpaOnnxKeywordSpotter *SherpaOnnxCreateKeywordSpotter(
623 const SherpaOnnxKeywordSpotterConfig *config); 631 const SherpaOnnxKeywordSpotterConfig *config);
624 632
625 -/// Free a pointer returned by CreateKeywordSpotter() 633 +/// Free a pointer returned by SherpaOnnxCreateKeywordSpotter()
626 /// 634 ///
627 -/// @param p A pointer returned by CreateKeywordSpotter()  
628 -SHERPA_ONNX_API void DestroyKeywordSpotter(SherpaOnnxKeywordSpotter *spotter); 635 +/// @param p A pointer returned by SherpaOnnxCreateKeywordSpotter()
  636 +SHERPA_ONNX_API void SherpaOnnxDestroyKeywordSpotter(
  637 + SherpaOnnxKeywordSpotter *spotter);
629 638
630 /// Create an online stream for accepting wave samples. 639 /// Create an online stream for accepting wave samples.
631 /// 640 ///
632 -/// @param spotter A pointer returned by CreateKeywordSpotter() 641 +/// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter()
633 /// @return Return a pointer to an OnlineStream. The user has to invoke 642 /// @return Return a pointer to an OnlineStream. The user has to invoke
634 -/// DestroyOnlineStream() to free it to avoid memory leak.  
635 -SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateKeywordStream( 643 +/// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
  644 +SHERPA_ONNX_API SherpaOnnxOnlineStream *SherpaOnnxCreateKeywordStream(
636 const SherpaOnnxKeywordSpotter *spotter); 645 const SherpaOnnxKeywordSpotter *spotter);
637 646
638 /// Create an online stream for accepting wave samples with the specified hot 647 /// Create an online stream for accepting wave samples with the specified hot
639 /// words. 648 /// words.
640 /// 649 ///
641 -/// @param spotter A pointer returned by CreateKeywordSpotter() 650 +/// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter()
642 /// @param keywords A pointer points to the keywords that you set 651 /// @param keywords A pointer points to the keywords that you set
643 /// @return Return a pointer to an OnlineStream. The user has to invoke 652 /// @return Return a pointer to an OnlineStream. The user has to invoke
644 -/// DestroyOnlineStream() to free it to avoid memory leak.  
645 -SHERPA_ONNX_API SherpaOnnxOnlineStream *CreateKeywordStreamWithKeywords( 653 +/// SherpaOnnxDestroyOnlineStream() to free it to avoid memory leak.
  654 +SHERPA_ONNX_API SherpaOnnxOnlineStream *
  655 +SherpaOnnxCreateKeywordStreamWithKeywords(
646 const SherpaOnnxKeywordSpotter *spotter, const char *keywords); 656 const SherpaOnnxKeywordSpotter *spotter, const char *keywords);
647 657
648 /// Return 1 if there are enough number of feature frames for decoding. 658 /// Return 1 if there are enough number of feature frames for decoding.
649 /// Return 0 otherwise. 659 /// Return 0 otherwise.
650 /// 660 ///
651 -/// @param spotter A pointer returned by CreateKeywordSpotter  
652 -/// @param stream A pointer returned by CreateKeywordStream  
653 -SHERPA_ONNX_API int32_t IsKeywordStreamReady(SherpaOnnxKeywordSpotter *spotter,  
654 - SherpaOnnxOnlineStream *stream); 661 +/// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter
  662 +/// @param stream A pointer returned by SherpaOnnxCreateKeywordStream
  663 +SHERPA_ONNX_API int32_t SherpaOnnxIsKeywordStreamReady(
  664 + SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream);
655 665
656 /// Call this function to run the neural network model and decoding. 666 /// Call this function to run the neural network model and decoding.
657 // 667 //
658 -/// Precondition for this function: IsKeywordStreamReady() MUST return 1.  
659 -SHERPA_ONNX_API void DecodeKeywordStream(SherpaOnnxKeywordSpotter *spotter,  
660 - SherpaOnnxOnlineStream *stream); 668 +/// Precondition for this function: SherpaOnnxIsKeywordStreamReady() MUST
  669 +/// return 1.
  670 +SHERPA_ONNX_API void SherpaOnnxDecodeKeywordStream(
  671 + SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream);
661 672
662 -/// This function is similar to DecodeKeywordStream(). It decodes multiple  
663 -/// OnlineStream in parallel. 673 +/// This function is similar to SherpaOnnxDecodeKeywordStream(). It decodes
  674 +/// multiple OnlineStream in parallel.
664 /// 675 ///
665 /// Caution: The caller has to ensure each OnlineStream is ready, i.e., 676 /// Caution: The caller has to ensure each OnlineStream is ready, i.e.,
666 -/// IsKeywordStreamReady() for that stream should return 1. 677 +/// SherpaOnnxIsKeywordStreamReady() for that stream should return 1.
667 /// 678 ///
668 -/// @param spotter A pointer returned by CreateKeywordSpotter() 679 +/// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter()
669 /// @param streams A pointer array containing pointers returned by 680 /// @param streams A pointer array containing pointers returned by
670 -/// CreateKeywordStream() 681 +/// SherpaOnnxCreateKeywordStream()
671 /// @param n Number of elements in the given streams array. 682 /// @param n Number of elements in the given streams array.
672 -SHERPA_ONNX_API void DecodeMultipleKeywordStreams( 683 +SHERPA_ONNX_API void SherpaOnnxDecodeMultipleKeywordStreams(
673 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream **streams, 684 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream **streams,
674 int32_t n); 685 int32_t n);
675 686
676 /// Get the decoding results so far for an OnlineStream. 687 /// Get the decoding results so far for an OnlineStream.
677 /// 688 ///
678 -/// @param spotter A pointer returned by CreateKeywordSpotter().  
679 -/// @param stream A pointer returned by CreateKeywordStream(). 689 +/// @param spotter A pointer returned by SherpaOnnxCreateKeywordSpotter().
  690 +/// @param stream A pointer returned by SherpaOnnxCreateKeywordStream().
680 /// @return A pointer containing the result. The user has to invoke 691 /// @return A pointer containing the result. The user has to invoke
681 -/// DestroyKeywordResult() to free the returned pointer to 692 +/// SherpaOnnxDestroyKeywordResult() to free the returned pointer to
682 /// avoid memory leak. 693 /// avoid memory leak.
683 -SHERPA_ONNX_API const SherpaOnnxKeywordResult *GetKeywordResult( 694 +SHERPA_ONNX_API const SherpaOnnxKeywordResult *SherpaOnnxGetKeywordResult(
684 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream); 695 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream);
685 696
686 -/// Destroy the pointer returned by GetKeywordResult(). 697 +/// Destroy the pointer returned by SherpaOnnxGetKeywordResult().
687 /// 698 ///
688 -/// @param r A pointer returned by GetKeywordResult()  
689 -SHERPA_ONNX_API void DestroyKeywordResult(const SherpaOnnxKeywordResult *r); 699 +/// @param r A pointer returned by SherpaOnnxGetKeywordResult()
  700 +SHERPA_ONNX_API void SherpaOnnxDestroyKeywordResult(
  701 + const SherpaOnnxKeywordResult *r);
690 702
691 -// the user has to call FreeKeywordResultJson() to free the returned pointer  
692 -// to avoid memory leak  
693 -SHERPA_ONNX_API const char *GetKeywordResultAsJson( 703 +// the user has to call SherpaOnnxFreeKeywordResultJson() to free the returned
  704 +// pointer to avoid memory leak
  705 +SHERPA_ONNX_API const char *SherpaOnnxGetKeywordResultAsJson(
694 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream); 706 SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream *stream);
695 707
696 -SHERPA_ONNX_API void FreeKeywordResultJson(const char *s); 708 +SHERPA_ONNX_API void SherpaOnnxFreeKeywordResultJson(const char *s);
697 709
698 // ============================================================ 710 // ============================================================
699 // For VAD 711 // For VAD
@@ -979,7 +991,7 @@ SherpaOnnxCreateSpokenLanguageIdentification( @@ -979,7 +991,7 @@ SherpaOnnxCreateSpokenLanguageIdentification(
979 SHERPA_ONNX_API void SherpaOnnxDestroySpokenLanguageIdentification( 991 SHERPA_ONNX_API void SherpaOnnxDestroySpokenLanguageIdentification(
980 const SherpaOnnxSpokenLanguageIdentification *slid); 992 const SherpaOnnxSpokenLanguageIdentification *slid);
981 993
982 -// The user has to invoke DestroyOfflineStream() 994 +// The user has to invoke SherpaOnnxDestroyOfflineStream()
983 // to free the returned pointer to avoid memory leak 995 // to free the returned pointer to avoid memory leak
984 SHERPA_ONNX_API SherpaOnnxOfflineStream * 996 SHERPA_ONNX_API SherpaOnnxOfflineStream *
985 SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream( 997 SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream(
@@ -1029,8 +1041,8 @@ SHERPA_ONNX_API void SherpaOnnxDestroySpeakerEmbeddingExtractor( @@ -1029,8 +1041,8 @@ SHERPA_ONNX_API void SherpaOnnxDestroySpeakerEmbeddingExtractor(
1029 SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingExtractorDim( 1041 SHERPA_ONNX_API int32_t SherpaOnnxSpeakerEmbeddingExtractorDim(
1030 const SherpaOnnxSpeakerEmbeddingExtractor *p); 1042 const SherpaOnnxSpeakerEmbeddingExtractor *p);
1031 1043
1032 -// The user has to invoke DestroyOnlineStream() to free the returned pointer  
1033 -// to avoid memory leak 1044 +// The user has to invoke SherpaOnnxDestroyOnlineStream() to free the returned
  1045 +// pointer to avoid memory leak
1034 SHERPA_ONNX_API const SherpaOnnxOnlineStream * 1046 SHERPA_ONNX_API const SherpaOnnxOnlineStream *
1035 SherpaOnnxSpeakerEmbeddingExtractorCreateStream( 1047 SherpaOnnxSpeakerEmbeddingExtractorCreateStream(
1036 const SherpaOnnxSpeakerEmbeddingExtractor *p); 1048 const SherpaOnnxSpeakerEmbeddingExtractor *p);
@@ -1239,7 +1251,7 @@ SHERPA_ONNX_API const SherpaOnnxAudioTagging *SherpaOnnxCreateAudioTagging( @@ -1239,7 +1251,7 @@ SHERPA_ONNX_API const SherpaOnnxAudioTagging *SherpaOnnxCreateAudioTagging(
1239 SHERPA_ONNX_API void SherpaOnnxDestroyAudioTagging( 1251 SHERPA_ONNX_API void SherpaOnnxDestroyAudioTagging(
1240 const SherpaOnnxAudioTagging *tagger); 1252 const SherpaOnnxAudioTagging *tagger);
1241 1253
1242 -// The user has to invoke DestroyOfflineStream() 1254 +// The user has to invoke SherpaOnnxDestroyOfflineStream()
1243 // to free the returned pointer to avoid memory leak 1255 // to free the returned pointer to avoid memory leak
1244 SHERPA_ONNX_API const SherpaOnnxOfflineStream * 1256 SHERPA_ONNX_API const SherpaOnnxOfflineStream *
1245 SherpaOnnxAudioTaggingCreateOfflineStream(const SherpaOnnxAudioTagging *tagger); 1257 SherpaOnnxAudioTaggingCreateOfflineStream(const SherpaOnnxAudioTagging *tagger);
@@ -213,7 +213,7 @@ class SherpaOnnxOnlineRecongitionResult { @@ -213,7 +213,7 @@ class SherpaOnnxOnlineRecongitionResult {
213 213
214 deinit { 214 deinit {
215 if let result { 215 if let result {
216 - DestroyOnlineRecognizerResult(result) 216 + SherpaOnnxDestroyOnlineRecognizerResult(result)
217 } 217 }
218 } 218 }
219 } 219 }
@@ -227,17 +227,17 @@ class SherpaOnnxRecognizer { @@ -227,17 +227,17 @@ class SherpaOnnxRecognizer {
227 init( 227 init(
228 config: UnsafePointer<SherpaOnnxOnlineRecognizerConfig>! 228 config: UnsafePointer<SherpaOnnxOnlineRecognizerConfig>!
229 ) { 229 ) {
230 - recognizer = CreateOnlineRecognizer(config)  
231 - stream = CreateOnlineStream(recognizer) 230 + recognizer = SherpaOnnxCreateOnlineRecognizer(config)
  231 + stream = SherpaOnnxCreateOnlineStream(recognizer)
232 } 232 }
233 233
234 deinit { 234 deinit {
235 if let stream { 235 if let stream {
236 - DestroyOnlineStream(stream) 236 + SherpaOnnxDestroyOnlineStream(stream)
237 } 237 }
238 238
239 if let recognizer { 239 if let recognizer {
240 - DestroyOnlineRecognizer(recognizer) 240 + SherpaOnnxDestroyOnlineRecognizer(recognizer)
241 } 241 }
242 } 242 }
243 243
@@ -248,22 +248,22 @@ class SherpaOnnxRecognizer { @@ -248,22 +248,22 @@ class SherpaOnnxRecognizer {
248 /// - sampleRate: Sample rate of the input audio samples. Must match 248 /// - sampleRate: Sample rate of the input audio samples. Must match
249 /// the one expected by the model. 249 /// the one expected by the model.
250 func acceptWaveform(samples: [Float], sampleRate: Int = 16000) { 250 func acceptWaveform(samples: [Float], sampleRate: Int = 16000) {
251 - AcceptWaveform(stream, Int32(sampleRate), samples, Int32(samples.count)) 251 + SherpaOnnxOnlineStreamAcceptWaveform(stream, Int32(sampleRate), samples, Int32(samples.count))
252 } 252 }
253 253
254 func isReady() -> Bool { 254 func isReady() -> Bool {
255 - return IsOnlineStreamReady(recognizer, stream) == 1 ? true : false 255 + return SherpaOnnxIsOnlineStreamReady(recognizer, stream) == 1 ? true : false
256 } 256 }
257 257
258 /// If there are enough number of feature frames, it invokes the neural 258 /// If there are enough number of feature frames, it invokes the neural
259 /// network computation and decoding. Otherwise, it is a no-op. 259 /// network computation and decoding. Otherwise, it is a no-op.
260 func decode() { 260 func decode() {
261 - DecodeOnlineStream(recognizer, stream) 261 + SherpaOnnxDecodeOnlineStream(recognizer, stream)
262 } 262 }
263 263
264 /// Get the decoding results so far 264 /// Get the decoding results so far
265 func getResult() -> SherpaOnnxOnlineRecongitionResult { 265 func getResult() -> SherpaOnnxOnlineRecongitionResult {
266 - let result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>? = GetOnlineStreamResult( 266 + let result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>? = SherpaOnnxGetOnlineStreamResult(
267 recognizer, stream) 267 recognizer, stream)
268 return SherpaOnnxOnlineRecongitionResult(result: result) 268 return SherpaOnnxOnlineRecongitionResult(result: result)
269 } 269 }
@@ -275,15 +275,15 @@ class SherpaOnnxRecognizer { @@ -275,15 +275,15 @@ class SherpaOnnxRecognizer {
275 /// the given hotWords appended to the default hotwords. 275 /// the given hotWords appended to the default hotwords.
276 func reset(hotwords: String? = nil) { 276 func reset(hotwords: String? = nil) {
277 guard let words = hotwords, !words.isEmpty else { 277 guard let words = hotwords, !words.isEmpty else {
278 - Reset(recognizer, stream) 278 + SherpaOnnxOnlineStreamReset(recognizer, stream)
279 return 279 return
280 } 280 }
281 281
282 words.withCString { cString in 282 words.withCString { cString in
283 - let newStream = CreateOnlineStreamWithHotwords(recognizer, cString) 283 + let newStream = SherpaOnnxCreateOnlineStreamWithHotwords(recognizer, cString)
284 // lock while release and replace stream 284 // lock while release and replace stream
285 objc_sync_enter(self) 285 objc_sync_enter(self)
286 - DestroyOnlineStream(stream) 286 + SherpaOnnxDestroyOnlineStream(stream)
287 stream = newStream 287 stream = newStream
288 objc_sync_exit(self) 288 objc_sync_exit(self)
289 } 289 }
@@ -292,12 +292,12 @@ class SherpaOnnxRecognizer { @@ -292,12 +292,12 @@ class SherpaOnnxRecognizer {
292 /// Signal that no more audio samples would be available. 292 /// Signal that no more audio samples would be available.
293 /// After this call, you cannot call acceptWaveform() any more. 293 /// After this call, you cannot call acceptWaveform() any more.
294 func inputFinished() { 294 func inputFinished() {
295 - InputFinished(stream) 295 + SherpaOnnxOnlineStreamInputFinished(stream)
296 } 296 }
297 297
298 /// Return true is an endpoint has been detected. 298 /// Return true is an endpoint has been detected.
299 func isEndpoint() -> Bool { 299 func isEndpoint() -> Bool {
300 - return IsEndpoint(recognizer, stream) == 1 ? true : false 300 + return SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream) == 1 ? true : false
301 } 301 }
302 } 302 }
303 303
@@ -469,7 +469,7 @@ class SherpaOnnxOfflineRecongitionResult { @@ -469,7 +469,7 @@ class SherpaOnnxOfflineRecongitionResult {
469 469
470 deinit { 470 deinit {
471 if let result { 471 if let result {
472 - DestroyOfflineRecognizerResult(result) 472 + SherpaOnnxDestroyOfflineRecognizerResult(result)
473 } 473 }
474 } 474 }
475 } 475 }
@@ -481,12 +481,12 @@ class SherpaOnnxOfflineRecognizer { @@ -481,12 +481,12 @@ class SherpaOnnxOfflineRecognizer {
481 init( 481 init(
482 config: UnsafePointer<SherpaOnnxOfflineRecognizerConfig>! 482 config: UnsafePointer<SherpaOnnxOfflineRecognizerConfig>!
483 ) { 483 ) {
484 - recognizer = CreateOfflineRecognizer(config) 484 + recognizer = SherpaOnnxCreateOfflineRecognizer(config)
485 } 485 }
486 486
487 deinit { 487 deinit {
488 if let recognizer { 488 if let recognizer {
489 - DestroyOfflineRecognizer(recognizer) 489 + SherpaOnnxDestroyOfflineRecognizer(recognizer)
490 } 490 }
491 } 491 }
492 492
@@ -497,16 +497,17 @@ class SherpaOnnxOfflineRecognizer { @@ -497,16 +497,17 @@ class SherpaOnnxOfflineRecognizer {
497 /// - sampleRate: Sample rate of the input audio samples. Must match 497 /// - sampleRate: Sample rate of the input audio samples. Must match
498 /// the one expected by the model. 498 /// the one expected by the model.
499 func decode(samples: [Float], sampleRate: Int = 16000) -> SherpaOnnxOfflineRecongitionResult { 499 func decode(samples: [Float], sampleRate: Int = 16000) -> SherpaOnnxOfflineRecongitionResult {
500 - let stream: OpaquePointer! = CreateOfflineStream(recognizer) 500 + let stream: OpaquePointer! = SherpaOnnxCreateOfflineStream(recognizer)
501 501
502 - AcceptWaveformOffline(stream, Int32(sampleRate), samples, Int32(samples.count)) 502 + SherpaOnnxAcceptWaveformOffline(stream, Int32(sampleRate), samples, Int32(samples.count))
503 503
504 - DecodeOfflineStream(recognizer, stream) 504 + SherpaOnnxDecodeOfflineStream(recognizer, stream)
505 505
506 - let result: UnsafePointer<SherpaOnnxOfflineRecognizerResult>? = GetOfflineStreamResult(  
507 - stream) 506 + let result: UnsafePointer<SherpaOnnxOfflineRecognizerResult>? =
  507 + SherpaOnnxGetOfflineStreamResult(
  508 + stream)
508 509
509 - DestroyOfflineStream(stream) 510 + SherpaOnnxDestroyOfflineStream(stream)
510 511
511 return SherpaOnnxOfflineRecongitionResult(result: result) 512 return SherpaOnnxOfflineRecongitionResult(result: result)
512 } 513 }
@@ -852,14 +853,14 @@ class SherpaOnnxSpokenLanguageIdentificationWrapper { @@ -852,14 +853,14 @@ class SherpaOnnxSpokenLanguageIdentificationWrapper {
852 -> SherpaOnnxSpokenLanguageIdentificationResultWrapper 853 -> SherpaOnnxSpokenLanguageIdentificationResultWrapper
853 { 854 {
854 let stream: OpaquePointer! = SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream(slid) 855 let stream: OpaquePointer! = SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream(slid)
855 - AcceptWaveformOffline(stream, Int32(sampleRate), samples, Int32(samples.count)) 856 + SherpaOnnxAcceptWaveformOffline(stream, Int32(sampleRate), samples, Int32(samples.count))
856 857
857 let result: UnsafePointer<SherpaOnnxSpokenLanguageIdentificationResult>? = 858 let result: UnsafePointer<SherpaOnnxSpokenLanguageIdentificationResult>? =
858 SherpaOnnxSpokenLanguageIdentificationCompute( 859 SherpaOnnxSpokenLanguageIdentificationCompute(
859 slid, 860 slid,
860 stream) 861 stream)
861 862
862 - DestroyOfflineStream(stream) 863 + SherpaOnnxDestroyOfflineStream(stream)
863 return SherpaOnnxSpokenLanguageIdentificationResultWrapper(result: result) 864 return SherpaOnnxSpokenLanguageIdentificationResultWrapper(result: result)
864 } 865 }
865 } 866 }
@@ -900,7 +901,7 @@ class SherpaOnnxKeywordResultWrapper { @@ -900,7 +901,7 @@ class SherpaOnnxKeywordResultWrapper {
900 901
901 deinit { 902 deinit {
902 if let result { 903 if let result {
903 - DestroyKeywordResult(result) 904 + SherpaOnnxDestroyKeywordResult(result)
904 } 905 }
905 } 906 }
906 } 907 }
@@ -933,34 +934,34 @@ class SherpaOnnxKeywordSpotterWrapper { @@ -933,34 +934,34 @@ class SherpaOnnxKeywordSpotterWrapper {
933 init( 934 init(
934 config: UnsafePointer<SherpaOnnxKeywordSpotterConfig>! 935 config: UnsafePointer<SherpaOnnxKeywordSpotterConfig>!
935 ) { 936 ) {
936 - spotter = CreateKeywordSpotter(config)  
937 - stream = CreateKeywordStream(spotter) 937 + spotter = SherpaOnnxCreateKeywordSpotter(config)
  938 + stream = SherpaOnnxCreateKeywordStream(spotter)
938 } 939 }
939 940
940 deinit { 941 deinit {
941 if let stream { 942 if let stream {
942 - DestroyOnlineStream(stream) 943 + SherpaOnnxDestroyOnlineStream(stream)
943 } 944 }
944 945
945 if let spotter { 946 if let spotter {
946 - DestroyKeywordSpotter(spotter) 947 + SherpaOnnxDestroyKeywordSpotter(spotter)
947 } 948 }
948 } 949 }
949 950
950 func acceptWaveform(samples: [Float], sampleRate: Int = 16000) { 951 func acceptWaveform(samples: [Float], sampleRate: Int = 16000) {
951 - AcceptWaveform(stream, Int32(sampleRate), samples, Int32(samples.count)) 952 + SherpaOnnxOnlineStreamAcceptWaveform(stream, Int32(sampleRate), samples, Int32(samples.count))
952 } 953 }
953 954
954 func isReady() -> Bool { 955 func isReady() -> Bool {
955 - return IsKeywordStreamReady(spotter, stream) == 1 ? true : false 956 + return SherpaOnnxIsKeywordStreamReady(spotter, stream) == 1 ? true : false
956 } 957 }
957 958
958 func decode() { 959 func decode() {
959 - DecodeKeywordStream(spotter, stream) 960 + SherpaOnnxDecodeKeywordStream(spotter, stream)
960 } 961 }
961 962
962 func getResult() -> SherpaOnnxKeywordResultWrapper { 963 func getResult() -> SherpaOnnxKeywordResultWrapper {
963 - let result: UnsafePointer<SherpaOnnxKeywordResult>? = GetKeywordResult( 964 + let result: UnsafePointer<SherpaOnnxKeywordResult>? = SherpaOnnxGetKeywordResult(
964 spotter, stream) 965 spotter, stream)
965 return SherpaOnnxKeywordResultWrapper(result: result) 966 return SherpaOnnxKeywordResultWrapper(result: result)
966 } 967 }
@@ -968,7 +969,7 @@ class SherpaOnnxKeywordSpotterWrapper { @@ -968,7 +969,7 @@ class SherpaOnnxKeywordSpotterWrapper {
968 /// Signal that no more audio samples would be available. 969 /// Signal that no more audio samples would be available.
969 /// After this call, you cannot call acceptWaveform() any more. 970 /// After this call, you cannot call acceptWaveform() any more.
970 func inputFinished() { 971 func inputFinished() {
971 - InputFinished(stream) 972 + SherpaOnnxOnlineStreamInputFinished(stream)
972 } 973 }
973 } 974 }
974 975
@@ -9,22 +9,22 @@ endif() @@ -9,22 +9,22 @@ endif()
9 set(exported_functions 9 set(exported_functions
10 MyPrint 10 MyPrint
11 # online ASR 11 # online ASR
12 - AcceptWaveform  
13 - CreateOnlineRecognizer  
14 - CreateOnlineStream  
15 - DecodeOnlineStream  
16 - DestroyOfflineStreamResultJson  
17 - DestroyOnlineRecognizer  
18 - DestroyOnlineRecognizerResult  
19 - DestroyOnlineStream  
20 - DestroyOnlineStreamResultJson  
21 - GetOfflineStreamResultAsJson  
22 - GetOnlineStreamResult  
23 - GetOnlineStreamResultAsJson  
24 - InputFinished  
25 - IsEndpoint  
26 - IsOnlineStreamReady  
27 - Reset 12 + SherpaOnnxCreateOnlineRecognizer
  13 + SherpaOnnxCreateOnlineStream
  14 + SherpaOnnxDecodeOnlineStream
  15 + SherpaOnnxDestroyOfflineStreamResultJson
  16 + SherpaOnnxDestroyOnlineRecognizer
  17 + SherpaOnnxDestroyOnlineRecognizerResult
  18 + SherpaOnnxDestroyOnlineStream
  19 + SherpaOnnxDestroyOnlineStreamResultJson
  20 + SherpaOnnxGetOfflineStreamResultAsJson
  21 + SherpaOnnxGetOnlineStreamResult
  22 + SherpaOnnxGetOnlineStreamResultAsJson
  23 + SherpaOnnxIsOnlineStreamReady
  24 + SherpaOnnxOnlineStreamAcceptWaveform
  25 + SherpaOnnxOnlineStreamInputFinished
  26 + SherpaOnnxOnlineStreamIsEndpoint
  27 + SherpaOnnxOnlineStreamReset
28 # 28 #
29 ) 29 )
30 set(mangled_exported_functions) 30 set(mangled_exported_functions)
@@ -869,7 +869,7 @@ class OfflineStream { @@ -869,7 +869,7 @@ class OfflineStream {
869 869
870 free() { 870 free() {
871 if (this.handle) { 871 if (this.handle) {
872 - this.Module._DestroyOfflineStream(this.handle); 872 + this.Module._SherpaOnnxDestroyOfflineStream(this.handle);
873 this.handle = null; 873 this.handle = null;
874 } 874 }
875 } 875 }
@@ -882,7 +882,7 @@ class OfflineStream { @@ -882,7 +882,7 @@ class OfflineStream {
882 const pointer = 882 const pointer =
883 this.Module._malloc(samples.length * samples.BYTES_PER_ELEMENT); 883 this.Module._malloc(samples.length * samples.BYTES_PER_ELEMENT);
884 this.Module.HEAPF32.set(samples, pointer / samples.BYTES_PER_ELEMENT); 884 this.Module.HEAPF32.set(samples, pointer / samples.BYTES_PER_ELEMENT);
885 - this.Module._AcceptWaveformOffline( 885 + this.Module._SherpaOnnxAcceptWaveformOffline(
886 this.handle, sampleRate, pointer, samples.length); 886 this.handle, sampleRate, pointer, samples.length);
887 this.Module._free(pointer); 887 this.Module._free(pointer);
888 } 888 }
@@ -892,7 +892,7 @@ class OfflineRecognizer { @@ -892,7 +892,7 @@ class OfflineRecognizer {
892 constructor(configObj, Module) { 892 constructor(configObj, Module) {
893 this.config = configObj; 893 this.config = configObj;
894 const config = initSherpaOnnxOfflineRecognizerConfig(configObj, Module); 894 const config = initSherpaOnnxOfflineRecognizerConfig(configObj, Module);
895 - const handle = Module._CreateOfflineRecognizer(config.ptr); 895 + const handle = Module._SherpaOnnxCreateOfflineRecognizer(config.ptr);
896 freeConfig(config, Module); 896 freeConfig(config, Module);
897 897
898 this.handle = handle; 898 this.handle = handle;
@@ -900,24 +900,25 @@ class OfflineRecognizer { @@ -900,24 +900,25 @@ class OfflineRecognizer {
900 } 900 }
901 901
902 free() { 902 free() {
903 - this.Module._DestroyOfflineRecognizer(this.handle); 903 + this.Module._SherpaOnnxDestroyOfflineRecognizer(this.handle);
904 this.handle = 0 904 this.handle = 0
905 } 905 }
906 906
907 createStream() { 907 createStream() {
908 - const handle = this.Module._CreateOfflineStream(this.handle); 908 + const handle = this.Module._SherpaOnnxCreateOfflineStream(this.handle);
909 return new OfflineStream(handle, this.Module); 909 return new OfflineStream(handle, this.Module);
910 } 910 }
911 911
912 decode(stream) { 912 decode(stream) {
913 - this.Module._DecodeOfflineStream(this.handle, stream.handle); 913 + this.Module._SherpaOnnxDecodeOfflineStream(this.handle, stream.handle);
914 } 914 }
915 915
916 getResult(stream) { 916 getResult(stream) {
917 - const r = this.Module._GetOfflineStreamResultAsJson(stream.handle); 917 + const r =
  918 + this.Module._SherpaOnnxGetOfflineStreamResultAsJson(stream.handle);
918 const jsonStr = this.Module.UTF8ToString(r); 919 const jsonStr = this.Module.UTF8ToString(r);
919 const ans = JSON.parse(jsonStr); 920 const ans = JSON.parse(jsonStr);
920 - this.Module._DestroyOfflineStreamResultJson(r); 921 + this.Module._SherpaOnnxDestroyOfflineStreamResultJson(r);
921 922
922 return ans; 923 return ans;
923 } 924 }
@@ -933,7 +934,7 @@ class OnlineStream { @@ -933,7 +934,7 @@ class OnlineStream {
933 934
934 free() { 935 free() {
935 if (this.handle) { 936 if (this.handle) {
936 - this.Module._DestroyOnlineStream(this.handle); 937 + this.Module._SherpaOnnxDestroyOnlineStream(this.handle);
937 this.handle = null; 938 this.handle = null;
938 this.Module._free(this.pointer); 939 this.Module._free(this.pointer);
939 this.pointer = null; 940 this.pointer = null;
@@ -954,12 +955,12 @@ class OnlineStream { @@ -954,12 +955,12 @@ class OnlineStream {
954 } 955 }
955 956
956 this.Module.HEAPF32.set(samples, this.pointer / samples.BYTES_PER_ELEMENT); 957 this.Module.HEAPF32.set(samples, this.pointer / samples.BYTES_PER_ELEMENT);
957 - this.Module._AcceptWaveform( 958 + this.Module._SherpaOnnxOnlineStreamAcceptWaveform(
958 this.handle, sampleRate, this.pointer, samples.length); 959 this.handle, sampleRate, this.pointer, samples.length);
959 } 960 }
960 961
961 inputFinished() { 962 inputFinished() {
962 - this.Module._InputFinished(this.handle); 963 + this.Module._SherpaOnnxOnlineStreamInputFinished(this.handle);
963 } 964 }
964 }; 965 };
965 966
@@ -967,7 +968,7 @@ class OnlineRecognizer { @@ -967,7 +968,7 @@ class OnlineRecognizer {
967 constructor(configObj, Module) { 968 constructor(configObj, Module) {
968 this.config = configObj; 969 this.config = configObj;
969 const config = initSherpaOnnxOnlineRecognizerConfig(configObj, Module) 970 const config = initSherpaOnnxOnlineRecognizerConfig(configObj, Module)
970 - const handle = Module._CreateOnlineRecognizer(config.ptr); 971 + const handle = Module._SherpaOnnxCreateOnlineRecognizer(config.ptr);
971 972
972 freeConfig(config, Module); 973 freeConfig(config, Module);
973 974
@@ -976,37 +977,39 @@ class OnlineRecognizer { @@ -976,37 +977,39 @@ class OnlineRecognizer {
976 } 977 }
977 978
978 free() { 979 free() {
979 - this.Module._DestroyOnlineRecognizer(this.handle); 980 + this.Module._SherpaOnnxDestroyOnlineRecognizer(this.handle);
980 this.handle = 0 981 this.handle = 0
981 } 982 }
982 983
983 createStream() { 984 createStream() {
984 - const handle = this.Module._CreateOnlineStream(this.handle); 985 + const handle = this.Module._SherpaOnnxCreateOnlineStream(this.handle);
985 return new OnlineStream(handle, this.Module); 986 return new OnlineStream(handle, this.Module);
986 } 987 }
987 988
988 isReady(stream) { 989 isReady(stream) {
989 - return this.Module._IsOnlineStreamReady(this.handle, stream.handle) == 1; 990 + return this.Module._SherpaOnnxIsOnlineStreamReady(
  991 + this.handle, stream.handle) == 1;
990 } 992 }
991 993
992 decode(stream) { 994 decode(stream) {
993 - this.Module._DecodeOnlineStream(this.handle, stream.handle); 995 + this.Module._SherpaOnnxDecodeOnlineStream(this.handle, stream.handle);
994 } 996 }
995 997
996 isEndpoint(stream) { 998 isEndpoint(stream) {
997 - return this.Module._IsEndpoint(this.handle, stream.handle) == 1; 999 + return this.Module._SherpaOnnxOnlineStreamIsEndpoint(
  1000 + this.handle, stream.handle) == 1;
998 } 1001 }
999 1002
1000 reset(stream) { 1003 reset(stream) {
1001 - this.Module._Reset(this.handle, stream.handle); 1004 + this.Module._SherpaOnnxOnlineStreamReset(this.handle, stream.handle);
1002 } 1005 }
1003 1006
1004 getResult(stream) { 1007 getResult(stream) {
1005 - const r =  
1006 - this.Module._GetOnlineStreamResultAsJson(this.handle, stream.handle); 1008 + const r = this.Module._SherpaOnnxGetOnlineStreamResultAsJson(
  1009 + this.handle, stream.handle);
1007 const jsonStr = this.Module.UTF8ToString(r); 1010 const jsonStr = this.Module.UTF8ToString(r);
1008 const ans = JSON.parse(jsonStr); 1011 const ans = JSON.parse(jsonStr);
1009 - this.Module._DestroyOnlineStreamResultJson(r); 1012 + this.Module._SherpaOnnxDestroyOnlineStreamResultJson(r);
1010 1013
1011 return ans; 1014 return ans;
1012 } 1015 }
@@ -8,15 +8,15 @@ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/assets/decoder-epoch-12-avg-2-chunk-1 @@ -8,15 +8,15 @@ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/assets/decoder-epoch-12-avg-2-chunk-1
8 endif() 8 endif()
9 9
10 set(exported_functions 10 set(exported_functions
11 - AcceptWaveform  
12 - CreateKeywordSpotter  
13 - DestroyKeywordSpotter  
14 - CreateKeywordStream  
15 - DecodeKeywordStream  
16 - GetKeywordResult  
17 - DestroyKeywordResult  
18 - IsKeywordStreamReady  
19 - InputFinished 11 + SherpaOnnxCreateKeywordSpotter
  12 + SherpaOnnxCreateKeywordStream
  13 + SherpaOnnxDecodeKeywordStream
  14 + SherpaOnnxDestroyKeywordResult
  15 + SherpaOnnxDestroyKeywordSpotter
  16 + SherpaOnnxGetKeywordResult
  17 + SherpaOnnxIsKeywordStreamReady
  18 + SherpaOnnxOnlineStreamAcceptWaveform
  19 + SherpaOnnxOnlineStreamInputFinished
20 ) 20 )
21 set(mangled_exported_functions) 21 set(mangled_exported_functions)
22 foreach(x IN LISTS exported_functions) 22 foreach(x IN LISTS exported_functions)
@@ -189,7 +189,7 @@ class Stream { @@ -189,7 +189,7 @@ class Stream {
189 189
190 free() { 190 free() {
191 if (this.handle) { 191 if (this.handle) {
192 - this.Module._DestroyOnlineKwsStream(this.handle); 192 + this.Module._SherpaOnnxDestroyOnlineStream(this.handle);
193 this.handle = null; 193 this.handle = null;
194 this.Module._free(this.pointer); 194 this.Module._free(this.pointer);
195 this.pointer = null; 195 this.pointer = null;
@@ -210,12 +210,12 @@ class Stream { @@ -210,12 +210,12 @@ class Stream {
210 } 210 }
211 211
212 this.Module.HEAPF32.set(samples, this.pointer / samples.BYTES_PER_ELEMENT); 212 this.Module.HEAPF32.set(samples, this.pointer / samples.BYTES_PER_ELEMENT);
213 - this.Module._AcceptWaveform( 213 + this.Module._SherpaOnnxOnlineStreamAcceptWaveform(
214 this.handle, sampleRate, this.pointer, samples.length); 214 this.handle, sampleRate, this.pointer, samples.length);
215 } 215 }
216 216
217 inputFinished() { 217 inputFinished() {
218 - this.Module._InputFinished(this.handle); 218 + this.Module._SherpaOnnxOnlineStreamInputFinished(this.handle);
219 } 219 }
220 }; 220 };
221 221
@@ -223,7 +223,7 @@ class Kws { @@ -223,7 +223,7 @@ class Kws {
223 constructor(configObj, Module) { 223 constructor(configObj, Module) {
224 this.config = configObj; 224 this.config = configObj;
225 let config = initKwsConfig(configObj, Module) 225 let config = initKwsConfig(configObj, Module)
226 - let handle = Module._CreateKeywordSpotter(config.ptr); 226 + let handle = Module._SherpaOnnxCreateKeywordSpotter(config.ptr);
227 227
228 freeConfig(config, Module); 228 freeConfig(config, Module);
229 229
@@ -232,28 +232,30 @@ class Kws { @@ -232,28 +232,30 @@ class Kws {
232 } 232 }
233 233
234 free() { 234 free() {
235 - this.Module._DestroyKeywordSpotter(this.handle); 235 + this.Module._SherpaOnnxDestroyKeywordSpotter(this.handle);
236 this.handle = 0 236 this.handle = 0
237 } 237 }
238 238
239 createStream() { 239 createStream() {
240 - let handle = this.Module._CreateKeywordStream(this.handle); 240 + let handle = this.Module._SherpaOnnxCreateKeywordStream(this.handle);
241 return new Stream(handle, this.Module); 241 return new Stream(handle, this.Module);
242 } 242 }
243 243
244 isReady(stream) { 244 isReady(stream) {
245 - return this.Module._IsKeywordStreamReady(this.handle, stream.handle) === 1; 245 + return this.Module._SherpaOnnxIsKeywordStreamReady(
  246 + this.handle, stream.handle) == 1;
246 } 247 }
247 248
248 decode(stream) { 249 decode(stream) {
249 - return this.Module._DecodeKeywordStream(this.handle, stream.handle); 250 + return this.Module._SherpaOnnxDecodeKeywordStream(
  251 + this.handle, stream.handle);
250 } 252 }
251 253
252 getResult(stream) { 254 getResult(stream) {
253 - let r = this.Module._GetKeywordResult(this.handle, stream.handle); 255 + let r = this.Module._SherpaOnnxGetKeywordResult(this.handle, stream.handle);
254 let jsonPtr = this.Module.getValue(r + 24, 'i8*'); 256 let jsonPtr = this.Module.getValue(r + 24, 'i8*');
255 let json = this.Module.UTF8ToString(jsonPtr); 257 let json = this.Module.UTF8ToString(jsonPtr);
256 - this.Module._DestroyKeywordResult(r); 258 + this.Module._SherpaOnnxDestroyKeywordResult(r);
257 return JSON.parse(json); 259 return JSON.parse(json);
258 } 260 }
259 } 261 }
@@ -14,41 +14,41 @@ set(exported_functions @@ -14,41 +14,41 @@ set(exported_functions
14 SherpaOnnxOfflineTtsSampleRate 14 SherpaOnnxOfflineTtsSampleRate
15 SherpaOnnxWriteWave 15 SherpaOnnxWriteWave
16 # streaming asr 16 # streaming asr
17 - AcceptWaveform  
18 - CreateOnlineRecognizer  
19 - CreateOnlineStream  
20 - DecodeOnlineStream  
21 - DestroyOnlineRecognizer  
22 - DestroyOnlineRecognizerResult  
23 - DestroyOnlineStream  
24 - DestroyOnlineStreamResultJson  
25 - GetOnlineStreamResult  
26 - GetOnlineStreamResultAsJson  
27 - InputFinished  
28 - IsEndpoint  
29 - IsOnlineStreamReady  
30 - Reset 17 + SherpaOnnxCreateOnlineRecognizer
  18 + SherpaOnnxCreateOnlineStream
  19 + SherpaOnnxDecodeOnlineStream
  20 + SherpaOnnxDestroyOnlineRecognizer
  21 + SherpaOnnxDestroyOnlineRecognizerResult
  22 + SherpaOnnxDestroyOnlineStream
  23 + SherpaOnnxDestroyOnlineStreamResultJson
  24 + SherpaOnnxGetOnlineStreamResult
  25 + SherpaOnnxGetOnlineStreamResultAsJson
  26 + SherpaOnnxIsOnlineStreamReady
  27 + SherpaOnnxOnlineStreamAcceptWaveform
  28 + SherpaOnnxOnlineStreamInputFinished
  29 + SherpaOnnxOnlineStreamIsEndpoint
  30 + SherpaOnnxOnlineStreamReset
31 # non-streaming ASR 31 # non-streaming ASR
32 - AcceptWaveformOffline  
33 - CreateOfflineRecognizer  
34 - CreateOfflineStream  
35 - DecodeMultipleOfflineStreams  
36 - DecodeOfflineStream  
37 - DestroyOfflineRecognizer  
38 - DestroyOfflineRecognizerResult  
39 - DestroyOfflineStream  
40 - DestroyOfflineStreamResultJson  
41 - GetOfflineStreamResult  
42 - GetOfflineStreamResultAsJson  
43 PrintOfflineRecognizerConfig 32 PrintOfflineRecognizerConfig
  33 + SherpaOnnxAcceptWaveformOffline
  34 + SherpaOnnxCreateOfflineRecognizer
  35 + SherpaOnnxCreateOfflineStream
  36 + SherpaOnnxDecodeMultipleOfflineStreams
  37 + SherpaOnnxDecodeOfflineStream
  38 + SherpaOnnxDestroyOfflineRecognizer
  39 + SherpaOnnxDestroyOfflineRecognizerResult
  40 + SherpaOnnxDestroyOfflineStream
  41 + SherpaOnnxDestroyOfflineStreamResultJson
  42 + SherpaOnnxGetOfflineStreamResult
  43 + SherpaOnnxGetOfflineStreamResultAsJson
44 # online kws 44 # online kws
45 - CreateKeywordSpotter  
46 - DestroyKeywordSpotter  
47 - CreateKeywordStream  
48 - DecodeKeywordStream  
49 - GetKeywordResult  
50 - DestroyKeywordResult  
51 - IsKeywordStreamReady 45 + SherpaOnnxCreateKeywordSpotter
  46 + SherpaOnnxCreateKeywordStream
  47 + SherpaOnnxDecodeKeywordStream
  48 + SherpaOnnxDestroyKeywordResult
  49 + SherpaOnnxDestroyKeywordSpotter
  50 + SherpaOnnxGetKeywordResult
  51 + SherpaOnnxIsKeywordStreamReady
52 ) 52 )
53 53
54 54