Html 我可以使用 javascript 在网络应用程序上录制语音吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15082689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I use javascript to record voice on a web app?
提问by Tsundoku
It seems I can only use Flash or Java to record voice on a web app. Is there a way of doing it via JavaScript?
看来我只能使用 Flash 或 Java 在网络应用程序上录制语音。有没有办法通过 JavaScript 做到这一点?
回答by Philip Kirkbride
It can be done but the solution won't work across all platforms at the moment.
它可以完成,但该解决方案目前不适用于所有平台。
<input type="file" accept="audio/*;capture=microphone">
请参阅HTML5 媒体捕获
Currently Supported By:
目前支持:
Android 3.0 browser, Chrome for Android (0.16), Firefox Mobile 10.0, iOS6 Safari and Chrome (partial support)
Android 3.0 浏览器、Android 版 Chrome (0.16)、Firefox Mobile 10.0、iOS6 Safari 和 Chrome(部分支持)
Links:
链接:
http://www.html5rocks.com/en/tutorials/getusermedia/intro/
回答by Jani Hyyti?inen
Javascript cannot access your hardware directly. What you need, is a client side technology that can. Flash, for one.
Javascript 无法直接访问您的硬件。您需要的是一种可以的客户端技术。闪存,一个。
Javascript can communicate quite easily with flash, so you can hide your flash recorder and construct your recorder ui with html/js/css.
Javascript 可以很容易地与 Flash 通信,因此您可以隐藏您的 Flash 记录器并使用 html/js/css 构建您的记录器 ui。
Here's one example: https://github.com/jwagener/recorder.js/blob/master/examples/example-1.html
这是一个例子:https: //github.com/jwagener/recorder.js/blob/master/examples/example-1.html
Here's another one: http://blogupstairs.com/flashwavrecorder-javascript-flash-audio-recorder/
这是另一个:http: //blogupstairs.com/flashwavrecorder-javascript-flash-audio-recorder/
I realize this is not EXACTLY what you need, but you didn't tell why you want a JS solution. This doesn't fix the flash dependency problem but it solves the UI problem since you can construct the UI without flash.
我意识到这并不是您真正需要的,但是您没有说明为什么需要 JS 解决方案。这并没有解决 flash 依赖问题,但它解决了 UI 问题,因为您可以在没有 flash 的情况下构建 UI。
回答by tarcnux
Another wellknow solution is WAMI, I know it's not pure javascript but maybe it can help.
另一个众所周知的解决方案是 WAMI,我知道它不是纯 javascript,但也许它可以提供帮助。
"As of this writing, most browsers still do not support WebRTC's getUserMedia(), which promises to give web developers microphone access via Javascript. This project achieves the next best thing for browsers that support Flash. Using the WAMI recorder, you can collect audio on your server without installing any proprietary media server software." https://code.google.com/p/wami-recorder/
“在撰写本文时,大多数浏览器仍然不支持 WebRTC 的 getUserMedia(),它承诺通过 Javascript 为 Web 开发人员提供麦克风访问权限。该项目为支持 Flash 的浏览器实现了下一个最佳选择。使用 WAMI 录音机,您可以收集音频在您的服务器上,而无需安装任何专有媒体服务器软件。” https://code.google.com/p/wami-recorder/
Another example using node.js This example application is written in JavaScript and uses Node and Express for the web server and framework. You will need all three installed on your web server in order for this to work, as well as the Node.js WebAPI Library. nodejs voice recording example
另一个使用 node.js 的示例 此示例应用程序是用 JavaScript 编写的,并使用 Node 和 Express 作为 Web 服务器和框架。您需要在 Web 服务器上安装所有这三个,以及 Node.js WebAPI 库才能使其工作。 nodejs录音示例
回答by Octavian Naicu
Yes there is a pure HTML/JavaScript way but it only works in Firefox and Chrome: http://audior.ec/blog/recording-mp3-using-only-html5-and-javascript-recordmp3-js/
是的,有一种纯 HTML/JavaScript 方式,但它只适用于 Firefox 和 Chrome:http: //audior.ec/blog/recording-mp3-using-only-html5-and-javascript-recordmp3-js/
Direct demo: http://audior.ec/recordmp3js/
直接演示:http: //audior.ec/recordmp3js/