Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
fix(runtime): give AudioFrame deep-copy ownership
wangxiuwen62037b10faa5
diff --git a/runtime/onnxruntime/include/audio.h b/runtime/onnxruntime/include/audio.hindex b14d3b85d..7e889cfbc 100644--- a/runtime/onnxruntime/include/audio.h+++ b/runtime/onnxruntime/include/audio.h@@ -24,6 +24,7 @@ class AudioFrame {AudioFrame();AudioFrame(int len);AudioFrame(const AudioFrame &other);+ AudioFrame& operator=(const AudioFrame &other);AudioFrame(int start, int end, bool is_final);~AudioFrame();diff --git a/runtime/onnxruntime/src/audio.cpp b/runtime/onnxruntime/src/audio.cppindex ba6045f8a..20db14b26 100644--- a/runtime/onnxruntime/src/audio.cpp+++ b/runtime/onnxruntime/src/audio.cpp@@ -151,11 +151,40 @@ AudioFrame::AudioFrame(int len) : len(len)start = 0;}AudioFrame::AudioFrame(const AudioFrame &other)+ : start(other.start), end(other.end), is_final(other.is_final), len(other.len),+ global_start(other.global_start), global_end(other.global_end){+ if (other.data != nullptr && len > 0) {+ data = static_cast<float*>(malloc(sizeof(float) * len));+ if (data != nullptr) {+ memcpy(data, other.data, sizeof(float) * len);+ }+ }+}+AudioFrame& AudioFrame::operator=(const AudioFrame &other)+{+ if (this == &other) {+ return *this;+ }++ float* copied_data = nullptr;+ if (other.data != nullptr && other.len > 0) {+ copied_data = static_cast<float*>(malloc(sizeof(float) * other.len));+ if (copied_data == nullptr) {+ return *this;+ }+ memcpy(copied_data, other.data, sizeof(float) * other.len);+ }++ free(data);start = other.start;end = other.end;- len = other.len;is_final = other.is_final;+ data = copied_data;+ len = other.len;+ global_start = other.global_start;+ global_end = other.global_end;+ return *this;}AudioFrame::AudioFrame(int start, int end, bool is_final):start(start),end(end),is_final(is_final){len = end - start;