Android中的声音识别 [英] Sound recognition in Android

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

问题描述

我希望我的 Android 应用能够识别声音.例如我想知道麦克风发出的声音是拍手声还是敲击声还是别的什么.

I want my Android app to recognize sound. For example I want to know if the sound from microphone is a clapping or knocking or something else.

我需要使用数学吗,或者我可以为此使用一些库吗?

Do I need to use math, or can I just use some library for that?

如果有任何用于声音分析的库,请告诉我.谢谢.

If there are any libraries for sound analysis please let me know. Thanks.

推荐答案

Musicg 库对于哨声检测很有用.关于拍手,我不建议使用它,因为它会对每一个响亮的声音(甚至是说话)做出反应.

Musicg library is useful for whistle detection. Concerning claps, I wouldn't recommend use it, cause it reacts to every loud sound (even speech).

对于拍手和其他敲击声检测,我推荐 TarsosDSP.它有一个简单的 API 和丰富的功能(音高检测等).对于拍手检测,您可以使用类似的东西(如果您使用 TarsosDSPAndroid-v3):

For clap and other percussive sounds detection I recommend TarsosDSP. It has a simple API with a rich functionality (pitch detection and so on). For clap detection you can use something like (if you use TarsosDSPAndroid-v3):

MicrophoneAudioDispatcher mDispatcher = new MicrophoneAudioDispatcher((int) SAMPLE_RATE, BUFFER_SIZE, BUFFER_OVERLAP);
double threshold = 8;
double sensitivity = 20;
mPercussionDetector = new PercussionOnsetDetector(22050, 1024, 
        new OnsetHandler() {

            @Override
            public void handleOnset(double time, double salience) {
                Log.d(TAG, "Clap detected!");
            }
        }, sensitivity, threshold);
mDispatcher.addAudioProcessor(mPercussionDetector);
new Thread(mDispatcher).start();

您可以通过调整灵敏度 (0-100) 和阈值 (0-20) 来调整检测器.

You can tune your detector by adjusting sensitivity (0-100) and threshold (0-20).

祝你好运!

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