list_asr_models
Retrieve a comprehensive list of available ASR models and their capabilities from the Whissle MCP Server to streamline speech-to-text processing tasks.
Instructions
List all available ASR models and their capabilities.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- whissle_mcp/server.py:452-512 (handler)The complete handler function for the 'list_asr_models' MCP tool, including the @mcp.tool decorator for registration. It fetches the list of available ASR models from the WhissleClient, handles various response formats, implements retry logic for API errors, and returns a formatted TextContent response.@mcp.tool( description="List all available ASR models and their capabilities." ) def list_asr_models() -> TextContent: """List all available ASR models. Returns: TextContent with a formatted list of available models """ try: logger.info("Fetching available ASR models...") retry_count = 0 max_retries = 2 # Increased from 1 to 2 while retry_count <= max_retries: try: logger.info(f"Attempting to list models (Attempt {retry_count+1}/{max_retries+1})") models = client.list_asr_models() if not models: logger.error("No models were returned from the API") return make_error("No models were returned from the API") # Handle both string and object responses if isinstance(models, list): if all(isinstance(model, str) for model in models): # If models is a list of strings model_list = "\n".join(f"Model: {model}" for model in models) else: # If models is a list of objects with name and description model_list = "\n".join( f"Model: {model.name}\nDescription: {model.description}\n" for model in models ) else: logger.error("Unexpected response format from API") return make_error("Unexpected response format from API") logger.info("Successfully retrieved ASR models") return TextContent( type="text", text=f"Available ASR Models:\n\n{model_list}", ) except Exception as api_error: error_msg = str(api_error) logger.error(f"Error listing models: {error_msg}") # Handle API errors with retries error_result = handle_api_error(error_msg, "listing models", retry_count, max_retries) if error_result is not None: # If we should not retry return error_result # Return the error message retry_count += 1 # If we get here, all retries failed logger.error(f"All attempts to list models failed after {max_retries+1} attempts") return make_error(f"Failed to list ASR models after {max_retries+1} attempts") except Exception as e: logger.error(f"Unexpected error listing ASR models: {str(e)}") return make_error(f"Failed to list ASR models: {str(e)}")