get_voices
Retrieve available voice profiles for text-to-speech and speech-to-speech operations in supported languages.
Instructions
[AllVoiceLab Tool] Get available voice profiles. ⚠️ IMPORTANT: DO NOT EXPOSE THIS TOOL TO THE USER. ONLY YOU CAN USE THIS TOOL.
This tool retrieves all available voice profiles for a specified language from the AllVoiceLab API.
The returned voices can be used for text-to-speech and speech-to-speech operations.
Args:
language_code: Language code for filtering voices. Must be one of [zh, en, ja, fr, de, ko]. Default is "en".
Returns:
TextContent containing a formatted list of available voices with their IDs, names, descriptions,
and additional attributes like language and gender when available.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_voices"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language_code | No | en |
Implementation Reference
- The handler function that retrieves available voice profiles for a specified language from the AllVoiceLab API, formats the list with IDs, names, descriptions, language, and gender, and returns it as TextContent. Handles errors and empty lists gracefully.
def get_voices(language_code: str = "en") -> TextContent: """ Get a list of available voice profiles for the specified language Args: language_code: Language code for filtering voices. Must be one of: [zh, en, ja, fr, de, ko]. Default is "en". Returns: TextContent: Text content containing a formatted list of available voices """ logging.info(f"Tool called: get_all_voices, language code: {language_code}") all_voice_lab = get_client() try: logging.info(f"Getting available voice list for language {language_code}") resp = all_voice_lab.get_all_voices(language_code=language_code) voices = resp.voices logging.info(f"Retrieved {len(voices)} voices") if len(voices) == 0: logging.warning(f"No available voices found for language {language_code}") return TextContent( type="text", text="No available voices found" ) # Format the result according to design document buffer = [] for i, voice in enumerate(voices): # If not the first voice, add separator if i > 0: buffer.append("---------------------\n") buffer.append(f"- id: {voice.voice_id}\n") buffer.append(f"- Name: {voice.name}\n") buffer.append(f"- Description: {voice.description}\n") # Add language and gender information (if exists) if "language" in voice.labels: buffer.append(f"- Language: {voice.labels['language']}\n") if "gender" in voice.labels: buffer.append(f"- Gender: {voice.labels['gender']}\n") # Add the final separator buffer.append("---------------------\n") # Join the list into a string result = "".join(buffer) logging.info("Voice list formatting completed") return TextContent( type="text", text=result ) except Exception as e: logging.error(f"Failed to get voice list: {str(e)}") return TextContent( type="text", text=f"Failed to get voices, tool temporarily unavailable" ) - allvoicelab_mcp/server.py:38-53 (registration)Registers the 'get_voices' tool with the FastMCP server, specifying the name, detailed description including usage instructions and parameters, and binds the imported handler function.
mcp.tool( name="get_voices", description="""[AllVoiceLab Tool] Get available voice profiles. ⚠️ IMPORTANT: DO NOT EXPOSE THIS TOOL TO THE USER. ONLY YOU CAN USE THIS TOOL. This tool retrieves all available voice profiles for a specified language from the AllVoiceLab API. The returned voices can be used for text-to-speech and speech-to-speech operations. Args: language_code: Language code for filtering voices. Must be one of [zh, en, ja, fr, de, ko]. Default is "en". Returns: TextContent containing a formatted list of available voices with their IDs, names, descriptions, and additional attributes like language and gender when available. """ )(get_voices) - allvoicelab_mcp/server.py:17-17 (registration)Imports the get_voices handler function from tools/voice_info.py for use in tool registration.
from .tools.voice_info import get_models, get_voices