# AI audio translator with speech-to-text, LLM translation, and text-to-speech

> Source: <https://github.com/team-telnyx/telnyx-code-examples/tree/main/ai-content-translator-python>
> Published: 2026-06-26 21:50:51+00:00

| 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`

--[ref](https://developers.telnyx.com/api/inference/transcribe)**AI Inference**:`POST /v2/ai/chat/completions`

--[ref](https://developers.telnyx.com/api/inference/chat-completions)**TTS Generate**:`POST /v2/ai/generate`

--[ref](https://developers.telnyx.com/api/inference/generate)

```
  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`

[Docs](https://developers.telnyx.com/docs/inference/models)`TTS_MODEL`

`string`

`telnyx/tts`

[Docs](https://developers.telnyx.com/docs/inference)`STT_MODEL`

`string`

`telnyx/asr`

[Docs](https://developers.telnyx.com/docs/inference)

```
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](https://portal.telnyx.com):

- 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. Run`python app.py`

and check no other process uses port 5000.**401 Unauthorized**: Your`TELNYX_API_KEY`

is invalid. Generate a new one at[portal.telnyx.com/api-keys](https://portal.telnyx.com/api-keys).**AI response slow/empty**: Verify model name. See available models at[developers.telnyx.com](https://developers.telnyx.com/docs/inference/list-models).

[run-llm-inference-python](https://raw.githubusercontent.com/team-telnyx/telnyx-code-examples/main/run-llm-inference-python/README.md)- Standalone inference[build-voice-ai-agent-python](https://raw.githubusercontent.com/team-telnyx/telnyx-code-examples/main/build-voice-ai-agent-python/README.md)- Voice AI agent
