Skip to main content

Add your description here

Project description

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.

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

simli_ai-1.0.3.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

simli_ai-1.0.3-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file simli_ai-1.0.3.tar.gz.

File metadata

  • Download URL: simli_ai-1.0.3.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for simli_ai-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e96b0621a1dbd9582b2ae3d51eefd4995983b49c1f1061eb9239707b15a1ee27
MD5 ced8b08146b59e4d2dbaadef85ef8ca4
BLAKE2b-256 8103b0b3e12c68fd3f9c57f6afeee67841349e4866b88760f413357af3043ae4

See more details on using hashes here.

File details

Details for the file simli_ai-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: simli_ai-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for simli_ai-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ffafa7540aa28833e207be8f3b199367c7f500dac1a8ba0108395bfb7d8362bc
MD5 48868ebaa2094521d26039b27f9d5dc3
BLAKE2b-256 5ed1dc382ba529de0d2d51f35e9bfd20b41d8f5c96404a3aa24bae97a5a5e51f

See more details on using hashes here.

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