| 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.
STT Transcribe:POST /v2/ai/transcribe
--refAI Inference:POST /v2/ai/chat/completions
--refTTS Generate:POST /v2/ai/generate
--ref
API Request
β
βΌ
ββββββββββββββββββββ
β Answer + Greet β ββ TTS welcome message
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Gather Speech β ββ STT transcription
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β AI Inference β
β β’ Translation β
ββββββββββ¬ββββββββββ
β βββββ conversation loop
β
βΌ
JSON response
- Sends conversation to Telnyx AI Inference for processing
- Converts response to speech via Telnyx TTS
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.
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 | |||||
AI_MODEL
string
moonshotai/Kimi-K2.6
DocsTTS_MODEL
string
telnyx/tts
DocsSTT_MODEL
string
telnyx/asr
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.py
ngrok http 5000
Set webhook URL in Telnyx Portal:
- Call Control Application ->
https://<id>.ngrok.io/webhooks/voice
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}
curl http://localhost:5000/health
{"status": "ok"}
Connection refused on port 5000: App isn't running. Runpython app.py
and check no other process uses port 5000.401 Unauthorized: YourTELNYX_API_KEY
is invalid. Generate a new one atportal.telnyx.com/api-keys.AI response slow/empty: Verify model name. See available models atdevelopers.telnyx.com.
run-llm-inference-python- Standalone inferencebuild-voice-ai-agent-python- Voice AI agent