Add timestamps for offline paraformer (#310)
This commit is contained in:
@@ -353,11 +353,22 @@ SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult(
|
||||
std::copy(text.begin(), text.end(), const_cast<char *>(r->text));
|
||||
const_cast<char *>(r->text)[text.size()] = 0;
|
||||
|
||||
if (!result.timestamps.empty()) {
|
||||
r->timestamps = new float[result.timestamps.size()];
|
||||
std::copy(result.timestamps.begin(), result.timestamps.end(),
|
||||
r->timestamps);
|
||||
r->count = result.timestamps.size();
|
||||
} else {
|
||||
r->timestamps = nullptr;
|
||||
r->count = 0;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void DestroyOfflineRecognizerResult(
|
||||
const SherpaOnnxOfflineRecognizerResult *r) {
|
||||
delete[] r->text;
|
||||
delete[] r->timestamps;
|
||||
delete r;
|
||||
}
|
||||
|
||||
@@ -408,6 +408,14 @@ SHERPA_ONNX_API void DecodeMultipleOfflineStreams(
|
||||
|
||||
SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerResult {
|
||||
const char *text;
|
||||
|
||||
// Pointer to continuous memory which holds timestamps
|
||||
//
|
||||
// It is NULL if the model does not support timestamps
|
||||
float *timestamps;
|
||||
|
||||
// number of entries in timestamps
|
||||
int32_t count;
|
||||
// TODO(fangjun): Add more fields
|
||||
} SherpaOnnxOfflineRecognizerResult;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user