Skip to main content
Glama
phuihock
by phuihock

speech_recognition

Convert audio files to text transcriptions using the Whisper model for accessibility, documentation, or content analysis purposes.

Instructions

Transcribe audio to text using DeepInfra OpenAI-compatible API (Whisper).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audio_urlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The speech_recognition tool handler, conditionally defined and registered via @app.tool() decorator. It downloads audio from a provided URL, then uses DeepInfra's OpenAI-compatible Whisper API for transcription.
    if "all" in ENABLED_TOOLS or "speech_recognition" in ENABLED_TOOLS:
        @app.tool()
        async def speech_recognition(audio_url: str) -> str:
            """Transcribe audio to text using DeepInfra OpenAI-compatible API (Whisper)."""
            model = DEFAULT_MODELS["speech_recognition"]
            try:
                async with httpx.AsyncClient(timeout=120.0) as http_client:
                    # Download the audio file
                    audio_response = await http_client.get(audio_url)
                    audio_response.raise_for_status()
                    audio_content = audio_response.content
                
                # Use the OpenAI-compatible Whisper API
                response = await client.audio.transcriptions.create(
                    model=model,
                    file=("audio.mp3", audio_content),
                )
                return response.text
            except Exception as e:
                return f"Error transcribing audio: {type(e).__name__}: {str(e)}"
  • Configuration dictionary DEFAULT_MODELS defining the default model for speech_recognition tool (Whisper large-v3). Used within the handler.
    DEFAULT_MODELS = {
        "generate_image": os.getenv("MODEL_GENERATE_IMAGE", "Bria/Bria-3.2"),
        "text_generation": os.getenv("MODEL_TEXT_GENERATION", "meta-llama/Llama-2-7b-chat-hf"),
        "embeddings": os.getenv("MODEL_EMBEDDINGS", "sentence-transformers/all-MiniLM-L6-v2"),
        "speech_recognition": os.getenv("MODEL_SPEECH_RECOGNITION", "openai/whisper-large-v3"),
        "zero_shot_image_classification": os.getenv("MODEL_ZERO_SHOT_IMAGE_CLASSIFICATION", "openai/gpt-4o-mini"),
        "object_detection": os.getenv("MODEL_OBJECT_DETECTION", "openai/gpt-4o-mini"),
        "image_classification": os.getenv("MODEL_IMAGE_CLASSIFICATION", "openai/gpt-4o-mini"),
        "text_classification": os.getenv("MODEL_TEXT_CLASSIFICATION", "microsoft/DialoGPT-medium"),
        "token_classification": os.getenv("MODEL_TOKEN_CLASSIFICATION", "microsoft/DialoGPT-medium"),
        "fill_mask": os.getenv("MODEL_FILL_MASK", "microsoft/DialoGPT-medium"),
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the function (transcription) but lacks details on performance traits such as accuracy, latency, rate limits, authentication requirements, or error handling. This leaves gaps in understanding how the tool behaves in practice.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose and technology. It is front-loaded with no unnecessary words, making it easy to parse quickly. Every part of the sentence contributes essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (audio transcription with one parameter) and the presence of an output schema (which likely covers return values), the description is minimally adequate. However, it lacks context on usage scenarios, behavioral details, and parameter specifics, leaving room for improvement in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter with 0% description coverage, so the description must compensate. It implies the parameter is an audio URL but doesn't specify format requirements (e.g., supported audio types, size limits) or provide examples. The description adds minimal value beyond the schema's title ('Audio Url'), resulting in a baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Transcribe') and resource ('audio to text'), specifying the action and target. It also identifies the technology used ('DeepInfra OpenAI-compatible API (Whisper)'), which helps distinguish it from generic transcription tools. However, it doesn't explicitly differentiate from sibling tools like 'text_generation' or 'text_classification', which operate on text rather than audio.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions the API and model (Whisper) but doesn't specify use cases, prerequisites, or exclusions. For example, it doesn't indicate if it's for real-time or batch processing, or if there are limitations on audio formats or lengths.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/phuihock/mcp-deeinfra'

If you have feedback or need assistance with the MCP directory API, please join our Discord server