Skip to content
Proyek

Tentang

Give a face to your voice AI in 5 lines of code. Generate realtime avatar video connected to your voice AI locally

Desain dan media

Cara angka ini diukur

463 bintang61 Fork +3 dalam 24 jam

Pertumbuhan bintang terukur

dalam 24 jam
+3
dalam 7 hari
+19
dalam 15 hari
+37
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

OpenSpline

MIT license Python 3.10 to 3.12 Node.js 20+ NVIDIA GPU

Add a live face to any voice AI agent in five lines. Turn a portrait and generated audio into synchronized video and speech on OpenSpline Cloud or your own GPU.

Try Online (no GPU or installation needed)

Read Docs

  • Bring your agent. Keep your prompts, tools, microphone, and voice provider.
  • Python first, Node supported. Stream audio or use a ready-made connector.
  • Ready to display. Built-in viewer, React component, and web component.
  • Cloud or self-hosted. Start with an openspline cloud, or run the models on your GPUs.

AI agents: Download and attach llms.md for the complete documentation in one file.

Examples

Meera Acharya Lisa
Meera talking avatar preview
Try online
Acharya talking avatar preview
Try online
Lisa talking avatar preview
Try online
Steve Emily Professor Nikolaev
Steve talking avatar preview
Try online
Emily talking avatar preview
Try online
Professor Nikolaev talking avatar preview
Try online

Quickstart

There are two ways to run avatar generation:

GPU compatibility: PyTorch uses CUDA 12.8 for Blackwell (including RTX 50-series) and CUDA 12.6 for older NVIDIA GPUs. Pre-Ampere cards use FP32, which needs more VRAM and may be slower. AMD and Apple GPUs are not supported yet. Blackwell and pre-Ampere inference still need hardware validation.

Openspline Cloud

Create and embed an avatar in the Cloud dashboard, or use the API to generate avatars on Openspline GPUs.

Cloud Components & API Docs ↗

Self Host

Install the GPU service

Run the following command in a linux device/WSL2 with NVIDIA GPU:

curl -fsSL https://raw.githubusercontent.com/openspline/openspline/main/install.sh | sh

The installer creates a private Python environment and downloads the Low and High models.

Launch the demo

sh ~/.local/share/openspline/run.sh

Open http://localhost:7860 to access the demo.

Python SDK

Install the client package where your agent runs:

pip install openspline

Stream generated audio to a portrait:

from openspline import Openspline
client = Openspline()
async with client.avatar("portrait.jpg", quality="low") as avatar:
    print(avatar.viewer_url)
    await avatar.stream(agent.audio_stream(), sample_rate=24000)

Add a custom photo or video background.

stream() accepts generated PCM audio and returns after playback finishes. WAV and MP3 files are also supported.

The GPU stays active throughout a connected session; smooth continuous motion requires inference to keep up with playback.

Connectors

These snippets plug into an existing async agent. Openspline owns output playback; disable your previous speaker output to avoid playing audio twice. Provider credentials stay on your backend.

OpenAI Realtime

Install pip install openai==2.54.0. Wrap your existing OpenAI Realtime connection; tools and transcripts still reach your event handler.

from openspline import Openspline
from openspline.integrations import OpenAIRealtime

async with Openspline().avatar("portrait.jpg") as avatar:
    print(avatar.viewer_url)
    await avatar.wait_for_viewer()
    adapter = OpenAIRealtime(avatar, connection)
    try:
        async for event in adapter.wrap(connection):
            await handle_event(event)  # your existing handler
    finally:
        adapter.close()

Run the example: OPENAI_API_KEY=... python examples/python/openai_realtime.py portrait.jpg.

LiveKit (Python and Node)

The experimental LiveKit plugins support saved Cloud avatars and portrait uploads. Start the avatar before your existing agent session; your normal LiveKit frontend receives synchronized audio/video.

from livekit.plugins import openspline

avatar = openspline.AvatarSession(avatar_id="YOUR_AVATAR_ID")
await avatar.start(agent_session, room=ctx.room)
import * as openspline from '@livekit/agents-plugin-openspline';

