/*
* endsil.c
*
* Code generation for function 'endsil'
*
* C source code generated on: Wed Mar 02 11:54:34 2016
*
*/
/* Include files */
#include "rt_nonfinite.h"
#include "endsil.h"
#include "endsil_emxutil.h"
/* Function Definitions */
void endsil(const emxArray_real_T *input, real32_T fs, emxArray_real_T *out)
{
emxArray_real_T *bgSample;
real32_T samplePerFrame;
real32_T bgSampleCount;
int32_T k;
int32_T d;
int32_T xs;
real_T cUnVoiced;
real_T meanVal;
int32_T ix;
real_T xbar;
real_T r;
int8_T voicedUnvoiced[30000];
int8_T voiced[30000];
real32_T f0;
int32_T i0;
emxInit_real_T(&bgSample, 2);
samplePerFrame = (real32_T)floor(fs / 100.0F);
bgSampleCount = (real32_T)floor(fs / 5.0F);
/* according to formula, 1600 sample needed for 8 khz */
/* ---------- */
/* calculation of mean and std */
k = bgSample->size[0] * bgSample->size[1];
bgSample->size[0] = 1;
bgSample->size[1] = 0;
emxEnsureCapacity((emxArray__common *)bgSample, k, (int32_T)sizeof(real_T));
for (d = 0; d < (int32_T)bgSampleCount; d++) {
xs = bgSample->size[1];
k = bgSample->size[0] * bgSample->size[1];
bgSample->size[1] = xs + 1;
emxEnsureCapacity((emxArray__common *)bgSample, k, (int32_T)sizeof(real_T));
bgSample->data[xs] = input->data[(int32_T)(1.0F + (real32_T)d) - 1];
}
if (bgSample->size[1] == 0) {
cUnVoiced = 0.0;
} else {
cUnVoiced = bgSample->data[0];
for (k = 2; k <= bgSample->size[1]; k++) {
cUnVoiced += bgSample->data[k - 1];
}
}
meanVal = cUnVoiced / (real_T)bgSample->size[1];
if (bgSample->size[1] > 1) {
d = bgSample->size[1] - 1;
} else {
d = bgSample->size[1];
}
if (bgSample->size[1] == 0) {
cUnVoiced = rtNaN;
} else {
ix = 0;
xbar = bgSample->data[0];
for (k = 0; k <= bgSample->size[1] - 2; k++) {
ix++;
xbar += bgSample->data[ix];
}
xbar /= (real_T)bgSample->size[1];
ix = 0;
r = bgSample->data[0] - xbar;
cUnVoiced = r * r;
for (k = 0; k <= bgSample->size[1] - 2; k++) {
ix++;
r = bgSample->data[ix] - xbar;
cUnVoiced += r * r;
}
cUnVoiced /= (real_T)d;
}
emxFree_real_T(&bgSample);
xbar = sqrt(cUnVoiced);
/* ---------- */
/* identify voiced or not for each value */
for (k = 0; k < 30000; k++) {
voicedUnvoiced[k] = 0;
voiced[k] = 0;
}
for (d = 0; d < input->size[0]; d++) {
cUnVoiced = input->data[d] - meanVal;
if (fabs(cUnVoiced) / xbar > 0.3) {
voiced[d] = 1;
} else {
voiced[d] = 0;
}
}
/* identify voiced or not for each frame */
/* discard insufficient samples of last frame */
if (samplePerFrame == 0.0F) {
bgSampleCount = (real32_T)input->size[0];
} else if (samplePerFrame == samplePerFrame) {
bgSampleCount = (real32_T)input->size[0] - (real32_T)floor((real32_T)
input->size[0] / samplePerFrame) * samplePerFrame;
} else {
bgSampleCount = (real32_T)input->size[0] / samplePerFrame;
bgSampleCount = (bgSampleCount - (real32_T)floor(bgSampleCount)) *
samplePerFrame;
}
bgSampleCount = ((real32_T)input->size[0] - bgSampleCount) / samplePerFrame;
for (d = 0; d < (int32_T)bgSampleCount; d++) {
xbar = 0.0;
cUnVoiced = 0.0;
f0 = ((1.0F + (real32_T)d) * samplePerFrame - samplePerFrame) + 1.0F;
k = (int32_T)((1.0F + (real32_T)d) * samplePerFrame + (1.0F - f0));
for (ix = 0; ix < k; ix++) {
if (voiced[(int32_T)(f0 + (real32_T)ix) - 1] == 1) {
xbar++;
} else {
cUnVoiced++;
}
}
/* mark frame for voiced/unvoiced */
if (xbar > cUnVoiced) {
voicedUnvoiced[(int32_T)(real32_T)(1 + d) - 1] = 1;
} else {
voicedUnvoiced[(int32_T)(real32_T)(1 + d) - 1] = 0;
}
}
k = out->size[0] * out->size[1];
out->size[0] = 1;
out->size[1] = 0;
emxEnsureCapacity((emxArray__common *)out, k, (int32_T)sizeof(real_T));
/* ----- */
for (d = 0; d < (int32_T)bgSampleCount; d++) {
if (voicedUnvoiced[(int32_T)(real32_T)(1 + d) - 1] == 1) {
f0 = ((1.0F + (real32_T)d) * samplePerFrame - samplePerFrame) + 1.0F;
k = (int32_T)((1.0F + (real32_T)d) * samplePerFrame + (1.0F - f0));
for (ix = 0; ix < k; ix++) {
xs = out->size[1];
i0 = out->size[0] * out->size[1];
out->size[1] = xs + 1;
emxEnsureCapacity((emxArray__common *)out, i0, (int32_T)sizeof(real_T));
out->data[xs] = input->data[(int32_T)(f0 + (real32_T)ix) - 1];
}
}
}
/* ---display plot and play both sounds */
/* figure; plot(y); */
/* figure; plot(silenceRemovedSignal); */
/* %%play */
/* sound(y,Fs); */
/* sound(silenceRemovedSignal,Fs); */
}
/* End of code generation (endsil.c) */
没有合适的资源?快使用搜索试试~ 我知道了~
speech_recognition.rar_speech recognition_speech-recognition
共95个文件
mat:38个
m:11个
wav:11个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 149 浏览量
2022-07-15
05:01:35
上传
评论
收藏 1MB RAR 举报
温馨提示
speech recognition complete simulation
资源推荐
资源详情
资源评论
收起资源包目录
speech_recognition.rar (95个子文件)
major training - password
test_online.mat 971B
main.m 227B
unlock.wav 31KB
check.m 2KB
test_music.mat 971B
1.wav 23KB
unlock1.wav 31KB
tes_exit.mat 971B
test_star.mat 971B
SSBoll79.m 6KB
tes_table.mat 971B
test_monday.mat 971B
test_table.mat 971B
test_sun.mat 969B
test_window.mat 971B
aftr1.wav 23KB
test_hel.mat 971B
test_play.mat 971B
niise.wav 31KB
hello1.wav 31KB
1noise.wav 23KB
test_india.mat 971B
test_apple.mat 971B
test_banana.mat 556KB
remnoise.m 172B
test_pass.mat 971B
test_book.mat 971B
test_cycle.mat 971B
endsilence.prj 22KB
test_count.mat 173B
test_carrot.mat 971B
aftr1noise.wav 31KB
test_orange.mat 971B
test_forward.mat 971B
test_letter.mat 971B
test_fan.mat 971B
test_answer.mat 971B
test_search.mat 971B
codegen
mex
endsil
html
endsil1_watch.html 6KB
mex_warning.html 1KB
index.html 18KB
rtwshrink.js 6KB
coder_report.mat 274KB
hilite_warning.png 3KB
endsil1_mcode.html 18KB
index.css 127B
exe
endsil
endsil.c 5KB
rt_nonfinite.c 2KB
endsil_initialize.c 403B
rtGetInf.c 3KB
endsil_emxAPI.c 2KB
rtGetNaN.h 378B
endsil_emxutil.c 2KB
endsil_terminate.h 501B
rtGetInf.h 453B
endsil_initialize.h 507B
html
endsil1_watch.html 6KB
index.html 17KB
rtwshrink.js 6KB
metrics.html 2KB
coder_report.mat 273KB
hilite_warning.png 3KB
endsil1_mcode.html 19KB
index.css 127B
rtwtypes.h 5KB
endsil.h 500B
endsil_terminate.c 411B
rt_nonfinite.h 1KB
rtw_proj.tmw 164B
codeInfo.mat 6KB
endsil_ref.rsp 0B
endsil_emxutil.h 775B
rtGetNaN.c 2KB
endsil_types.h 1KB
endsil_emxAPI.h 863B
test_exit.mat 971B
hi_pre.wav 23KB
endsil.m 2KB
test_bus.mat 971B
CBTemp.mat 1KB
train.m 3KB
vqsplit.m 10KB
hello.wav 31KB
dist.m 527B
preemp.m 792B
test_grant.mat 971B
major.m 3KB
test_rose.mat 971B
aud.wav 31KB
maj.m 2KB
test_open.mat 971B
test_receive.mat 971B
test_charge.mat 971B
test_help.mat 971B
test_unlock.mat 971B
共 95 条
- 1
资源评论
钱亚锋
- 粉丝: 86
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Android源码新基线代码更新的方法
- 1_二级程序设计题(34).rar
- 二级程序调试题(填空27+改错7).docx
- HM2314-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 基于深度学习的危险驾驶检测算法python源码+视频判断是否闭眼或者张开嘴哈欠和吸烟打电话等手势行为功能涵盖7类.zip
- Free-Fs 开源文件管理系统
- HM2314B-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 毕业设计:Python高校学生学业预警系统(源码 + 数据库 + 说明文档)
- HM2312-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 毕业设计:Python的在线自主评测系统(源码 + 数据库 + 说明文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功