play_audio()

async Client.play_audio()

Stream an audio file, remote live URL, or Telegram media directly into group voice chat.

Telegram media objects (Message, Audio, Voice, Document, or file ID strings) are streamed directly in-memory on-the-fly with ZERO disk footprint.

Usable by Users Bots
Parameters:
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

  • audio (str | MediaStream | Message | Audio | Voice | Document) – Path to the local audio file, live stream URL, MediaStream descriptor, or Telegram media object. Telegram media objects are piped directly into the voice chat in RAM without writing to disk.

Returns:

GroupCall – On success, group call information is returned.

Example

# Play local MP3
await app.play_audio(chat_id, "music.mp3")

# Play live radio stream URL
await app.play_audio(chat_id, "https://live.stream/radio.aac")

# Play Telegram message audio without downloading to disk
await app.play_audio(chat_id, message.audio)
await app.play_audio(chat_id, message)

# Play Telegram Document (e.g. lossless FLAC)
await app.play_audio(chat_id, message.document)

# Play by Telegram file_id string
await app.play_audio(chat_id, "CQACAgQAAx0CYg-qTQAB...")