const avatar = new openspline.AvatarSession({ avatarId: 'YOUR_AVATAR_ID' });
await avatar.start(agentSession, ctx.room);

Installation, complete examples, and recorded demos · LiveKit integration guide.

Set OPENSPLINE_API_KEY and your LIVEKIT_* credentials. For self-hosting, unset the Cloud key and use a portrait instead. Existing SDK integration imports remain supported.

Gemini Realtime

Install pip install google-genai==1.75.0. Forward every audio part from your existing Gemini Live session, including interruption and turn-end events.

from openspline import Openspline
from openspline.integrations import GeminiLive

async with Openspline().avatar("portrait.jpg") as avatar:
    print(avatar.viewer_url)
    await avatar.wait_for_viewer()
    async for event in GeminiLive(avatar).wrap(live_session.receive()):
        await handle_event(event)  # your existing handler
    await avatar.end_turn()

Run the example: GEMINI_API_KEY=... python examples/python/gemini.py portrait.jpg. Repeat the receive loop for subsequent turns; set GEMINI_LIVE_MODEL to override the model.

ElevenLabs Agents

Connect an existing ElevenLabs agent WebSocket. No additional provider SDK is needed. Pass decoded events, including the initial metadata, so the adapter uses the agent's negotiated audio format.

import json
from openspline import Openspline
from openspline.integrations import ElevenLabsAgents

async with Openspline().avatar("portrait.jpg") as avatar:
    print(avatar.viewer_url)
    await avatar.wait_for_viewer()
    adapter = ElevenLabsAgents(avatar)
    async for message in connection:
        event = json.loads(message)
        await adapter.handle(event)
        await handle_event(event)  # keep your input, pong, and tool handlers

The adapter supports PCM and μ-law audio, flushes final audio, and handles interruptions. It preserves transcripts and tool events for your existing handler. If attaching after connection setup, pass audio_format="pcm_24000" (or the negotiated format) to the constructor. Node exports ElevenLabsAgents from @openspline/node/integrations, with await adapter.handle(event) and an optional format as the second constructor argument.

Python example: ELEVENLABS_AGENT_ID=... python examples/python/elevenlabs_agents.py portrait.jpg. Node example: ELEVENLABS_AGENT_ID=... node examples/node/elevenlabs_agents.mjs portrait.jpg. Set ELEVENLABS_API_KEY for private agents; the examples request a signed URL on the backend. Each plays one response; the demo supports microphone conversations. Configure the agent's client events to include audio, interruption, and agent_response_complete. Custom client tools and required dynamic variables need your application's handlers and initiation data; the demo uses the agent's saved configuration.

Custom connector

Use any TTS provider or agent with an async PCM16 audio iterator. stream() buffers audio, flushes the final block, and waits for playback to finish.

from openspline import Openspline
client = Openspline(quality="low")
async with client.avatar("portrait.jpg") as avatar:
    print(avatar.viewer_url)
    await avatar.stream(agent.audio_stream(), sample_rate=24000)

For callbacks, await avatar.send_audio(chunk, sample_rate=24000), then await avatar.end_turn() when speech ends. Call await avatar.interrupt() on barge-in. Float32 uses encoding="pcm_f32le"; encoded streams use encoding="mp3". File example.

More connectors: OpenAI Agents, Pipecat, Google ADK, Vocode, and TEN. Python examples have locked dependencies; Vocode uses its own environment.

Configuration

Pass settings directly when initializing, or reuse a typed config object:

from openspline import Openspline, OpensplineConfig

client = Openspline(url="http://localhost:7860", quality="low")
config = OpensplineConfig(quality="high", timeout=300, viewer_timeout=90)
client = Openspline(config=config)  # a dict works too
Python / Node option Default Purpose
api_key / apiKey OPENSPLINE_API_KEY Backend-only Cloud key; automatically selects Cloud
url Cloud with a key; otherwise http://localhost:7860 Explicit URL or OPENSPLINE_URL overrides the service address
quality low Default quality: low or high
timeout 180 s / 180,000 ms HTTP and audio request timeout
viewer_timeout / viewerTimeout 60 s / 60,000 ms Wait for the playback destination

