Voice assistant example
This example is based on LiveKit’s agents examples repo, modified to use Telnyx for LLM inference.Set up and activate a virtual env
Install requirements
Download files
This downloads model weights for voice-activity detection:Agent code
The following code uses Telnyx for LLM inference viaopenai.LLM.with_telnyx(), with Telnyx STT and TTS.
Set environment variables
Run the agent worker
Test with a LiveKit frontend
Use the LiveKit Agents Playground to test your agent without building a frontend.Telnyx STT and TTS plugins
Two Telnyx plugins provide native STT and TTS for LiveKit agents. Both install thelivekit.plugins.telnyx module and provide telnyx.STT and telnyx.TTS, so install only one.
Install the Telnyx-maintained plugin:
STT
Usetelnyx.STT() for real-time speech-to-text via Telnyx’s WebSocket streaming API:
TTS
Usetelnyx.TTS() for real-time text-to-speech over Telnyx’s WebSocket streaming API. Pass a voice parameter to select a specific voice: