From 0b5ab0709e8292447b314f4f02c74becafd6ce76 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期二, 19 九月 2023 12:33:53 +0800
Subject: [PATCH] wechat
---
funasr/runtime/onnxruntime/src/audio.cpp | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/funasr/runtime/onnxruntime/src/audio.cpp b/funasr/runtime/onnxruntime/src/audio.cpp
index 94fcefc..d62151e 100644
--- a/funasr/runtime/onnxruntime/src/audio.cpp
+++ b/funasr/runtime/onnxruntime/src/audio.cpp
@@ -1112,6 +1112,8 @@
if(asr_mode != ASR_OFFLINE){
if(buff_len >= step){
frame = new AudioFrame(step);
+ frame->global_start = speech_start;
+ frame->global_end = speech_start + step/seg_sample;
frame->data = (float*)malloc(sizeof(float) * step);
memcpy(frame->data, all_samples.data()+start-offset, step*sizeof(float));
asr_online_queue.push(frame);
@@ -1138,6 +1140,8 @@
if(asr_mode != ASR_OFFLINE){
frame = new AudioFrame(end-start);
frame->is_final = true;
+ frame->global_start = speech_start_i;
+ frame->global_end = speech_end_i;
frame->data = (float*)malloc(sizeof(float) * (end-start));
memcpy(frame->data, all_samples.data()+start-offset, (end-start)*sizeof(float));
asr_online_queue.push(frame);
@@ -1147,6 +1151,8 @@
if(asr_mode != ASR_ONLINE){
frame = new AudioFrame(end-start);
frame->is_final = true;
+ frame->global_start = speech_start_i;
+ frame->global_end = speech_end_i;
frame->data = (float*)malloc(sizeof(float) * (end-start));
memcpy(frame->data, all_samples.data()+start-offset, (end-start)*sizeof(float));
asr_offline_queue.push(frame);
@@ -1168,6 +1174,8 @@
if(asr_mode != ASR_OFFLINE){
if(buff_len >= step){
frame = new AudioFrame(step);
+ frame->global_start = speech_start;
+ frame->global_end = speech_start + step/seg_sample;
frame->data = (float*)malloc(sizeof(float) * step);
memcpy(frame->data, all_samples.data()+start-offset, step*sizeof(float));
asr_online_queue.push(frame);
@@ -1191,6 +1199,8 @@
if(asr_mode != ASR_ONLINE){
frame = new AudioFrame(end-offline_start);
frame->is_final = true;
+ frame->global_start = speech_offline_start;
+ frame->global_end = speech_end_i;
frame->data = (float*)malloc(sizeof(float) * (end-offline_start));
memcpy(frame->data, all_samples.data()+offline_start-offset, (end-offline_start)*sizeof(float));
asr_offline_queue.push(frame);
@@ -1207,6 +1217,8 @@
}
frame = new AudioFrame(step);
frame->is_final = is_final;
+ frame->global_start = (int)((start+sample_offset)/seg_sample);
+ frame->global_end = frame->global_start + step/seg_sample;
frame->data = (float*)malloc(sizeof(float) * step);
memcpy(frame->data, all_samples.data()+start-offset+sample_offset, step*sizeof(float));
asr_online_queue.push(frame);
@@ -1215,6 +1227,8 @@
}else{
frame = new AudioFrame(0);
frame->is_final = true;
+ frame->global_start = speech_start; // in this case start >= end
+ frame->global_end = speech_end_i;
asr_online_queue.push(frame);
frame = NULL;
}
--
Gitblit v1.9.1