本文介绍了Android的语音识别特定的声音音调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以检测'尖叫'或'响亮的声音等采用Android语音识别的API?或者是有其他的软件/第三方工具,它可以这样做?

Can we detect 'scream' or 'loud sound' etc using Android Speech Recognition APIs?Or is there is any other software/third party tool that can do the same?

谢谢,KAPS

推荐答案

您的意思是实现一个拍板?

You mean implement a clapper?

有没有必要使用花哨的数学或语音识别API。只需使用MediaRecorder及其getMaxAmplitute()方法。

There's no need to use fancy math or the speech recognition API. Just use the MediaRecorder and its getMaxAmplitute() method.

下面是一些code,你将需要。的算法,记录了一段时间,然后测量amplitute差。如果是大,那么用户可能做出一个响亮的声音。

Here is some of code you'll need.The algorithm, records for a period of time and then measures the amplitute difference. If it is large, then the user probably made a loud sound.

public void recordClap()
{
    recorder.start();

    int startAmplitude = recorder.getMaxAmplitude();
    Log.d(D_LOG, "starting amplitude: " + startAmplitude);
boolean ampDiff;
do
{
    Log.d(D_LOG, "waiting while taking in input");
    waitSome();
    int finishAmplitude = 0;
    try
    {
        finishAmplitude = recorder.getMaxAmplitude();
    }
    catch (RuntimeException re)
    {
        Log.e(D_LOG, "unable to get the max amplitude " + re);
    }
    ampDiff = checkAmplitude(startAmplitude, finishAmplitude);
    Log.d(D_LOG, "finishing amp: " + finishAmplitude + " difference: " + ampDiff );
}
while (!ampDiff && recorder.isRecording());

}

private boolean checkAmplitude(int startAmplitude, int finishAmplitude)
{
    int ampDiff = finishAmplitude - startAmplitude;
    Log.d(D_LOG, "amplitude difference " + ampDiff);
    return (ampDiff >= 10000);
}

这篇关于Android的语音识别特定的声音音调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-25 23:29