javascript - 从浏览器中的麦克风获取音频输入并提取特征

标签 javascript audio html5-audio audio-recording

什么是最好的库编程语言来捕获浏览器中麦克风的原始音频输入,然后能够从中提取特征?

我知道我可以在 JavaScript 中使用 getUserMedia() 来捕获音频,但是它可以使用 JavaScript 轻松处理该音频吗?还是我应该换个方向?

最佳答案

是的,有!

最容易使用的是 Microphone.js

USAGE

To instantiate the main Microphone object, use the create function:

require(['microphone'], function(microphone){
 var Microphone = microphone.create();
 });

To activate voice processing, use the on function:
Microphone.on(); The primary usage of microphone.js is through the addCommand function. This takes two main arguments: patterns, which is assumed to be an array of regular expressions, and the callback, which is the code that will be run if any of the patterns specified match the voice input:

Microphone.addCommand({
    patterns: [new RegExp('dog', 'i')],
    callback: function() {
      alert("no, cats!");
    }
});

The callback also receives two arguments: the current Microphone instance, allowing the user to inspect the currentTranscript and other relevant information; and the matched CommandString, which exposes the matched string, and the args, which is an array of the words following the matched string. This allows you to do things like:

Microphone.addCommand({
    patterns: [new RegExp("display", "i")],
    callback: function(mic, command) {
      $("#" + command.args[0]).show();
    }
});

Thus, if you said "display foo", the DOM element with an id of foo would be shown (presuming you are using jQuery, of course).

还有Web Speech API ,它更复杂,但也有更多功能。

getUserMedia()方法仍然是最好的方法,在我看来,随意选择!

关于javascript - 从浏览器中的麦克风获取音频输入并提取特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42008613/

相关文章:

javascript - 出现错误 - 未捕获( promise 中)DOMException : play() failed because the user didn't interact with the document first

javascript - 替换(淡化)主体背景而不影响嵌套元素

javascript - 如何格式化日期以获得日期和月份的名称?

c# - unity “Can not play a disabled audio source”

ios - Swift 3 音频无法播放

android - 如何使用 html5 音频标签在 Android 上使用 phonegap 播放本地 mp3?

javascript - 在 Firefox 中捕获页面的 x 和 y 坐标

JavaScript 放在顶部还是底部?

android - 根据关联的音频文件拦截 Android 通知?

HTML5 大纲和 "Unsupported Browser"消息?