转载自:http://ganeshtiwaridotcomdotnp.blogspot.com/2011/08/silence-removal-and-end-point-detection_29.html

For the purpose of silence removal of captured sound, we used the algorithm in our final year project.

In this post, I am publishing the endpoint detection and silence removal code ( implementation of this algorithm in JAVA).

These links might be useful to you as well.

The constructor of following java class EndPointDetection takes two parameters

      1. array of original signal's amplitude data : float[] originalSignal
      2. sampling rate of original signal in Hz : int samplingRate
package org.ioe.tprsa.audio.preProcessings;
/**
* @author Ganesh Tiwari
* @reference 'A New Silence Removal and Endpoint Detection Algorithm
* for Speech and Speaker Recognition Applications' by IIT, Khragpur
*/
public class EndPointDetection {
private float[] originalSignal; //input
private float[] silenceRemovedSignal;//output
private int samplingRate;
private int firstSamples;
private int samplePerFrame;
public EndPointDetection(float[] originalSignal, int samplingRate) {
this.originalSignal = originalSignal;
this.samplingRate = samplingRate;
samplePerFrame = this.samplingRate / 1000;
firstSamples = samplePerFrame * 200;// according to formula
}
public float[] doEndPointDetection() {
// for identifying each sample whether it is voiced or unvoiced
float[] voiced = new float[originalSignal.length];
float sum = 0;
double sd = 0.0;
double m = 0.0;
// 1. calculation of mean
for (int i = 0; i < firstSamples; i++) {
sum += originalSignal[i];
}
m = sum / firstSamples;// mean
sum = 0;// reuse var for S.D. // 2. calculation of Standard Deviation
for (int i = 0; i < firstSamples; i++) {
sum += Math.pow((originalSignal[i] - m), 2);
}
sd = Math.sqrt(sum / firstSamples);
// 3. identifying one-dimensional Mahalanobis distance function
// i.e. |x-u|/s greater than ####3 or not,
for (int i = 0; i < originalSignal.length; i++) {
if ((Math.abs(originalSignal[i] - m) / sd) > 0.3) { //0.3 =THRESHOLD.. adjust value yourself
voiced[i] = 1;
} else {
voiced[i] = 0;
}
}
// 4. calculation of voiced and unvoiced signals
// mark each frame to be voiced or unvoiced frame
int frameCount = 0;
int usefulFramesCount = 1;
int count_voiced = 0;
int count_unvoiced = 0;
int voicedFrame[] = new int[originalSignal.length / samplePerFrame];
// the following calculation truncates the remainder
int loopCount = originalSignal.length - (originalSignal.length % samplePerFrame);
for (int i = 0; i < loopCount; i += samplePerFrame) {
count_voiced = 0;
count_unvoiced = 0;
for (int j = i; j < i + samplePerFrame; j++) {
if (voiced[j] == 1) {
count_voiced++;
} else {
count_unvoiced++;
}
}
if (count_voiced > count_unvoiced) {
usefulFramesCount++;
voicedFrame[frameCount++] = 1;
} else {
voicedFrame[frameCount++] = 0;
}
}
// 5. silence removal
silenceRemovedSignal = new float[usefulFramesCount * samplePerFrame];
int k = 0;
for (int i = 0; i < frameCount; i++) {
if (voicedFrame[i] == 1) {
for (int j = i * samplePerFrame; j < i * samplePerFrame + samplePerFrame; j++) {
silenceRemovedSignal[k++] = originalSignal[j];
}
}
}
// end
return silenceRemovedSignal;
}
}

The MATLAB implementation of this algorithm is also available.

问:Hi ganesh, So Is impossible listen the voice after normalizePCM and endpointdetection?

答:you can play the recorded audio after doing those time domain operations.
  you need to play the pcm array using the code : http://ganeshtiwaridotcomdotnp.blogspot.com/2011/12/java-audio-playing-pcm-amplitude-array.html

  you can find other codes related to sound processing in java here :
  http://ganeshtiwaridotcomdotnp.blogspot.com/search/label/Audio%20Processing

Silence Removal and End Point Detection JAVA Code(音频删除静音与结束判断)的更多相关文章

  1. Silence Removal and End Point Detection MATLAB Code

    转载自:http://ganeshtiwaridotcomdotnp.blogspot.com/2011/08/silence-removal-and-end-point-detection.html ...

  2. Java语言编码规范(Java Code Conventions)

    Java语言编码规范(Java Code Conventions) 名称 Java语言编码规范(Java Code Conventions) 译者 晨光(Morning) 简介 本文档讲述了Java语 ...

  3. java code to byte code--partone--reference

    Understanding how Java code is compiled into byte code and executed on a Java Virtual Machine (JVM) ...

  4. [转]Java Code Examples for android.util.JsonReader

    [转]Java Code Examples for android.util.JsonReader The following are top voted examples for showing h ...

  5. SQL to Java code for Elasticsearch

    Elasticsearch虽然定位为Search Engine,但是因其可以持久化数据,很多时候,我们把Elasticsearch当成Database用,但是Elasticsearch不支持SQL,就 ...

  6. JUnit单元测试教程(翻译自Java Code Geeks)

    JUnit单元测试教程--终极指南 JUnit单元测试教程终极指南 说明 单元测试简介 1 什么是单元测试 2 测试覆盖 3 Java中的单元测试 JUnit简介 1 使用Eclipse实现简单JUn ...

  7. Java Code Style

    近期困惑于团队成员代码风格迥异,代码质量不可控,作为一名老司机,忧患于后期服务的可维护性,多次一对一的代码Review,耗时耗力不说,效果也不明显.痛定思痛,多次反思之后得出结论:无规矩不成方圆,可靠 ...

  8. 玩转Eclipse — 自动代码生成的Java Code Template

    文章转载地址:点击打开链接 当代码写到一定程度之后,就会发现很多代码都被重复地敲了N多遍,甚至毫不夸张地说:闭着眼睛都能敲出来.大量地敲这些重复地代码,除了锻炼敲键盘的速度,基本上没有其他益处,但是长 ...

  9. Use formatter to format your JAVA code

    In order to make the codes looks unified and make it easy to understand, it's better to use the same ...

随机推荐

  1. Dubbo源码分析(6):Code2

    背景 定义解码和编码方法. Code2是Code的升级版本. 类图 问题 DubboCodec的父类已经实现了Code2接口并且DubboCodec没有实现Code2接口,为什么要implement ...

  2. SpringBoot测试Controller层

    一.准备工作 1.导入测试依赖 <dependency> <groupId>org.springframework.boot</groupId> <artif ...

  3. call,apply,bind的用法及区别

    <script> function test(){ console.log(this) } // new test(); //函数调用call方法的时候,就会执行. //call的参数:第 ...

  4. 飞扬的小鸟 DP

    飞扬的小鸟 DP 细节有点恶心的DP,设\(f[i][j]\)表示横坐标为\(i\)(从\(0\)开始)高度为\(j\)时,屏幕点击的最小次数为\(f[i][j]\),转移便很好写了,这里要注意枚举当 ...

  5. EasyUI日期时间框DateTimeBox

    WEB DEMO 日期时间框 DateTimeBox <!DOCTYPE html> <html> <HTML> <head> <HEAD> ...

  6. 印象笔记作为todo(GTD相关)的一个尝试

    印象笔记作为todo(GTD相关)的一个尝试 上来说结果: 失败 原则上的原因: 印象笔记作为一个比较重的笔记, 重点也不在于这一点, 虽然是可以新建清单之类的. 还是比较小巧的好一些. 最后使用的软 ...

  7. python 链表的反转

    code #!/usr/bin/python # -*- coding: utf- -*- class ListNode: def __init__(self,x): self.val=x self. ...

  8. Intellij IDEA 从入门到上瘾 图文教程

    1. IDEA VS Eclipse 核心术语比较 ​ 由下图可见:两者最大的转变就在于工作空间概念的转变,并且在IDEA当中,Project和 Module是作为两个不同的概念,对项目结构是具有重大 ...

  9. html5的 embed元素 和 object元素

    html5的 embed元素 和 object元素 一.总结 一句话总结: embed定义嵌入的内容,比如插件,比如flash object定义定义一个嵌入的对象,用于包含对象,比如图像.音频.视频. ...

  10. 在Windows下编译Cef3.2623并加入mp3、mp4支持(附带源码包和最终DLL)《转》

    https://blog.csdn.net/zhuhongshu/article/details/54193842 源码包下载地址:点我下载 最终Dll.Lib.PDB.头文件下载地址(release ...