Add C API for punctuation (#768)

This commit is contained in:
Fangjun Kuang
2024-04-14 19:02:34 +08:00
committed by GitHub
parent b0265b258d
commit 13730ecbd8
13 changed files with 302 additions and 12 deletions

View File

@@ -1149,6 +1149,41 @@ SherpaOnnxAudioTaggingCompute(const SherpaOnnxAudioTagging *tagger,
SHERPA_ONNX_API void SherpaOnnxAudioTaggingFreeResults(
const SherpaOnnxAudioEvent *const *p);
// ============================================================
// For punctuation
// ============================================================
SHERPA_ONNX_API typedef struct SherpaOnnxOfflinePunctuationModelConfig {
const char *ct_transformer;
int32_t num_threads;
int32_t debug; // true to print debug information of the model
const char *provider;
} SherpaOnnxOfflinePunctuationModelConfig;
SHERPA_ONNX_API typedef struct SherpaOnnxOfflinePunctuationConfig {
SherpaOnnxOfflinePunctuationModelConfig model;
} SherpaOnnxOfflinePunctuationConfig;
SHERPA_ONNX_API typedef struct SherpaOnnxOfflinePunctuation
SherpaOnnxOfflinePunctuation;
// The user has to invoke SherpaOnnxDestroyOfflinePunctuation()
// to free the returned pointer to avoid memory leak
SHERPA_ONNX_API const SherpaOnnxOfflinePunctuation *
SherpaOnnxCreateOfflinePunctuation(
const SherpaOnnxOfflinePunctuationConfig *config);
SHERPA_ONNX_API void SherpaOnnxDestroyOfflinePunctuation(
const SherpaOnnxOfflinePunctuation *punct);
// Add punctuations to the input text.
// The user has to invoke SherpaOfflinePunctuationFreeText()
// to free the returned pointer to avoid memory leak
SHERPA_ONNX_API const char *SherpaOfflinePunctuationAddPunct(
const SherpaOnnxOfflinePunctuation *punct, const char *text);
SHERPA_ONNX_API void SherpaOfflinePunctuationFreeText(const char *text);
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif