Skip to main content

Python SDK for avatar WebSocket services with audio streaming and animation frame reception

Project description

Spatius Python SDK

Python server SDK for creating Spatius avatar sessions.

Installation

pip install spatius

Install the optional Ogg Opus encoder support when you want the SDK to encode raw PCM before sending:

pip install "spatius[opus]"

Quick Start

import asyncio
from datetime import datetime, timedelta, timezone

from spatius import new_avatar_session


async def main():
    session = new_avatar_session(
        api_key="your-api-key",
        app_id="your-app-id",
        avatar_id="your-avatar-id",
        expire_at=datetime.now(timezone.utc) + timedelta(minutes=5),
        transport_frames=lambda frame, last: print(
            f"Received frame: {len(frame)} bytes, last={last}"
        ),
        on_error=lambda err: print(f"Session error: {err}"),
        on_close=lambda: print("Session closed"),
    )

    await session.init()
    connection_id = await session.start()
    print(f"Connected: {connection_id}")

    audio_data = b"..."  # mono PCM s16le audio bytes
    request_id = await session.send_audio(audio_data, end=True)
    print(f"Sent audio request: {request_id}")

    await asyncio.sleep(10)
    await session.close()


if __name__ == "__main__":
    asyncio.run(main())

Documentation

See the full Python SDK guide at docs.spatius.ai/sdk-reference/python-sdk/python-sdk.

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

spatius-1.0.1.tar.gz (136.2 kB view details)

Uploaded Source

Built Distribution

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

spatius-1.0.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file spatius-1.0.1.tar.gz.

File metadata

  • Download URL: spatius-1.0.1.tar.gz
  • Upload date:
  • Size: 136.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spatius-1.0.1.tar.gz
Algorithm Hash digest
SHA256 199b73f353b6bf32c65f8e71f5708d466c599befd87f04f440db4e0de4b84abb
MD5 296967c19551cf48ca621455374b26ec
BLAKE2b-256 c19368ed1891abe67d57b481af613157f1a12bf0e34344a0bd14a3a7360c376a

See more details on using hashes here.

Provenance

The following attestation bundles were made for spatius-1.0.1.tar.gz:

Publisher: publish.yml on spatius-ai/spatius-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spatius-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: spatius-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spatius-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 305bb0c1625629604b5c0f328de04dc19c817f0789f8e9f488d17eb39848a463
MD5 b54aa1c7b620ea37b59cfe675d512848
BLAKE2b-256 7118ba6605cac93d6229ca186b914f9021c7f492ae56a7466422f6a674e7775c

See more details on using hashes here.

Provenance

The following attestation bundles were made for spatius-1.0.1-py3-none-any.whl:

Publisher: publish.yml on spatius-ai/spatius-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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