audio_playback
Control playback of local audio files to simulate human speech input for automated testing in Android emulators.
Instructions
Control playback of local audio files for automated testing. Audio is played via a virtual audio output device that is routed into the Android emulator's microphone. Use this to simulate a human speaking into the mic by playing prerecorded files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | ||
| filename | No | ||
| start_offset_ms | No | ||
| list_limit | No |
Implementation Reference
- The `audio_playback` tool handler is defined using the `@server.tool` decorator within `_build_server`. It processes playback actions by delegating to an `AudioPlaybackManager` instance.
@server.tool( name="audio_playback", description=( "Control playback of local audio files for automated testing. Audio is " "played via a virtual audio output device that is routed into the Android " "emulator's microphone. Use this to simulate a human speaking into the mic " "by playing prerecorded files." ), ) async def audio_playback( action: Literal["play", "stop", "pause", "resume", "status", "list_files"], filename: Optional[str] = None, start_offset_ms: int = 0, list_limit: int = 200, ) -> dict: if action == "play" and (filename is None or not filename.strip()): return { "success": False, "message": "filename is required for 'play' action.", "state": manager.state, } if start_offset_ms < 0: return { "success": False, "message": "start_offset_ms must be non-negative.", "state": manager.state, } try: if action == "play": success, message, state = await manager.play( filename=filename or "", start_offset_ms=start_offset_ms, ) return {"success": success, "message": message, "state": state} if action == "stop": success, message, state = await manager.stop() return {"success": success, "message": message, "state": state} if action == "pause": success, message, state = await manager.pause() return {"success": success, "message": message, "state": state} if action == "resume": success, message, state = await manager.resume() return {"success": success, "message": message, "state": state} if action == "status": success, message, state = await manager.status() return {"success": success, "message": message, "state": state} files_payload = manager.list_local_files(limit=list_limit) return { "success": True, "message": "Listed files available under AUDIO_ROOT_DIR.", "state": manager.state, "files": files_payload, } except ValueError as exc: return {"success": False, "message": str(exc), "state": manager.state} return server