--- url: "https://web.dev/articles/media/microphone-process" titulek: "How to process audio from the user's microphone | Media patterns | web.dev" h1: "How to process audio from the user's microphone Stay organized with collections Save and categorize content based on your preferences." popis: "" jazyk: "en" kanonicka: "https://web.dev/articles/media/microphone-process" drobecky: ["Media patterns", "How to process audio from the user's microphone"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:29:23" znaku: 3236 slov: 333 kodovani: "iso-8859-2" sha256: "156e95094184e580e42cad3bbcf99ba7811e3708acc52e07d428566c1b022b86" --- How to process audio from the user's microphone Stay organized with collections Save and categorize content based on your preferences. François Beaufort Accessing the user's camera and microphone is possible on the web platform with the [Media Capture and Streams API](https://www.w3.org/TR/mediacapture-streams/). The [`getUserMedia()`](https://developer.mozilla.org/docs/Web/API/MediaDevices/getUserMedia) method prompts the user to access a camera and/or microphone to capture as a media stream. This stream can then be processed in a separate [Web Audio](https://developer.mozilla.org/docs/Web/API/Web_Audio_API) thread with an [AudioWorklet](https://developer.mozilla.org/docs/Web/API/AudioWorklet) that provides very low latency audio processing. The example below shows how you can process audio from the user's microphone in a performant way. `let stream; startMicrophoneButton.addEventListener("click", async () => { // Prompt the user to use their microphone. stream = await navigator.mediaDevices.getUserMedia({ audio: true, }); const context = new AudioContext(); const source = context.createMediaStreamSource(stream); // Load and execute the module script. await context.audioWorklet.addModule("processor.js"); // Create an AudioWorkletNode. The name of the processor is the // one passed to registerProcessor() in the module script. const processor = new AudioWorkletNode(context, "processor"); source.connect(processor).connect(context.destination); log("Your microphone audio is being used."); }); stopMicrophoneButton.addEventListener("click", () => { // Stop the stream. stream.getTracks().forEach(track => track.stop()); log("Your microphone audio is not used anymore."); });``// processor.js // This file is evaluated in the audio rendering thread // upon context.audioWorklet.addModule() call. class Processor extends AudioWorkletProcessor { process([input], [output]) { // Copy inputs to outputs. output[0].set(input[0]); return true; } } registerProcessor("processor", Processor);` Browser support MediaDevices.getUserMedia() Browser Support 53 12 36 11 [Source](https://developer.mozilla.org/docs/Web/API/MediaDevices/getUserMedia) Web Audio Browser Support 35 12 25 14.1 [Source](https://developer.mozilla.org/docs/Web/API/AudioContext) AudioWorklet Browser Support 66 79 76 14.1 [Source](https://developer.mozilla.org/docs/Web/API/AudioWorklet) Further reading [W3C Media Capture and Streams Specification](https://www.w3.org/TR/mediacapture-streams/) [W3C Web Audio Specification](https://webaudio.github.io/web-audio-api/) [Enter AudioWorklet](https://developer.chrome.com/blog/audio-worklet) Demo [Open demo](/articles/media/microphone-process/demo) Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2026-09-04 UTC.