如何使用 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 录制用户的声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)