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

# setMicrophone

> Play an audio file as the simulator microphone input.

Feeds an audio file into the microphone of the simulator, so the app under test
hears the audio instead of silence. Use it to test flows like voice input or
speech recognition.

This command runs only on Momentic-hosted iOS simulators. It is not supported on
Android or on local simulators.

## Parameters

| Parameter | Type      | Required | Description                                                       |
| --------- | --------- | -------- | ----------------------------------------------------------------- |
| `path`    | `string`  | Yes      | Path to the audio file on the host. May be a local path or a URL. |
| `once`    | `boolean` | No       | Play the audio one time instead of looping. Defaults to `false`.  |
| `saveAs`  | `string`  | No       | Variable to store this step's return value on `env.<name>`.       |
| `retries` | `number`  | No       | Times to retry the step on failure before failing the test.       |
| `skipped` | `boolean` | No       | Skip this step at execution time.                                 |

Use a `.wav`, `.mp3`, `.m4a`, `.aac`, or `.caf` file.

## Examples

Simplified form:

```yaml theme={null}
- setMicrophone: ./fixtures/speech.wav
```

Detailed form, with a single pass instead of a loop:

```yaml theme={null}
- setMicrophone:
    path: ./fixtures/speech.wav
    once: true
```

Setting a new file replaces the one that is playing. Put the step in `before` to
keep one audio input active for the whole test:

```yaml theme={null}
before:
  - setMicrophone: ./fixtures/speech.wav
steps:
  - tap: Start recording
  - checkScreenContains: Transcription ready
  - clearMicrophone
```

## Related

* [`clearMicrophone`](/docs/reference/mobile-commands/clear-microphone)
* [`setCamera`](/docs/reference/mobile-commands/set-camera)
* [YAML format](/docs/core-concepts/test-format)
