stt
Transcribe audio files to text with word-level timestamps using a URL input. Supports multiple languages.
Instructions
Transcribe audio to text with timestamps. Cost: 2 credits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audio_url | No | URL to audio file | |
| language | No | Language code | en |
Implementation Reference
- src/index.ts:90-97 (schema)Schema definition for the 'stt' tool: transcribes audio to text. Inputs: audio_url (optional string URL) and language (optional string, defaults to 'en').
{ name: "stt", description: "Transcribe audio to text with timestamps. Cost: 2 credits.", inputSchema: { audio_url: z.string().optional().describe("URL to audio file"), language: z.string().optional().default("en").describe("Language code"), }, }, - src/index.ts:255-258 (handler)Generic handler for all tools including 'stt'. Calls the Suprsonic REST API via callSuprsonic() with the capability name and args.
async (args: any): Promise<CallToolResult> => { return callSuprsonic(cap.name, args as Record<string, unknown>); }, ); - src/index.ts:247-259 (registration)Registration loop: iterates over all CAPABILITIES (including 'stt') and registers each as an MCP tool using server.registerTool().
for (const cap of CAPABILITIES) { // Cast inputSchema to avoid TS2589 (excessively deep type instantiation from Zod chains) server.registerTool( cap.name, { description: cap.description, inputSchema: cap.inputSchema as any, }, async (args: any): Promise<CallToolResult> => { return callSuprsonic(cap.name, args as Record<string, unknown>); }, ); } - src/index.ts:183-234 (helper)Generic helper function callSuprsonic() that all tools delegate to. It POSTs to the Suprsonic REST API with the capability name (e.g. 'stt') and params, then returns the result.
async function callSuprsonic(capability: string, params: Record<string, unknown>): Promise<CallToolResult> { if (!API_KEY) { return { content: [{ type: "text", text: "Error: SUPRSONIC_API_KEY environment variable is not set. Get your key at https://suprsonic.ai/app/apis" }], isError: true, }; } try { const resp = await fetch(`${BASE_URL}/v1/agent`, { method: "POST", headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ capability, params }), }); const result = await resp.json() as any; // Handle non-envelope responses (401, 429, etc. return {"detail": ...}) if (result.detail && result.success === undefined) { const msg = typeof result.detail === "object" ? (result.detail.title || result.detail.detail || JSON.stringify(result.detail)) : String(result.detail); return { content: [{ type: "text", text: `Error (HTTP ${resp.status}): ${msg}` }], isError: true, }; } if (!result.success) { const errMsg = result.error?.detail || result.error?.title || "Request failed"; return { content: [{ type: "text", text: `Error: ${errMsg}` }], isError: true, }; } const text = JSON.stringify(result.data, null, 2); const meta = result.metadata ? `\n\n[Provider: ${(result.metadata as any).provider_used || "unknown"}, ${(result.metadata as any).response_time_ms || 0}ms, ${result.credits_used || 0} credits]` : ""; return { content: [{ type: "text", text: text + meta }], }; } catch (err) { return { content: [{ type: "text", text: `Network error: ${err instanceof Error ? err.message : String(err)}` }], isError: true, }; } }