Skip to content

Conversation

@fmv1992
Copy link

@fmv1992 fmv1992 commented Feb 3, 2026

Description

This PR introduces support for Telnyx Speech-to-Text (STT) and Text-to-Speech (TTS) services, enabling real-time conversational AI pipelines using Telnyx's voice APIs.

The implementation focuses on low latency and minimal dependencies by leveraging native PCM streaming.

Key Features

  • TelnyxSTTService: Supports streaming raw audio (WAV/PCM) to Telnyx for real-time transcription.
  • TelnyxTTSService: Supports streaming raw PCM audio from Telnyx (24kHz by default for NaturalHD voices), bypassing the need for external decoding libraries like ffmpeg or pydub.
  • src/pipecat/services/telnyx/utils.py: Added utility for generating valid WAV headers required by the Telnyx streaming protocol.
  • Example Agent: Added examples/foundational/telnyx_openai_agent.py demonstrating a complete voice-to-voice agent using Telnyx + OpenAI + Daily.co.

Implementation Details

  • Protocol: Switched from mp3 to pcm in the WebSocket handshake. This eliminates decoding overhead and external dependencies, significantly reducing Time-to-First-Byte (TTFB).
  • Sample Rates:
    • STT input defaults to 16kHz (optimal for VAD/ASR).
    • TTS output defaults to 24kHz (native rate for Telnyx NaturalHD voices) to ensure high-fidelity playback without pitch shifting.
  • Context Aggregation: The example agent implements LLMUserResponseAggregator and LLMAssistantResponseAggregator to handle conversational turns robustly, including handling race conditions where VAD silence detection might outpace cloud transcription.

Dependencies

  • No new OS-level dependencies (e.g., ffmpeg is not required).
  • Standard Python websockets and aiohttp.

How to Test

  1. Set the following environment variables:
    export TELNYX_API_KEY="your_key"
    export DAILY_ROOM_URL="your_daily_url"
    export DAILY_ROOM_TOKEN="your_daily_token"
    export OPENAI_API_KEY="your_openai_key"
  2. Run the foundational example:
    python3 examples/foundational/telnyx_openai_agent.py

@sonamg-droid
Copy link

@aconchillo Hi Aleix, we’d appreciate a review from someone on the team so this PR can be approved and merged.

We’re contributing this from Telnyx to add official support for Telnyx Speech-to-Text and Text-to-Speech services, which we think can help broaden the range of real-time voice AI pipelines Pipecat supports.

Happy to make any changes based on feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants