Implement Tokens in Swift and Kotlin (#227)

Co-authored-by: duc <duc@appiphany.com.au>
This commit is contained in:
Wilson Wongso
2023-08-05 17:37:03 +07:00
committed by GitHub
parent c5756734a9
commit 64efbd82af
4 changed files with 121 additions and 1 deletions

View File

@@ -101,8 +101,35 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerConfig {
} SherpaOnnxOnlineRecognizerConfig;
SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerResult {
// Recognized text
const char *text;
// TODO(fangjun): Add more fields
// Pointer to continuous memory which holds string based tokens
// which are seperated by \0
const char *tokens;
// a pointer array contains the address of the first item in tokens
const char *const *tokens_arr;
// Pointer to continuous memory which holds timestamps
float *timestamps;
// The number of tokens/timestamps in above pointer
int32_t count;
/** Return a json string.
*
* The returned string contains:
* {
* "text": "The recognition result",
* "tokens": [x, x, x],
* "timestamps": [x, x, x],
* "segment": x,
* "start_time": x,
* "is_final": true|false
* }
*/
const char *json;
} SherpaOnnxOnlineRecognizerResult;
/// Note: OnlineRecognizer here means StreamingRecognizer.