简体   繁体   English

使用javascript或html5录制具有特定参数的WAV音频

[英]Record wav audio with specific parameters using javascript or html5

Im trying some javascript codes to record wav sound, for example I tried this example: 我正在尝试一些JavaScript代码来录制WAV声音,例如,我尝试了以下示例:

http://webaudiodemos.appspot.com/AudioRecorder/index.html http://webaudiodemos.appspot.com/AudioRecorder/index.html

That I found in this post: 我在这篇文章中发现:

HTML5 record audio to file HTML5将音频录制到文件

But I need to configure this attributes: 但是我需要配置以下属性:

  • Sampling Rate: 8000 Hz 采样率:8000 Hz
  • Bit Resolution: 16 (L16) 位分辨率:16(L16)
  • Encoding: PCM linear (LPCM) 编码:PCM线性(LPCM)
  • Audio channel: Mono 音频通道:单声道

This is not a duplicated post. 这不是重复的帖子。 The difference is that I need to generate the sound with specific configuration, like I said. 所不同的是,我需要像我说的那样生成具有特定配置的声音。 I didn't find any example setting this parameters. 我没有找到设置此参数的任何示例。

You can get the sampling you want with the sampleRate constraint . 您可以使用sampleRate约束获取所需的采样。

navigator.mediaDevices.getUserMedia({audio: {sampleRate: 8000}})

Native PCM encoding is entirely up to the browser, but PCM is simple enough that, given the stream, you can certainly implement it yourself. 原生PCM编码完全取决于浏览器,但是PCM非常简单,只要有流,就可以自己实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM