livekit / python-sdks

LiveKit real-time and server SDKs for Python

Home Page:https://docs.livekit.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve API design of publishing data

davidzhao opened this issue · comments

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.