From 63cb171bc5f734180195e2428ef4b3a0da93dc43 Mon Sep 17 00:00:00 2001 From: Yabin Li Date: Fri, 5 May 2023 19:12:31 +0800 Subject: [PATCH] Update audio.cpp --- funasr/runtime/onnxruntime/src/audio.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/funasr/runtime/onnxruntime/src/audio.cpp b/funasr/runtime/onnxruntime/src/audio.cpp index 8f46a4f63..e6bfd2848 100644 --- a/funasr/runtime/onnxruntime/src/audio.cpp +++ b/funasr/runtime/onnxruntime/src/audio.cpp @@ -238,6 +238,15 @@ bool Audio::LoadWav(const char *filename, int32_t* sampling_rate) return false; } + if (!header.Validate()) { + return false; + } + + header.SeekToDataChunk(is); + if (!is) { + return false; + } + *sampling_rate = header.sample_rate; // header.subchunk2_size contains the number of bytes in the data. // As we assume each sample contains two bytes, so it is divided by 2 here @@ -519,4 +528,4 @@ void Audio::Split(Model* recog_obj) frame_queue.push(frame); frame = NULL; } -} \ No newline at end of file +}