play_audio
Play audio files in WAV or MP3 format using the ElevenLabs MCP Server to listen to generated speech or processed audio content.
Instructions
Play an audio file. Supports WAV and MP3 formats.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_file_path | Yes |
Implementation Reference
- elevenlabs_mcp/server.py:1158-1162 (handler)The main execution function for the 'play_audio' MCP tool. It validates the input file path, reads and plays the audio file using an external 'play' function (likely from pydub), and returns a success confirmation message. The @mcp.tool decorator registers it with MCP and provides the tool description serving as schema documentation.@mcp.tool(description="Play an audio file. Supports WAV and MP3 formats.") def play_audio(input_file_path: str) -> TextContent: file_path = handle_input_file(input_file_path) play(open(file_path, "rb").read(), use_ffmpeg=False) return TextContent(type="text", text=f"Successfully played audio file: {file_path}")
- elevenlabs_mcp/utils.py:126-148 (helper)Utility function called by play_audio to resolve and validate the input file path. Ensures the file exists, is a file, and (optionally) is an audio/video file by calling check_audio_file.def handle_input_file(file_path: str, audio_content_check: bool = True) -> Path: if not os.path.isabs(file_path) and not os.environ.get("ELEVENLABS_MCP_BASE_PATH"): make_error( "File path must be an absolute path if ELEVENLABS_MCP_BASE_PATH is not set" ) path = Path(file_path) if not path.exists() and path.parent.exists(): parent_directory = path.parent similar_files = try_find_similar_files(path.name, parent_directory) similar_files_formatted = ",".join([str(file) for file in similar_files]) if similar_files: make_error( f"File ({path}) does not exist. Did you mean any of these files: {similar_files_formatted}?" ) make_error(f"File ({path}) does not exist") elif not path.exists(): make_error(f"File ({path}) does not exist") elif not path.is_file(): make_error(f"File ({path}) is not a file") if audio_content_check and not check_audio_file(path): make_error(f"File ({path}) is not an audio or video file") return path