Skip to main content
Use Playwright’s fake media device flags to inject a pre-recorded audio file as the browser’s microphone input. This lets you test voice-activated features, speech recognition, and audio processing in web apps under controlled, repeatable conditions.
WAV format is recommended. Store your audio file in team storage and reference it via process.env.TEAM_STORAGE_DIR. See Upload files for instructions.
Playwright initializes the fake audio device once per browser instance. You cannot swap the audio file mid-flow. If you need to test with different audio inputs, launch a new browser instance for each.

Examples

Inject audio into the browser microphone

When to use

  • Your app has speech recognition and you need to test that specific voice commands are interpreted correctly.
  • Your app has voice-activated controls and you need to verify they produce the expected behavior.
  • Your app processes or transforms microphone input and you need to assert on the output.
  • Your app has voice-controlled accessibility features and you need to confirm they work as expected.

Full sample test

Last modified on May 20, 2026