Skip to main content

Simli AI SDK

This package is a simple and streamlined to use the Simli WebRTC API. To use the Simli SDK:

pip install simli-ai

The simplest way to use the package looks like this

import asyncio
from simli import SimliClient, SimliConfig
from simli.renderers import FileRenderer
async def main():
    async with SimliClient(
        SimliConfig(
            apiKey="",  # API Key
            faceId="",  # Face ID
            maxSessionLength=20,
            maxIdleTime=10,
        )
    ) as connection:
        await connection.send(audio) # Audio is the raw PCM16 16khz mono audio data
        await FileRenderer(connection).render() # Write the output to an output.mp4 file

asyncio.run(main())

The audio can be loaded from a local file or a result of a TTS call.

If you want to display the stream, you can install the optional dependency "local"

pip install "simli-ai[local]"

And modify the snippet above by replacing FileRenderer with LocalRenderer. Note that LocalRenderer doesn't work on headless machines.

If you want to get the data in your python program to do extra processing on it later (or just want to access the data and send it somewhere else as you need) replace FileRenderer with NPArrayRenderer.

Now, calling NPArrayRenderer().render() returns two np.ndarray objects representing video and audio respectively. The shape of these objects will always be (N, H, W, 3) and (2, L) where N is the number of frames, H is the height of the frame, W is the width of the frame, 3 is the number of channels (always RGB) and for the audio 2 is the number of audio channels (always stereo) and L is the number of samples in the audio file (frame rate is 30 sampling rate is 48000hz).

Note that you can use the SimliClient without the using statement. It requires that you add the following calls to your function

connection = SimliClient(
        SimliConfig(
            apiKey="",  # API Key
            faceId="",  # Face ID
            maxSessionLength=20,
            maxIdleTime=10,
        )
    )
await connection.Initialize() # First thing after you create the SimliCLient
# The rest of your code
await connection.stop() # Call to gracefully shut down the SimliClient

Accessing the data on your own

You might not want to use the Renderer utils but would like to access the frames on your own. There are two ways to do so:

  1. Use await SimliClient().getNextVideoFrame() and await SimliClient().getNextAudioFrame() to receive the next frame and process them one by one
  2. Use async for videoFrame in SimliClient().getVideoStreamIterator() and async for audioFrame in SimliClient().getAudioStreamIterator() to get the frames all in the same loop. Note that it is recommended to run these loops in asyncio.create_task to receive all the frames concurrently.

The video and audio frames are PyAV frames.

Metadata

Release files for simli-ai 2.0.3

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

Source distribution (sdist)

Source distribution for simli-ai 2.0.3
File Size Uploaded
simli_ai-2.0.3.tar.gz 16.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simli-ai 2.0.3
File Interpreter ABI Platform
simli_ai-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.3 kB

Release files / simli_ai-2.0.3.tar.gz

Download URL simli_ai-2.0.3.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0d3f8f211ae4392c4208fedc9a51ca1d583adf21d785a973ab4e4db3e211d859
BLAKE2b-256 checksum
How to use checksums
347d00c6d9cdcf8d6c1e7274f5fc9908faf12e8ee7b3ab4961f6af5dbe5c2bd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.12

Release files / simli_ai-2.0.3-py3-none-any.whl

Download URL simli_ai-2.0.3-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6901c276c7fabecf51dab3e188ab0167ef119eebb4d4ca992839183d01acf5de
BLAKE2b-256 checksum
How to use checksums
846386106eec68fc99b131333ba07e7fa19400e318598722fa60eb0656208b7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.12

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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