MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / send_audio

Method send_audio

src/telegram/_bot.py:1636–1808  ·  view source on GitHub ↗

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the ``.mp3`` or ``.m4a`` format. Bots can currently send audio files of up to :tg-const:`telegram.constants.FileSizeLimit.FILESIZE_UPLOAD` in

(
        self,
        chat_id: int | str,
        audio: "FileInput | Audio",
        duration: TimePeriod | None = None,
        performer: str | None = None,
        title: str | None = None,
        caption: str | None = None,
        disable_notification: ODVInput[bool] = DEFAULT_NONE,
        reply_markup: "ReplyMarkup | None" = None,
        parse_mode: ODVInput[str] = DEFAULT_NONE,
        caption_entities: Sequence["MessageEntity"] | None = None,
        protect_content: ODVInput[bool] = DEFAULT_NONE,
        message_thread_id: int | None = None,
        thumbnail: "FileInput | None" = None,
        reply_parameters: "ReplyParameters | None" = None,
        business_connection_id: str | None = None,
        message_effect_id: str | None = None,
        allow_paid_broadcast: bool | None = None,
        direct_messages_topic_id: int | None = None,
        suggested_post_parameters: "SuggestedPostParameters | None" = None,
        *,
        allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
        reply_to_message_id: int | None = None,
        filename: str | None = None,
        read_timeout: ODVInput[float] = DEFAULT_NONE,
        write_timeout: ODVInput[float] = DEFAULT_NONE,
        connect_timeout: ODVInput[float] = DEFAULT_NONE,
        pool_timeout: ODVInput[float] = DEFAULT_NONE,
        api_kwargs: JSONDict | None = None,
    )

Source from the content-addressed store, hash-verified

1634 )
1635
1636 async def send_audio(
1637 self,
1638 chat_id: int | str,
1639 audio: "FileInput | Audio",
1640 duration: TimePeriod | None = None,
1641 performer: str | None = None,
1642 title: str | None = None,
1643 caption: str | None = None,
1644 disable_notification: ODVInput[bool] = DEFAULT_NONE,
1645 reply_markup: "ReplyMarkup | None" = None,
1646 parse_mode: ODVInput[str] = DEFAULT_NONE,
1647 caption_entities: Sequence["MessageEntity"] | None = None,
1648 protect_content: ODVInput[bool] = DEFAULT_NONE,
1649 message_thread_id: int | None = None,
1650 thumbnail: "FileInput | None" = None,
1651 reply_parameters: "ReplyParameters | None" = None,
1652 business_connection_id: str | None = None,
1653 message_effect_id: str | None = None,
1654 allow_paid_broadcast: bool | None = None,
1655 direct_messages_topic_id: int | None = None,
1656 suggested_post_parameters: "SuggestedPostParameters | None" = None,
1657 *,
1658 allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
1659 reply_to_message_id: int | None = None,
1660 filename: str | None = None,
1661 read_timeout: ODVInput[float] = DEFAULT_NONE,
1662 write_timeout: ODVInput[float] = DEFAULT_NONE,
1663 connect_timeout: ODVInput[float] = DEFAULT_NONE,
1664 pool_timeout: ODVInput[float] = DEFAULT_NONE,
1665 api_kwargs: JSONDict | None = None,
1666 ) -> Message:
1667 """
1668 Use this method to send audio files, if you want Telegram clients to display them in the
1669 music player. Your audio must be in the ``.mp3`` or ``.m4a`` format.
1670
1671 Bots can currently send audio files of up to
1672 :tg-const:`telegram.constants.FileSizeLimit.FILESIZE_UPLOAD` in size, this limit may be
1673 changed in the future.
1674
1675 For sending voice messages, use the :meth:`send_voice` method instead.
1676
1677 .. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
1678
1679 .. versionchanged:: 20.5
1680 |removed_thumb_arg|
1681
1682 Args:
1683 chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
1684 audio (:obj:`str` | :term:`file object` | :class:`~telegram.InputFile` | \
1685 :obj:`bytes` | :class:`pathlib.Path` | :class:`telegram.Audio`): Audio file to
1686 send. |fileinput|
1687 Lastly you can pass an existing :class:`telegram.Audio` object to send.
1688
1689 .. versionchanged:: 13.2
1690 Accept :obj:`bytes` as input.
1691
1692 .. versionchanged:: 20.0
1693 File paths as input is also accepted for bots *not* running in

Calls 2

_parse_file_inputMethod · 0.95
_send_messageMethod · 0.95