Skip to main content

Agora's low latency, high performance Realtime API to work with Voice Conversational AI

Project description

API Reference for agora-realtime-ai-api Python Package

RtcOptions Class

The RtcOptions class represents the configuration options for an RTC (Real-Time Communication) session.

Constructor:

RtcOptions(
    *,
    channel_name: str = None,
    uid: int = 0,
    sample_rate: int = 24000,
    channels: int = 1,
    enable_pcm_dump: bool = False
)
  • channel_name: Name of the channel.
  • uid: Unique identifier for the user.
  • sample_rate: Sample rate for audio (default is 24,000 Hz).
  • channels: Number of audio channels (default is 1).
  • enable_pcm_dump: Flag to enable PCM audio dump (default is False).

AudioStream Class

The AudioStream class represents an iterable stream of PCM audio frames.

Constructor:

AudioStream()

Methods:

  • __aiter__() -> AsyncIterator[PcmAudioFrame]: Async iterator to traverse through audio frames.
  • __anext__() -> PcmAudioFrame: Returns the next audio frame in the queue.

Channel Class

The Channel class handles the RTC channel and associated operations such as connection, audio subscriptions, and data stream messages.

Constructor:

Channel(rtc: "RtcEngine", options: RtcOptions)

Methods:

  • connect() -> None: Connects to the channel asynchronously.
  • disconnect() -> None: Disconnects from the channel asynchronously.
  • get_audio_frames(uid: int) -> AudioStream: Returns the audio stream for a specific user.
  • push_audio_frame(frame: bytes) -> None: Sends a PCM audio frame to the channel.
  • clear_sender_audio_buffer() -> None: Clears the audio buffer used for sending.
  • subscribe_audio(uid: int) -> None: Subscribes to a user's audio stream.
  • unsubscribe_audio(uid: int) -> None: Unsubscribes from a user's audio stream.
  • send_stream_message(data: str, msg_id: str) -> None: Sends a data stream message to the channel.

ChatMessage Class

Represents a chat message to be sent over the RTC channel.

Constructor:

ChatMessage(message: str, msg_id: str)

Chat Class

Handles the queue of chat messages and sends them over the RTC channel.

Constructor:

Chat(channel: Channel)

Methods:

  • send_message(item: ChatMessage) -> None: Sends a chat message.

RtcEngine Class

The RtcEngine class initializes the Agora service and provides methods for managing RTC channels.

Constructor:

RtcEngine(appid: str, appcert: str)

Methods:

  • create_channel(options: RtcOptions) -> Channel: Creates an RTC channel with the given options.
  • destroy() -> None: Destroys the RTC engine instance.

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

agora-realtime-ai-api-1.0.9.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

agora_realtime_ai_api-1.0.9-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file agora-realtime-ai-api-1.0.9.tar.gz.

File metadata

  • Download URL: agora-realtime-ai-api-1.0.9.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.1

File hashes

Hashes for agora-realtime-ai-api-1.0.9.tar.gz
Algorithm Hash digest
SHA256 a758c4b4c12f6f2021c3826c6c86b58fd90ffa17262c4c16a141c6dfa5695ef5
MD5 479652b1b847fc07e86037983b4ad1a3
BLAKE2b-256 378ec03a5fb199fc5706f1f4eb88a13bc85d72013f3bf1155223d3f39ba46f7e

See more details on using hashes here.

File details

Details for the file agora_realtime_ai_api-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for agora_realtime_ai_api-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 bb1f403d6da423e3ffecf2192177936e8f795c66909631493772c4255d611473
MD5 bbdab8fa63e244005d3401709c6a8bd0
BLAKE2b-256 c14255f504bfde4f854f868dfc32fecc9f0402f9c5caa010b5829b2cadde57ce

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