Skip to main content

Resemble plugin for LiveKit Agents

Support for voice synthesis with the Resemble AI API, using both their REST API and WebSocket streaming interface.

See https://docs.livekit.io/agents/integrations/tts/resemble/ for more information.

Installation

pip install livekit-plugins-resemble

Pre-requisites

You'll need an API key from Resemble AI. It can be set as an environment variable: RESEMBLE_API_KEY

Additionally, you'll need the voice UUID from your Resemble AI account.

Examples

import asyncio
from livekit.plugins.resemble import TTS

async def run_tts_example():
    # Use TTS with async context manager for automatic resource cleanup
    async with TTS(
        api_key="your_api_key",  # or set RESEMBLE_API_KEY environment variable
        voice_uuid="your_voice_uuid",
        # Optional parameters
        sample_rate=44100,  # Sample rate in Hz (default: 44100)
        precision="PCM_16",  # Audio precision (PCM_32, PCM_24, PCM_16, MULAW)
        output_format="wav",  # Output format (wav or mp3)
    ) as tts:
        # One-off synthesis (uses REST API)
        audio_stream = tts.synthesize("Hello, world!")
        
        # Process chunks as they arrive
        async for chunk in audio_stream:
            # Audio data is in the 'frame.data' attribute of SynthesizedAudio objects
            audio_data = chunk.frame.data
            print(f"Received chunk: {len(audio_data)} bytes")
        
        # Alternative: collect all audio at once into a single AudioFrame
        audio_stream = tts.synthesize("Another example sentence.")
        audio_frame = await audio_stream.collect()
        print(f"Collected complete audio: {len(audio_frame.data)} bytes")
        
        # Real-time streaming synthesis (uses WebSocket API)
        # Only available for Business plan users in Resemble AI
        stream = tts.stream()
        await stream.synthesize_text("Hello, world!")
        


# Run the example
asyncio.run(run_tts_example())

Alternative: Manual Resource Management

If you prefer to manage resources manually, make sure to properly clean up:

import asyncio
from livekit.plugins.resemble import TTS

async def run_tts_example():
    # Initialize TTS with your credentials
    tts = TTS(
        api_key="your_api_key", 
        voice_uuid="your_voice_uuid",
    )

    try:
        # TTS operations
        audio_stream = tts.synthesize("Hello, world!")
        async for chunk in audio_stream:
            # Access audio data correctly
            process_audio(chunk.frame.data)
    finally:
        # Always clean up resources when done
        await tts.aclose()

# Run the example
asyncio.run(run_tts_example())

Resource Management

When using this plugin outside of the LiveKit agent framework, it's important to properly manage the TTS instance lifecycle:

  1. Preferred method: Use the async context manager pattern (async with TTS(...) as tts:)
  2. If managing manually, always call await tts.aclose() in a finally block
  3. If you prefer to provide your own HTTP session, you can pass it using the http_session parameter:
import aiohttp

async def with_custom_session():
    async with aiohttp.ClientSession() as session:
        async with TTS(
            api_key="your_api_key",
            voice_uuid="your_voice_uuid",
            http_session=session
        ) as tts:
            # Use TTS...
            # No need to manually close anything - context managers handle it all

Implementation Details

This plugin uses two different approaches to generate speech:

  1. One-off Synthesis - Uses Resemble's REST API for simple text-to-speech conversion
  2. Streaming Synthesis - Uses Resemble's WebSocket API for real-time streaming synthesis

The WebSocket streaming API is only available for Resemble AI Business plan users.

Metadata

Release files for livekit-plugins-resemble 1.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for livekit-plugins-resemble 1.3.6
File Size Uploaded Provenance Actions
livekit_plugins_resemble-1.3.6.tar.gz 7.7 kB Without provenance Details for livekit_plugins_resemble-1.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for livekit-plugins-resemble 1.3.6
File Interpreter ABI Platform Actions
livekit_plugins_resemble-1.3.6-py3-none-any.whl Python 3 none any Details for livekit_plugins_resemble-1.3.6-py3-none-any.whl

Total release size: 16.3 kB

Release files / livekit_plugins_resemble-1.3.6.tar.gz

Download URL livekit_plugins_resemble-1.3.6.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
45247abbf730689dadfcfc075c29f82d21e7059029d1421856b34ce34a949bf5
BLAKE2b-256 checksum
How to use checksums
e1a875f6bb5f1d7b3456699dbf2bc7b07b38a1dce70e94aea6cf95c5661a1c0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.12

Release files / livekit_plugins_resemble-1.3.6-py3-none-any.whl

Download URL livekit_plugins_resemble-1.3.6-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a8ed487b8331d7b639760847a51794cfb73a2c3466523dbf1581fe434a45f9b
BLAKE2b-256 checksum
How to use checksums
3bc3e3c6fb332a934d2f97d4a3cc53e32eb1158e2319e79a53551839a3724772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.12

Security for livekit-plugins-resemble 1.3.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page