{"slug": "i-built-a-one-curl-audio-translator-with-telnyx-ai-inference", "title": "I Built a One-Curl Audio Translator with Telnyx AI Inference", "summary": "Telnyx released a one-curl audio translator built with its AI Inference API, combining speech-to-text, chat completions, and text-to-speech into a single Flask app. The tool translates audio files by transcribing, translating, and re-synthesizing speech, with error handling that preserves partial results. The open-source code example is available on GitHub.", "body_md": "Localizing a podcast, translating a recorded meeting, or dubbing a lecture used to require three different services stitched together. The Telnyx AI Inference API exposes STT, chat completions, and TTS on the same private backbone, which means a single Flask app can run the whole pipeline.\n\nThe Telnyx code example is:\n\n[https://github.com/team-telnyx/telnyx-code-examples/tree/main/ai-content-translator-python](https://github.com/team-telnyx/telnyx-code-examples/tree/main/ai-content-translator-python)\n\nIt is a Python Flask app you can clone and run in a few minutes. No phone number, no webhook tunnel, no background job runner.\n\nYou POST an audio file plus a target language. The app calls Telnyx STT to transcribe the audio in the source language, calls AI Inference to translate the transcript with a TTS-friendly system prompt, and calls Telnyx TTS to render the translated text into audio. Long transcripts are chunked at sentence boundaries so the TTS model never gets an input larger than it supports, and the chunks are concatenated into one mp3.\n\nThe response includes the job id, both transcripts, and a URL you can curl to download the dubbed audio.\n\nIt is small enough to demo live, but it covers the parts that often get cut from an audio translation demo:\n\nThe design choice I care most about is per-stage error handling. If the TTS call fails on chunk 3 of 8, the app returns `200 partial`\n\nwith the transcripts still intact, rather than throwing away the STT and translation work.\n\n```\ngit clone https://github.com/team-telnyx/telnyx-code-examples.git\ncd telnyx-code-examples/ai-content-translator-python\ncp .env.example .env\npip install -r requirements.txt\npython app.py\n```\n\nTranslate a Spanish clip into English:\n\n```\ncurl -X POST http://localhost:5000/translate \\\n  -F audio=@spanish-sample.mp3 \\\n  -F source=es \\\n  -F target=en\n```\n\nDownload the dubbed audio:\n\n```\ncurl -OJ http://localhost:5000/translate/<job_id>/audio\n```\n\nRead the full transcripts:\n\n```\ncurl http://localhost:5000/translate/<job_id> | python3 -m json.tool\n```\n\nI would keep the demo short:\n\n`/languages`\n\nendpoint to call out the supported set.`target=en`\n\nand walk through the response shape (job_id, transcript previews, audio_url).`GET /translate/<job_id>`\n\nfor the full transcripts.`source=auto`\n\nto show language detection.That gives viewers the full loop without getting lost in implementation details.\n\nThe demo keeps translation jobs in memory for one hour. Production would replace the in-memory `jobs`\n\ndict with object storage (S3, GCS) for the audio blobs and a database (Postgres) for the metadata, run STT / translate / TTS in a queue, return `202 Accepted`\n\nfor long jobs, add API key auth, and cap upload size and audio length up front.", "url": "https://wpnews.pro/news/i-built-a-one-curl-audio-translator-with-telnyx-ai-inference", "canonical_source": "https://dev.to/botoclock/i-built-a-one-curl-audio-translator-with-telnyx-ai-inference-39f9", "published_at": "2026-07-14 22:06:14+00:00", "updated_at": "2026-07-14 22:28:15.094454+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools", "ai-infrastructure"], "entities": ["Telnyx", "Flask", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/i-built-a-one-curl-audio-translator-with-telnyx-ai-inference", "markdown": "https://wpnews.pro/news/i-built-a-one-curl-audio-translator-with-telnyx-ai-inference.md", "text": "https://wpnews.pro/news/i-built-a-one-curl-audio-translator-with-telnyx-ai-inference.txt", "jsonld": "https://wpnews.pro/news/i-built-a-one-curl-audio-translator-with-telnyx-ai-inference.jsonld"}}