clone_voice
Create custom voice profiles from audio samples for text-to-speech and speech-to-speech applications. Analyze MP3 or WAV files to generate voice replicas that mimic original audio characteristics.
Instructions
[AllVoiceLab Tool] Create a custom voice profile by cloning from an audio sample.
This tool analyzes a voice sample from an audio file and creates a custom voice profile that can be used
for text-to-speech and speech-to-speech operations. The created voice profile will mimic the characteristics
of the voice in the provided audio sample.
Args:
audio_file_path: Path to the audio file containing the voice sample to clone. Only MP3 and WAV formats are supported. Maximum file size: 10MB.
name: Name to assign to the cloned voice profile. Required.
description: Optional description for the cloned voice profile.
Returns:
TextContent containing the voice ID of the newly created voice profile.
Limitations:
- Only MP3 and WAV formats are supported
- Maximum file size: 10MB (smaller than other audio tools)
- File must exist and be accessible
- Requires permission to use voice cloning feature
- Audio sample should contain clear speech with minimal background noise for best results
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audio_file_path | Yes | ||
| name | Yes | ||
| description | No |
Implementation Reference
- allvoicelab_mcp/tools/speech.py:213-271 (handler)The handler function that executes the clone_voice tool. Validates input audio file and name, calls all_voice_lab.add_voice to clone the voice, handles various exceptions, and returns TextContent with success or error message including the new voice ID.def clone_voice( audio_file_path: str, name: str, description: str = None ) -> TextContent: """ Create a custom voice profile by cloning from an audio sample Args: audio_file_path: Path to the audio file containing the voice sample to clone. Only MP3 and WAV formats are supported. Maximum file size: 10MB. name: Name to assign to the cloned voice profile. Required. description: Optional description for the cloned voice profile. Returns: TextContent: Contains the voice ID of the newly created voice profile. """ all_voice_lab = get_client() logging.info(f"Tool called: clone_voice") logging.info(f"Audio file path: {audio_file_path}") logging.info(f"Voice name: {name}") if description: logging.info(f"Voice description: {description}") # Validate audio file, using 10MB size limit is_valid, error_message = validate_audio_file(audio_file_path, max_size_mb=10) if not is_valid: return create_error_response(error_message) # Validate name parameter if not name: logging.warning("Name parameter is empty") return create_error_response("name parameter cannot be empty") try: logging.info("Starting voice cloning process") voice_id = all_voice_lab.add_voice(name, audio_file_path, description) logging.info(f"Voice cloning successful, voice ID: {voice_id}") return TextContent( type="text", text=f"Voice cloning completed. Your new voice ID is: {voice_id}\n" ) except VoiceCloneNoPermissionError as e: logging.error(f"Voice cloning failed: {str(e)}") return TextContent( type="text", text=f"Voice cloning failed, you don't have permission to clone voice. Please contact AllVoiceLab com." ) except FileNotFoundError as e: logging.error(f"Audio file does not exist: {audio_file_path}, error: {str(e)}") return TextContent( type="text", text=f"Audio file does not exist: {audio_file_path}" ) except Exception as e: logging.error(f"Voice cloning failed: {str(e)}") return TextContent( type="text", text=f"Voice cloning failed, tool temporarily unavailable" )
- allvoicelab_mcp/server.py:123-146 (registration)MCP tool registration for clone_voice, including name, detailed description serving as input/output schema with args, returns, and limitations.mcp.tool( name="clone_voice", description="""[AllVoiceLab Tool] Create a custom voice profile by cloning from an audio sample. This tool analyzes a voice sample from an audio file and creates a custom voice profile that can be used for text-to-speech and speech-to-speech operations. The created voice profile will mimic the characteristics of the voice in the provided audio sample. Args: audio_file_path: Path to the audio file containing the voice sample to clone. Only MP3 and WAV formats are supported. Maximum file size: 10MB. name: Name to assign to the cloned voice profile. Required. description: Optional description for the cloned voice profile. Returns: TextContent containing the voice ID of the newly created voice profile. Limitations: - Only MP3 and WAV formats are supported - Maximum file size: 10MB (smaller than other audio tools) - File must exist and be accessible - Requires permission to use voice cloning feature - Audio sample should contain clear speech with minimal background noise for best results """ )(clone_voice)
- Type hints and docstring in the handler function define the input schema (parameters with types and descriptions) and output type (TextContent). Also includes validation logic within the function.def clone_voice( audio_file_path: str, name: str, description: str = None ) -> TextContent: """ Create a custom voice profile by cloning from an audio sample Args: audio_file_path: Path to the audio file containing the voice sample to clone. Only MP3 and WAV formats are supported. Maximum file size: 10MB. name: Name to assign to the cloned voice profile. Required. description: Optional description for the cloned voice profile. Returns: TextContent: Contains the voice ID of the newly created voice profile. """ all_voice_lab = get_client() logging.info(f"Tool called: clone_voice") logging.info(f"Audio file path: {audio_file_path}") logging.info(f"Voice name: {name}") if description: logging.info(f"Voice description: {description}") # Validate audio file, using 10MB size limit is_valid, error_message = validate_audio_file(audio_file_path, max_size_mb=10) if not is_valid: return create_error_response(error_message) # Validate name parameter if not name: logging.warning("Name parameter is empty") return create_error_response("name parameter cannot be empty") try: logging.info("Starting voice cloning process") voice_id = all_voice_lab.add_voice(name, audio_file_path, description) logging.info(f"Voice cloning successful, voice ID: {voice_id}") return TextContent( type="text", text=f"Voice cloning completed. Your new voice ID is: {voice_id}\n" ) except VoiceCloneNoPermissionError as e: logging.error(f"Voice cloning failed: {str(e)}") return TextContent( type="text", text=f"Voice cloning failed, you don't have permission to clone voice. Please contact AllVoiceLab com." ) except FileNotFoundError as e: logging.error(f"Audio file does not exist: {audio_file_path}, error: {str(e)}") return TextContent( type="text", text=f"Audio file does not exist: {audio_file_path}" ) except Exception as e: logging.error(f"Voice cloning failed: {str(e)}") return TextContent( type="text", text=f"Voice cloning failed, tool temporarily unavailable" )