From bf3a1f11054e0215a6b24720359055e46d409ec9 Mon Sep 17 00:00:00 2001
From: lyblsgo <lyblsgo@163.com>
Date: 星期一, 27 三月 2023 15:36:36 +0800
Subject: [PATCH] c++ onnxruntime supports loading configs from model files
---
funasr/runtime/onnxruntime/src/Audio.cpp | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/funasr/runtime/onnxruntime/src/Audio.cpp b/funasr/runtime/onnxruntime/src/Audio.cpp
index d5d0746..f2dc956 100644
--- a/funasr/runtime/onnxruntime/src/Audio.cpp
+++ b/funasr/runtime/onnxruntime/src/Audio.cpp
@@ -116,6 +116,12 @@
speech_len);
}
+float Audio::get_time_len()
+{
+ return (float)speech_len / 16000;
+ //speech_len);
+}
+
bool Audio::loadwav(const char *filename)
{
@@ -132,9 +138,9 @@
fp = fopen(filename, "rb");
if (fp == nullptr)
return false;
- fseek(fp, 0, SEEK_END);
- uint32_t nFileLen = ftell(fp);
- fseek(fp, 44, SEEK_SET);
+ fseek(fp, 0, SEEK_END); /*瀹氫綅鍒版枃浠舵湯灏�*/
+ uint32_t nFileLen = ftell(fp); /*寰楀埌鏂囦欢澶у皬*/
+ fseek(fp, 44, SEEK_SET); /*璺宠繃wav鏂囦欢澶�*/
speech_len = (nFileLen - 44) / 2;
speech_align_len = (int)(ceil((float)speech_len / align_size) * align_size);
@@ -231,7 +237,7 @@
size_t nOffset = 0;
-#define WAV_HEADER_SIZE 44
+
speech_len = nBufLen / 2;
speech_align_len = (int)(ceil((float)speech_len / align_size) * align_size);
@@ -257,7 +263,8 @@
speech_data[i] = (float)speech_buff[i] / scale;
}
-
+ AudioFrame* frame = new AudioFrame(speech_len);
+ frame_queue.push(frame);
return true;
}
--
Gitblit v1.9.1