device.passAudioAsMicrophoneInput(...) to play an audio file during a flow, and your app will receive it as microphone input.
Microphone injection and audio capture work on emulators only, not on real Android phones.
Store your audio file in team storage and reference it via
process.env.TEAM_STORAGE_DIR. See Use files in flows for instructions.Examples
Inject audio into the microphone Start the recording in your app, then play the audio into it: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 Controls for the full signature.
delaySeconds delays playback, but the call still resolves only once playback has finished. Use it to line playback up with something your app does after it starts listening, not to start the recording after the call.