The Audio class allows you to display an audio player for a specific audio file in the chatbot user interface.

You must provide either an url or a path or content bytes.

Attributes

name
str

The name of the audio file to be displayed in the UI. This is shown to users.

display
ElementDisplay

Determines where the element should be displayed in the UI. Choices are “side” (default), “inline”, or “page”.

url
str

The remote URL of the audio.

path
str

The local file path of the audio.

content
bytes

The file content of the audio in bytes format.

Example

import chainlit as cl


@cl.on_chat_start
async def main():
    elements = [
        cl.Audio(name="example.mp3", path="./example.mp3", display="inline"),
    ]
    await cl.Message(
        content="Here is an audio file",
        elements=elements,
    ).send()