如何使用 Javascript/PHP 录制用户的声音?

How can I record a user#39;s voice using Javascript/PHP?(如何使用 Javascript/PHP 录制用户的声音?)
本文介绍了如何使用 Javascript/PHP 录制用户的声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我目前正在尝试创建一个测试站点,允许用户记录语音笔记并将其保存到他们的帐户中.使用 PHP 或 JavaScript 执行此操作的最佳方法是什么?

I am currently trying to make a test site that allows users to record voice-notes and save it to their account. What is the best way to do this using either PHP or JavaScript?

我希望此过程的步骤是:

The steps that I am looking to have for this process are:

1) 用户点击录制按钮.2) 启动记录序列.3) 停止序列.4) 命名文件并将其发送到服务器.

1) User clicking the record button. 2) Initiation of the recording sequence. 3) Stopping the sequence. 4) Naming of the file and sending it over to the server.

我的主要查询集中在第二步,在这里我需要某种机制来与用户的麦克风交互以录制语音.我对网络开发本身还是个新手,我不知道如何使用 JavaScript 调用录音.

My main query is focused on the 2nd step, where I'd need some mechanism that would interact with the user's mic to record the voice. I am still new to web dev per se and I do not know how I can invoke voice recording using JavaScript.

在 Google 中搜索后,我在 StackOverflow 中找到了一些解决类似问题的链接,但答案没有帮助.许多解决方案都指向 Flash,但我想尽可能避免这种情况.所以我的问题确实归结为是否可以使用 JavaScript 录制语音?如果可以,如何录制?"

Upon searching in Google, I found some links in StackOverflow which addressed similar issues but the answers were not helpful. A lot of solutions pointed to Flash but I would like to avoid that as much as possible. So my question does boil down to "Is it possible to record voice using JavaScript? If yes, how?"

提前致谢.

推荐答案

HTML5 音频 API 在浏览器中并未得到广泛支持,我认为它适用于 Chrome,而 Firefox 最近已将它添加到它的 nightlies ... 浏览器前缀是此阶段需要,但通用 API 是...

The HTML5 Audio API is not widely supported in browsers, I think it works in Chrome and Firefox has had it recently added to its nightlies... Browser prefixes are required at this stage but the general API is...

navigator.getUserMedia({audio: true}, function(stream) { /* do stuff */ });

那么对于 Chrome 来说就是 webkitGetUserMedia,对于 Firefox 来说就是 mozGetUserMedia.

So that would be webkitGetUserMedia for Chrome and mozGetUserMedia for Firefox.

您现在更一致的选择是通过浏览器插件(例如 Flash 或 Java)或创建用户需要安装的桌面客户端.

Your more consistent options right now are via browser plugins such as Flash or Java or to create a desktop client that the user would need to install.

有关 getUserMedia 的相关资源:

Resources of interest regarding getUserMedia:

  • getUserMedia 简介
  • getUserMedia 添加到 Firefox nightlies
  • Chromium 中 getUserMedia 的纯音频问题

以下问题可能会进一步帮助您:

The following question may assist you further:

教程使用 flash 或 java servlet 将麦克风数据从浏览器上传到服务器?

这篇关于如何使用 Javascript/PHP 录制用户的声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Encryption in JavaScript and decryption with PHP(JavaScript 加密和 PHP 解密)
Best solution to protect PHP code without encryption(无需加密即可保护 PHP 代码的最佳解决方案)
PHP AES encrypt / decrypt(PHP AES 加密/解密)
Upgrading my encryption library from Mcrypt to OpenSSL(将我的加密库从 Mcrypt 升级到 OpenSSL)
How to add/remove PKCS7 padding from an AES encrypted string?(如何从 AES 加密字符串中添加/删除 PKCS7 填充?)
How do I upgrade from PHP 7.0 to 7.3 on google cloud platform?(如何在谷歌云平台上从 PHP 7.0 升级到 7.3?)