| name | ai-content-translator | ||
|---|---|---|---|
| title | AI Content Translator | ||
| description | Upload any audio (podcast, meeting, lecture), STT transcribes in source language, AI Inference translates, TTS generates audio in target language. Returns translated audio + aligned transcript. | ||
| language | python | ||
| framework | flask | ||
| telnyx_products |
|
||
| integrations | |||
| channel |
|
Upload any audio (podcast, meeting, lecture), STT transcribes in source language, AI Inference translates, TTS generates audio in target language. Returns translated audio + aligned transcript.
Telnyx API Endpoints Used
- STT Transcribe:
POST /v2/ai/transcribe-- ref - AI Inference:
POST /v2/ai/chat/completions-- ref - TTS Generate:
POST /v2/ai/generate-- ref
Architecture
API Request
│
▼
┌──────────────────┐
│ Answer + Greet │ ── TTS welcome message
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Gather Speech │ ── STT transcription
└────────┬─────────┘
│
▼
┌──────────────────┐
│ AI Inference │
│ • Translation │
└────────┬─────────┘
│ ◄──── conversation loop
│
▼
JSON response
How It Works
- Sends conversation to Telnyx AI Inference for processing
- Converts response to speech via Telnyx TTS
Why Telnyx
Telnyx is an AI Communications Infrastructure platform - voice, messaging, SIP, AI, and IoT on one private, global network.
- Co-located inference - LLM runs on the same network as voice traffic. Sub-200ms round trips.
Environment Variables
Copy .env.example to .env and fill in:
| Variable | Type | Example | Required | Description | Where to get it |
|---|---|---|---|---|---|
TELNYX_API_KEY |
string |
KEY0123456789ABCDEF |
yes | Telnyx API v2 key | Portal |
AI_MODEL |
string |
moonshotai/Kimi-K2.6 |
no | AI Inference model | Docs |
TTS_MODEL |
string |
telnyx/tts |
no | TTS model name | Docs |
STT_MODEL |
string |
telnyx/asr |
no | STT model name | Docs |
Setup
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/ai-content-translator-python
cp .env.example .env
pip install -r requirements.txt
python app.pyWebhook Configuration
Set webhook URL in Telnyx Portal:
- Call Control Application ->
https://<id>.ngrok.io/webhooks/voice
API Reference
POST /translate
Upload as multipart form:
curl -X POST http://localhost:5000/translate \ -F audio=@lecture.mp3 \ -F source=en \ -F target=ja
Response:
{"job_id": "tr-a1b2c3d4", "status": "complete", "source": "en (English)", "target": "ja (Japanese)", "original_length": 1847, "translated_length": 923}GET /health
curl http://localhost:5000/health
Troubleshooting
- Connection refused on port 5000: App isn't running. Run
python app.pyand check no other process uses port 5000. - 401 Unauthorized: Your
TELNYX_API_KEYis invalid. Generate a new one at portal.telnyx.com/api-keys. - AI response slow/empty: Verify model name. See available models at developers.telnyx.com.
Related Examples
- run-llm-inference-python - Standalone inference
- build-voice-ai-agent-python - Voice AI agent





















