特定音高的Android语音识别

标签 android api

我们可以使用 Android 语音识别 API 检测“尖叫声”或“响亮的声音”等吗? 或者是否有任何其他软件/第三方工具可以执行相同的操作?

谢谢, 头巾

最佳答案

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

无需使用复杂的数学或语音识别 API。只需使用 MediaRecorder 及其 getMaxAmplitute() 方法即可。

这是您需要的一些代码。 该算法记录一段时间,然后测量振幅差。如果它很大,那么用户可能发出了很大的声音。

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语音识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5415376/

相关文章:

android - 如何在 android kitkat 中保持服务活跃?

java - ClipboardManager 使用 WorkManager 抛出以下错误 : Can't create handler inside thread that has not called Looper. 准备()

android - 在 21 android 以下的 api 上更改状态/通知栏颜色?

android - 带有 applicationIdSuffix 的 DexGuard

如果没有先前的互联网连接,则无法验证 Android 自签名证书

jquery - 如何每 15 秒刷新一次 Twitter API?

java - 如何使用 lucene API (a AND (b OR c)) 创建嵌套 boolean 查询?

javascript - 如何在 SAILS JS 的 API REST 中使用方法过滤器搜索?

android - 如何创建一个简单的 api 来测试我的移动应用程序,而不必在服务器上编写 api 代码?

php - PHP中如何处理日期格式