livekit / python-sdks

LiveKit real-time and server SDKs for Python
https://docs.livekit.io
Apache License 2.0
106 stars 34 forks source link

Improve API design of publishing data #30

Closed davidzhao closed 10 months ago

davidzhao commented 1 year ago

Currently to publish audio data, a user would have to write something like this:

        audio_frame = livekit.AudioFrame.create(
            ...
        )
        audio_data = np.ctypeslib.as_array(audio_frame.data)

        while True:
            duration, decoded_pcm_data = producer.get_frame()
            np.copyto(audio_data, decoded_pcm_data)
            source.capture_frame(audio_frame)

Dealing with ctypes is not clean here, and this should be abstracted within the SDK itself.