Skip to main content

TalkLabs TTS plugin for LiveKit Agents

Project description

livekit-plugins-talklabs

Python License: MIT LiveKit PyPI version

TalkLabs TTS plugin for LiveKit Agents. Provides high-quality Brazilian Portuguese text-to-speech synthesis with streaming support.

Installation

pip install livekit-plugins-talklabs

Compatibility

This plugin is compatible with LiveKit Agents Framework and can be used as a drop-in TTS provider alongside other LiveKit plugins:

  • ✅ Works with LiveKit Voice Assistant
  • ✅ Compatible with all LiveKit STT providers (Deepgram, OpenAI, etc.)
  • ✅ Compatible with all LiveKit LLM providers (OpenAI, Anthropic, etc.)

Usage

Basic Example

from livekit.plugins.talklabs import TalkLabsTTS

# Initialize TTS (same pattern as other LiveKit plugins)
tts = TalkLabsTTS(
    api_key="your-api-key"  # Get from https://talklabs.com.br
)

# Use with default voice (adam_rocha)
tts = TalkLabsTTS(api_key="your-api-key")

# Or specify custom settings
tts = TalkLabsTTS(
    api_key="your-api-key",
    voice="maria_silva",    # Female voice
    language="pt",          # Portuguese
    speed=1.2,             # Slightly faster
    sample_rate=24000      # High quality
)

With LiveKit Voice Assistant

from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice_assistant import VoiceAssistant
from livekit.plugins.openai import LLM
from livekit.plugins.deepgram import STT
from livekit.plugins.silero import VAD
from livekit.plugins.talklabs import TalkLabsTTS
import os

async def entrypoint(ctx: JobContext):
    # Create a voice assistant with TalkLabs TTS
    assistant = VoiceAssistant(
        vad=VAD.load(),
        stt=STT(),
        llm=LLM(),
        tts=TalkLabsTTS(api_key=os.environ["TALKLABS_API_KEY"])  # Same as other plugins
    )

    await assistant.start(ctx.room)

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

Complete Integration Example

from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice_assistant import VoiceAssistant
from livekit.plugins.openai import LLM
from livekit.plugins.deepgram import STT
from livekit.plugins.silero import VAD
from livekit.plugins.talklabs import TalkLabsTTS
import os

async def entrypoint(ctx: JobContext):
    """LiveKit Voice Assistant with Brazilian Portuguese support."""

    # Initialize plugins - all follow same pattern
    vad = VAD.load()
    stt = STT(language="pt-BR")  # Portuguese speech recognition
    llm = LLM(model="gpt-4")
    tts = TalkLabsTTS(api_key=os.environ["TALKLABS_API_KEY"])  # Portuguese TTS

    # Create voice assistant
    assistant = VoiceAssistant(
        vad=vad,
        stt=stt,
        llm=llm,
        tts=tts,  # TalkLabs as TTS provider
    )

    # Set Portuguese context
    assistant.llm_context.append({
        "role": "system",
        "content": "You are a helpful assistant. Respond in Portuguese (pt-BR)."
    })

    await assistant.start(ctx.room)

    # Greet in Portuguese
    await assistant.say("Olá! Como posso ajudá-lo hoje?")

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

Available Voices

Voice Gender Description
adam_rocha Male Default voice, natural Brazilian accent
maria_silva Female Clear and professional
carlos_santos Male Deep and authoritative
ana_costa Female Young and friendly

Configuration

Environment Variables

Set your API key as an environment variable:

export TALKLABS_API_KEY="your-api-key"

Then use it in your code:

tts = TalkLabsTTS(api_key=os.environ["TALKLABS_API_KEY"])

Parameters

Parameter Type Default Description
api_key str Required Your TalkLabs API key
voice str "adam_rocha" Voice identifier
language str "pt" Language code
speed float 1.0 Speech speed (0.5-2.0)
sample_rate int 24000 Audio sample rate
base_url str "https://api.talklabs.com.br" API endpoint

Comparison with Other LiveKit TTS Plugins

Plugin Languages Streaming Best For
livekit-plugins-talklabs Portuguese (pt-BR) Brazilian Portuguese applications
livekit-plugins-openai Multiple General purpose, English
livekit-plugins-elevenlabs Multiple High quality English voices
livekit-plugins-cartesia English Low latency English

Working Example

import asyncio
import os
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice_assistant import VoiceAssistant
from livekit.plugins.openai import LLM
from livekit.plugins.deepgram import STT
from livekit.plugins.silero import VAD
from livekit.plugins.talklabs import TalkLabsTTS

async def entrypoint(ctx: JobContext):
    """Minimal working example."""

    # Simple one-line TTS initialization like other plugins
    assistant = VoiceAssistant(
        vad=VAD.load(),
        stt=STT(),
        llm=LLM(),
        tts=TalkLabsTTS(api_key=os.environ["TALKLABS_API_KEY"])
    )

    await assistant.start(ctx.room)

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

Features

  • 🎯 Native LiveKit Integration: Works seamlessly with LiveKit Agents Framework
  • 🔄 Streaming Support: Real-time audio streaming for low latency
  • 🇧🇷 Brazilian Portuguese: Optimized for pt-BR pronunciation
  • Low Latency: < 200ms to first byte
  • 🎵 High Quality: 24kHz sample rate
  • 🔌 Plugin Architecture: Drop-in replacement for any LiveKit TTS provider

Requirements

  • Python 3.9+
  • LiveKit Agents 0.8.0+
  • TalkLabs API key (get from talklabs.com.br)

Support

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Made with ❤️ by TalkLabs for the LiveKit community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

livekit_plugins_talklabs-1.0.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

livekit_plugins_talklabs-1.0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file livekit_plugins_talklabs-1.0.2.tar.gz.

File metadata

  • Download URL: livekit_plugins_talklabs-1.0.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for livekit_plugins_talklabs-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5e18bd8b063a492b85438172c1552ec529a1d9b2acd1212d3d86de1898b9a483
MD5 3f449730666a5cffa531141a4a138ea0
BLAKE2b-256 8597be1c7358fb8e670075a3fab3c1c70c4db69b35f31579f6f3e18471171f1e

See more details on using hashes here.

File details

Details for the file livekit_plugins_talklabs-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for livekit_plugins_talklabs-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6a61b47306e9a5fd1d5170d47a45418206ec802387c41c341c6a5c7bb3fb989c
MD5 d859471df54c7fe30bab6105a6220686
BLAKE2b-256 e1b0ca30f1c8aea11395e6998bd7945d257e4364ab26dffe89a2f7b1b93c9696

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page