Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Oct 19, 2023
1 parent e4a7248 commit 34f8678
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions sherpa-onnx/c-api/c-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult(
}

void DestroyOnlineRecognizerResult(const SherpaOnnxOnlineRecognizerResult *r) {
delete[] r->text;
delete[] r->json;
delete[] r->tokens;
delete[] r->tokens_arr;
delete[] r->timestamps;
delete r;
if (r) {
delete[] r->text;
delete[] r->json;
delete[] r->tokens;
delete[] r->tokens_arr;
delete[] r->timestamps;
delete r;
}
}

void Reset(SherpaOnnxOnlineRecognizer *recognizer,
Expand Down Expand Up @@ -387,9 +389,11 @@ const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult(

void DestroyOfflineRecognizerResult(
const SherpaOnnxOfflineRecognizerResult *r) {
delete[] r->text;
delete[] r->timestamps;
delete r;
if (r) {
delete[] r->text;
delete[] r->timestamps;
delete r;
}
}

// ============================================================
Expand Down Expand Up @@ -517,8 +521,10 @@ const SherpaOnnxSpeechSegment *SherpaOnnxVoiceActivityDetectorFront(
}

void SherpaOnnxDestroySpeechSegment(const SherpaOnnxSpeechSegment *p) {
delete[] p->samples;
delete p;
if (p) {
delete[] p->samples;
delete p;
}
}

void SherpaOnnxVoiceActivityDetectorReset(SherpaOnnxVoiceActivityDetector *p) {
Expand Down Expand Up @@ -583,8 +589,10 @@ const SherpaOnnxGeneratedAudio *SherpaOnnxOfflineTtsGenerate(

SHERPA_ONNX_API void SherpaOnnxDestroyOfflineTtsGeneratedAudio(
const SherpaOnnxGeneratedAudio *p) {
delete[] p->samples;
delete p;
if (p) {
delete[] p->samples;
delete p;
}
}

int32_t SherpaOnnxDestroyOfflineWriteWave(const SherpaOnnxGeneratedAudio *p,
Expand Down

0 comments on commit 34f8678

Please sign in to comment.