0

音频降噪音,回声消除,自动增益代码示例

 2 years ago
source link: https://blog.p2hp.com/archives/8475
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

音频降噪音,回声消除,自动增益代码示例 | Lenix Blog

json

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <style>
    html, body{
      height: 100%;
      width: 100%;
    }
    #video{
      height: 300px;
      width: 300px;
    }
  </style>
  <script>
    $(() => {
      var constraints =  {
        audio: {
          echoCancellationType: 'system',//browser|system
          echoCancellation: true,
          noiseSuppression: true,
          autoGainControl: false,
          sampleRate:24000,
          sampleSize:16,
          channelCount:2,
          volume:0.5
        },
        video: {
          width:320,
          height:240,
          frameRate:{ideal:60, min:10}
        }
      }

      navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
        $('#video')[0].srcObject = stream;
        let statusHtml = '';
        stream.getTracks().forEach((track) => {
          statusHtml = statusHtml + track.kind+":"+JSON.stringify(track.getSettings(), null, 2)+'<br>';
          console.log('settings:', track.getSettings());
          console.log('capabilities:', track.getCapabilities());
        })
        $('#status').html(statusHtml);
      }).catch((err) => {
        console.log(err);
      });
    });
  </script>
</head>
<body>
  <h1> 音频降噪音,回声消除,自动增益测试</h1>
  <p>尝试更改 echoCancellation, noiseSuppression ,autoGainControl属性的值 .</p>
  <div>
  <video id='video' autoplay='false' playsinline='false'></video>
  <pre id='status'></pre>
  </div>
  </body>
</html>
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  6. <style>
  7. html, body{
  8. height: 100%;
  9. width: 100%;
  10. #video{
  11. height: 300px;
  12. width: 300px;
  13. </style>
  14. <script>
  15. $(() => {
  16. var constraints = {
  17. audio: {
  18. echoCancellationType: 'system',//browser|system
  19. echoCancellation: true,
  20. noiseSuppression: true,
  21. autoGainControl: false,
  22. sampleRate:24000,
  23. sampleSize:16,
  24. channelCount:2,
  25. volume:0.5
  26. video: {
  27. width:320,
  28. height:240,
  29. frameRate:{ideal:60, min:10}
  30. navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
  31. $('#video')[0].srcObject = stream;
  32. let statusHtml = '';
  33. stream.getTracks().forEach((track) => {
  34. statusHtml = statusHtml + track.kind+":"+JSON.stringify(track.getSettings(), null, 2)+'<br>';
  35. console.log('settings:', track.getSettings());
  36. console.log('capabilities:', track.getCapabilities());
  37. $('#status').html(statusHtml);
  38. }).catch((err) => {
  39. console.log(err);
  40. </script>
  41. </head>
  42. <body>
  43. <h1> 音频降噪音,回声消除,自动增益测试</h1>
  44. <p>尝试更改 echoCancellation, noiseSuppression ,autoGainControl属性的值 .</p>
  45. <div>
  46. <video id='video' autoplay='false' playsinline='false'></video>
  47. <pre id='status'></pre>
  48. </div>
  49. </body>
  50. </html>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <style>
    html, body{
      height: 100%;
      width: 100%;
    }
    #video{
      height: 300px;
      width: 300px;
    }
  </style>
  <script>
    $(() => {
      var constraints =  {
        audio: {
          echoCancellationType: 'system',//browser|system
          echoCancellation: true,
          noiseSuppression: true,
          autoGainControl: false,
          sampleRate:24000,
          sampleSize:16,
          channelCount:2,
          volume:0.5
        },
        video: {
          width:320,
          height:240,
          frameRate:{ideal:60, min:10}
        }
      }

      navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
        $('#video')[0].srcObject = stream;
        let statusHtml = '';
        stream.getTracks().forEach((track) => {
          statusHtml = statusHtml + track.kind+":"+JSON.stringify(track.getSettings(), null, 2)+'<br>';
          console.log('settings:', track.getSettings());
          console.log('capabilities:', track.getCapabilities());
        })
        $('#status').html(statusHtml);
      }).catch((err) => {
        console.log(err);
      });
    });
  </script>
</head>
<body>
  <h1> 音频降噪音,回声消除,自动增益测试</h1>
  <p>尝试更改 echoCancellation, noiseSuppression ,autoGainControl属性的值 .</p>
  <div>
  <video id='video' autoplay='false' playsinline='false'></video>
  <pre id='status'></pre>
  </div>
  </body>
</html>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK