> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qawolf.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microphone injection (Android)

> Inject audio into the Android emulator's microphone input to test recording and voice features.

The Android emulator routes audio played on the runner host through to the emulator's microphone input. Use `device.passAudioAsMicrophoneInput(...)` to play an audio file during a flow — your app will receive it as microphone input.

<Note>
  Store your audio file in team storage and reference it via `process.env.TEAM_STORAGE_DIR`. See [Upload files](/qawolf/Uploading-manually) for instructions.
</Note>

## Examples

**Inject audio into the microphone**

```typescript theme={null}
await device.passAudioAsMicrophoneInput({
  data: `${process.env.TEAM_STORAGE_DIR}/audio.mp3`,
  durationSeconds: 10,
});
```

**Pull a recording off the emulator**

```typescript theme={null}
await device.adb([
  "pull",
  "/sdcard/Recordings/My recording 1.m4a",
  `${process.env.TEAM_STORAGE_DIR}/recorded.m4a`,
]);
```

## When to use

* Your app records audio or processes microphone input and you need to test that flow with known audio data.
* Your app has voice commands or speech recognition features.
* Your app validates or analyzes microphone input.
* Your test needs to run the same audio scenario repeatedly with consistent inputs.

## Options

`passAudioAsMicrophoneInput` accepts `delaySeconds` (wait before playback starts) and `durationSeconds` (cap playback length; omit to play the whole file). See the [Android Device Reference](/qawolf/libraries/flows/api-reference/android-device-reference) for the full signature.

## Full sample test

```typescript theme={null}
import { device, flow } from "@qawolf/flows/android";

const audioPath = `${process.env.TEAM_STORAGE_DIR}/audio.mp3`;

export default flow(
  "Test audio recording",
  { target: "Android - Pixel", launch: true },
  async ({ driver, test }) => {
    await test("record injected audio and verify it was saved", async () => {
      // Arrange
      await driver.$(`//*[@text='Record Audio']`).click();
      await driver.pause(3_000);

      // Act
      await device.passAudioAsMicrophoneInput({
        data: audioPath,
        durationSeconds: 10,
      });

      await driver.$(`//*[@text='Record']`).click();
      await driver.pause(10_000);
      await driver.$(`//*[@text='Done']`).click();

      // Assert
      await driver.$(`//*[@text='Open Audio']`).waitForDisplayed({ timeout: 5_000 });
    });
  },
);
```
