Skip to main content

TalkLabs TTS and STT 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-2.0.0.tar.gz (13.6 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-2.0.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: livekit_plugins_talklabs-2.0.0.tar.gz
  • Upload date:
  • Size: 13.6 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-2.0.0.tar.gz
Algorithm Hash digest
SHA256 55a51fabfb162775f05422b9449d5851d116037d55c6cd9d9e3e56f4c33ba7a5
MD5 6eb5d9249dedba38300729fa8e12f438
BLAKE2b-256 77fb118c7539d4487fee1cf32c44fc6261559df76bfc7809cc6b5ef89e0d744a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for livekit_plugins_talklabs-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9935cde724ec67ee04ab7d5314b1fa2a3c7657e3f4b9469a99e62c9042a007f
MD5 160a47d48f062db5e0bf0d0a93ef3ee9
BLAKE2b-256 e359d244b2eb0d4811137d5c182953b541461fe2654a86008b53d3a0ca881f10

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