text_to_voice
Generate three voice previews from text prompts using ElevenLabs' API. Creates MP3 files with slight variations for voice design testing and saves them to your desktop.
Instructions
Create voice previews from a text prompt. Creates three previews with slight variations. Saves output file to directory (default: $HOME/Desktop).
If no text is provided, the tool will auto-generate text.
Voice preview files are saved as: voice_design_(generated_voice_id)_(timestamp).mp3
Example file name: voice_design_Ya2J5uIa5Pq14DNPsbC1_20250403_164949.mp3
⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| voice_description | Yes | ||
| text | No | ||
| output_directory | No |
Implementation Reference
- elevenlabs_mcp/server.py:932-979 (handler)The handler function for the 'text_to_voice' tool. It creates voice previews from a voice description using the ElevenLabs client API (client.text_to_voice.create_previews). Generates three preview audio files, handles output modes (files/resources), and returns voice IDs.@mcp.tool( description=f"""Create voice previews from a text prompt. Creates three previews with slight variations. {get_output_mode_description(output_mode)}. If no text is provided, the tool will auto-generate text. Voice preview files are saved as: voice_design_(generated_voice_id)_(timestamp).mp3 Example file name: voice_design_Ya2J5uIa5Pq14DNPsbC1_20250403_164949.mp3 ⚠️ COST WARNING: This tool makes an API call to ElevenLabs which may incur costs. Only use when explicitly requested by the user. """ ) def text_to_voice( voice_description: str, text: str | None = None, output_directory: str | None = None, ) -> list[EmbeddedResource] | TextContent: if voice_description == "": make_error("Voice description is required.") previews = client.text_to_voice.create_previews( voice_description=voice_description, text=text, auto_generate_text=True if text is None else False, ) output_path = make_output_path(output_directory, base_path) generated_voice_ids = [] results = [] for preview in previews.previews: output_file_name = make_output_file( "voice_design", preview.generated_voice_id, "mp3", full_id=True ) generated_voice_ids.append(preview.generated_voice_id) audio_bytes = base64.b64decode(preview.audio_base_64) # Handle different output modes result = handle_output_mode( audio_bytes, output_path, output_file_name, output_mode ) results.append(result) # Use centralized multiple files output handling additional_info = f"Generated voice IDs are: {', '.join(generated_voice_ids)}" return handle_multiple_files_output_mode(results, output_mode, additional_info)