Explicit Python parameters override the config object; explicit settings override environment defaults. avatar(..., quality="high") overrides that session only. Invalid configuration fails before connecting. JSON Schema describes Python settings, with #/$defs/node and #/$defs/server for Node and worker configuration. Only avatar.session should be passed to a browser.

Node SDK

Use Node 20+ and install the SDK with one command:

npm install @openspline/node
import { Openspline, type OpensplineConfig } from "@openspline/node";
const config: OpensplineConfig = { apiKey: "YOUR_API_KEY", quality: "low" };
const client = new Openspline(config);
await using avatar = await client.avatar("portrait.jpg");
console.log(avatar.viewerUrl);
await avatar.stream(agent.audioStream(), { sample_rate: 24000 });

Add a custom photo or video background.

For a saved Cloud avatar, use client.avatar({ avatarId: "YOUR_AVATAR_ID" }). You can omit apiKey to read OPENSPLINE_API_KEY from your server environment. For a local service, omit the key and unset that environment variable.

Node examples: run npm ci there, then node universal.mjs portrait.jpg speech.wav. Without await using, call avatar.close() in finally.

GPU workers

Configure multiple workers

Edit ~/.local/share/openspline/workers.yaml (example). Each worker loads weights once and serves one session at a time; device assignments cannot overlap.

workers:
  - { id: low-0, quality: low, devices: [0] }
  - { id: low-1, quality: low, devices: [1] }

The demo switches quality automatically for a single worker. For SDK sessions or multiple workers, configure a worker with quality: high, devices: [0, 1] to use a GPU pair, then run sh ~/.local/share/openspline/run.sh --prepare before starting. Busy workers return a typed CapacityError; an unconfigured quality returns ConfigurationError. IDs are relative to CUDA_VISIBLE_DEVICES when set. For multiple workers, remove OPENSPLINE_GPU, OPENSPLINE_GPUS, and OPENSPLINE_QUALITY overrides from the installed .env and configure devices in workers.yaml.

Network settings

Set OPENSPLINE_HOST, OPENSPLINE_PORT, OPENSPLINE_PUBLIC_URL, and provider credentials in the installed .env. Use HTTPS for remote microphone access. WebRTC playback additionally needs reachable UDP ports or TURN configured in ice_servers. API reference: http://localhost:7860/docs. Health: /readyz; metrics: /metrics.

Development and validation

Run uv sync --all-packages, npm ci && npm run build, then uv run pytest && npm test. uv run openspline serve --backend test --dev starts a static-portrait development service without a GPU. Keep optional framework environments separate; from examples/python, use uv pip sync requirements.lock in an activated environment. Release workflows build and optionally publish Python and npm packages.

Regenerate the native installer dependency locks with python scripts/lock-gpu.py (requires uv). The installer combines requirements/server.txt with the selected cu126.txt or cu128.txt runtime lock.

Real low/high inference, GPU streaming, browser/React playback, and native LiveKit have been exercised. Short A100 tests measured about 64 FPS for low quality and 8 FPS for high quality under different load conditions; these are engine rates, not playback latency. Long-duration, multi-GPU, cloud-provider, and TEN runtime validation remain incomplete.

License

MIT. The vendored inference code retains its Apache-2.0 license and third-party notices; model weights have separate terms.

Acknowledgments

Openspline builds on open research and infrastructure, with thanks to the teams and contributors behind:

  • SoulX-FlashHead for the audio-driven talking-head models that power avatar generation.
  • LiveKit Agents for the real-time agent framework that Openspline integrates with to bring avatars into voice conversations.
  • Wan for video generation research and VAE components used in the inference backend through SoulX-FlashHead.
  • LTX-Video for video autoencoder components used in the inference backend through SoulX-FlashHead.

Openspline carries this work forward with a self-hosted runtime for interactive avatars: synchronized audio and video streaming, continuous idle motion, interruption handling, GPU worker orchestration, and a shared API across voice providers. Its Python and Node SDKs, agent connectors, and embeddable players make these capabilities available to developers building their own conversational experiences.

Jelajahi proyek terkait

Memuat…