Agent Framework plugin for SpatialReal Avatar
Project description
LiveKit Agents Plugin for SpatialReal Avatar
This plugin provides integration with SpatialReal's avatar service for lip-synced avatar rendering in LiveKit voice agents.
Installation
pip install livekit-plugins-spatialreal
Or install from source:
pip install -e .
Configuration
Set the following environment variables:
# Required
SPATIALREAL_API_KEY=your-api-key
SPATIALREAL_APP_ID=your-app-id
SPATIALREAL_AVATAR_ID=your-avatar-id
# Optional
SPATIALREAL_CONSOLE_ENDPOINT=
SPATIALREAL_INGRESS_ENDPOINT=
# LiveKit credentials
LIVEKIT_URL=
LIVEKIT_API_KEY=
LIVEKIT_API_SECRET=
Usage
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
from livekit.plugins import spatialreal
class VoiceAssistant(Agent):
def __init__(self):
super().__init__(
instructions="You are a helpful voice assistant."
)
async def entrypoint(ctx: JobContext):
await ctx.connect()
# Configure your pipeline components (VAD, STT, LLM, TTS)
session = AgentSession(
vad=vad,
stt=stt,
llm=llm,
tts=tts,
)
# Initialize and start the avatar session
avatar = spatialreal.AvatarSession()
await avatar.start(session, room=ctx.room)
# Start the agent session
await session.start(
agent=VoiceAssistant(),
room=ctx.room,
)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
For production agents, catch SpatialRealException so you can decide whether to fail the job or continue without avatar output:
try:
await avatar.start(session, room=ctx.room)
except spatialreal.SpatialRealException as err:
logger.error("Avatar startup failed: %s", err)
raise
API Reference
AvatarSession
Main class for integrating SpatialReal avatars with LiveKit agents.
Constructor Parameters
| Parameter | Type | Description |
|---|---|---|
api_key |
str |
SpatialReal API key (or set SPATIALREAL_API_KEY) |
app_id |
str |
SpatialReal application ID (or set SPATIALREAL_APP_ID) |
avatar_id |
str |
Avatar ID to use (or set SPATIALREAL_AVATAR_ID) |
console_endpoint_url |
str |
Custom console endpoint URL |
ingress_endpoint_url |
str |
Custom ingress endpoint URL |
avatar_participant_identity |
str |
LiveKit identity for avatar participant |
idle_timeout_seconds |
int |
LiveKit egress idle timeout in seconds (0 uses server defaults) |
sample_rate |
int | None |
Optional avatar audio sample rate override |
Methods
start(agent_session, room, *, livekit_url, livekit_api_key, livekit_api_secret): Start the avatar session and hook into the agent's audio output. RaisesSpatialRealExceptionwith actionable context if startup fails.aclose(): Clean up avatar session resources.
When starting, the plugin automatically sets lk.publish_on_behalf to the
agent participant identity for avatar worker association in LiveKit frontends.
SpatialRealException
Exception raised for SpatialReal-related errors.
How It Works
- The plugin intercepts TTS audio output from the agent session
- Audio frames are forwarded to SpatialReal's avatar service
- SpatialReal generates lip-synced video and audio
- The avatar joins the LiveKit room and publishes the synchronized streams
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file livekit_plugins_spatialreal-1.4.4.tar.gz.
File metadata
- Download URL: livekit_plugins_spatialreal-1.4.4.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e799bd2c54834d0749496f2604c994ca3813898fc0ca14acf7e98effcb11cd26
|
|
| MD5 |
d9a00c1cee342fcc9e06bf65b88a5365
|
|
| BLAKE2b-256 |
2323ab9d125a1a9e638bc55e7d339020eae874c9bc7bd4741db9c9fffa92deae
|
Provenance
The following attestation bundles were made for livekit_plugins_spatialreal-1.4.4.tar.gz:
Publisher:
publish.yml on spatialwalk/livekit-plugins-spatialreal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livekit_plugins_spatialreal-1.4.4.tar.gz -
Subject digest:
e799bd2c54834d0749496f2604c994ca3813898fc0ca14acf7e98effcb11cd26 - Sigstore transparency entry: 1018748128
- Sigstore integration time:
-
Permalink:
spatialwalk/livekit-plugins-spatialreal@272e8428c0017e40b763eed0a804c8bf0800113a -
Branch / Tag:
refs/tags/v1.4.4 - Owner: https://github.com/spatialwalk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@272e8428c0017e40b763eed0a804c8bf0800113a -
Trigger Event:
release
-
Statement type:
File details
Details for the file livekit_plugins_spatialreal-1.4.4-py3-none-any.whl.
File metadata
- Download URL: livekit_plugins_spatialreal-1.4.4-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d6d393d31de0cbf5e55c5e887929f5ebe1c89c8d6c10fc21ee1672fc22e1653
|
|
| MD5 |
8a0c22b5b9678f2e2320b76cdc45b21a
|
|
| BLAKE2b-256 |
c22ace24df2c2de72c146de168d02da5d241a8b1eb657f4a31d0a39b63681455
|
Provenance
The following attestation bundles were made for livekit_plugins_spatialreal-1.4.4-py3-none-any.whl:
Publisher:
publish.yml on spatialwalk/livekit-plugins-spatialreal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
livekit_plugins_spatialreal-1.4.4-py3-none-any.whl -
Subject digest:
3d6d393d31de0cbf5e55c5e887929f5ebe1c89c8d6c10fc21ee1672fc22e1653 - Sigstore transparency entry: 1018748135
- Sigstore integration time:
-
Permalink:
spatialwalk/livekit-plugins-spatialreal@272e8428c0017e40b763eed0a804c8bf0800113a -
Branch / Tag:
refs/tags/v1.4.4 - Owner: https://github.com/spatialwalk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@272e8428c0017e40b763eed0a804c8bf0800113a -
Trigger Event:
release
-
Statement type: