Commit 2ac41d3 1 parent 9559a10 commit 2ac41d3 Copy full SHA for 2ac41d3
File tree 4 files changed +26
-2
lines changed
4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -533,6 +533,13 @@ const SherpaOnnxOfflineStream *SherpaOnnxCreateOfflineStream(
533
533
return stream;
534
534
}
535
535
536
+ const SherpaOnnxOfflineStream *SherpaOnnxCreateOfflineStreamWithHotwords (
537
+ const SherpaOnnxOfflineRecognizer *recognizer, const char *hotwords) {
538
+ SherpaOnnxOfflineStream *stream =
539
+ new SherpaOnnxOfflineStream (recognizer->impl ->CreateStream (hotwords));
540
+ return stream;
541
+ }
542
+
536
543
void SherpaOnnxDestroyOfflineStream (const SherpaOnnxOfflineStream *stream) {
537
544
delete stream;
538
545
}
Original file line number Diff line number Diff line change @@ -484,6 +484,16 @@ SHERPA_ONNX_API void SherpaOnnxDestroyOfflineRecognizer(
484
484
SHERPA_ONNX_API const SherpaOnnxOfflineStream * SherpaOnnxCreateOfflineStream (
485
485
const SherpaOnnxOfflineRecognizer * recognizer );
486
486
487
+ /// Create an offline stream for accepting wave samples with the specified hot
488
+ /// words.
489
+ ///
490
+ /// @param recognizer A pointer returned by SherpaOnnxCreateOfflineRecognizer()
491
+ /// @return Return a pointer to an OfflineStream. The user has to invoke
492
+ /// SherpaOnnxDestroyOfflineStream() to free it to avoid memory leak.
493
+ SHERPA_ONNX_API const SherpaOnnxOfflineStream *
494
+ SherpaOnnxCreateOfflineStreamWithHotwords (
495
+ const SherpaOnnxOfflineRecognizer * recognizer , const char * hotwords );
496
+
487
497
/// Destroy an offline stream.
488
498
///
489
499
/// @param stream A pointer returned by SherpaOnnxCreateOfflineStream()
Original file line number Diff line number Diff line change @@ -266,8 +266,13 @@ void OfflineRecognizer::Destroy(const SherpaOnnxOfflineRecognizer *p) const {
266
266
}
267
267
268
268
OfflineStream OfflineRecognizer::CreateStream () const {
269
- auto p = SherpaOnnxCreateOfflineStream (p_);
270
- return OfflineStream{p};
269
+ auto s = SherpaOnnxCreateOfflineStream (p_);
270
+ return OfflineStream{s};
271
+ }
272
+
273
+ OfflineStream OfflineRecognizer::CreateStream (const std::string &hotwords) const {
274
+ auto s = SherpaOnnxCreateOfflineStreamWithHotwords (p_, hotwords.c_str ());
275
+ return OfflineStream{s};
271
276
}
272
277
273
278
void OfflineRecognizer::Decode (const OfflineStream *s) const {
Original file line number Diff line number Diff line change @@ -301,6 +301,8 @@ class SHERPA_ONNX_API OfflineRecognizer
301
301
302
302
OfflineStream CreateStream () const ;
303
303
304
+ OfflineStream CreateStream (const std::string &hotwords) const ;
305
+
304
306
void Decode (const OfflineStream *s) const ;
305
307
306
308
void Decode (const OfflineStream *ss, int32_t n) const ;
You can’t perform that action at this time.
0 commit comments