From 6427c834dfd97b1f05c6659cdc7ccf010bf82fe1 Mon Sep 17 00:00:00 2001
From: 嘉渊 <wangjiaming.wjm@alibaba-inc.com>
Date: 星期一, 24 四月 2023 19:50:07 +0800
Subject: [PATCH] update
---
funasr/runtime/onnxruntime/src/Audio.cpp | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/funasr/runtime/onnxruntime/src/Audio.cpp b/funasr/runtime/onnxruntime/src/Audio.cpp
index d5d0746..bce3a90 100644
--- a/funasr/runtime/onnxruntime/src/Audio.cpp
+++ b/funasr/runtime/onnxruntime/src/Audio.cpp
@@ -3,7 +3,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <webrtc_vad.h>
#include "Audio.h"
@@ -116,6 +115,12 @@
speech_len);
}
+float Audio::get_time_len()
+{
+ return (float)speech_len / 16000;
+ //speech_len);
+}
+
bool Audio::loadwav(const char *filename)
{
@@ -132,9 +137,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 +236,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 +262,8 @@
speech_data[i] = (float)speech_buff[i] / scale;
}
-
+ AudioFrame* frame = new AudioFrame(speech_len);
+ frame_queue.push(frame);
return true;
}
@@ -407,6 +413,7 @@
#define SPEECH_LEN_20S (16000 * 20)
#define SPEECH_LEN_30S (16000 * 30)
+/*
void Audio::split()
{
VadInst *handle = WebRtcVad_Create();
@@ -465,3 +472,4 @@
}
WebRtcVad_Free(handle);
}
+*/
\ No newline at end of file
--
Gitblit v1.9.1