add_profile_audio()¶
- async Client.add_profile_audio()¶
Adds an audio file to the beginning of the profile audio files of the current user.
Usable by Users Bots- Parameters:
audio (
str|BinaryIO) – Audio file to add. Pass a file_id as string to add an audio file that exists on the Telegram servers, pass a file path as string to upload a new audio file that exists on your local machine, or pass a binary file-like object with its attribute “.name” set for in-memory uploads.duration (
int, optional) – Duration of sent video in seconds.performer (
str, optional) – Performer.title (
str) – Product name, 1-32 characters.thumb (
str|BinaryIO, optional) – Thumbnail of the video sent. The thumbnail should be in JPEG format and less than 200 KB in size. A thumbnail’s width and height should not exceed 320 pixels. Thumbnails can’t be reused and can be only uploaded as a new file.file_name (
str, optional) – File name of the story sent.progress (
Callable, optional) – Pass a callback function to view the file transmission progress. The function must take (current, total) as positional arguments (look at Other Parameters below for a detailed description) and will be called back each time a new file chunk has been successfully transmitted.progress_args (
tuple, optional) – Extra custom arguments for the progress callback function. You can pass anything you need to be available in the progress callback scope; for example, a Message object or a Client instance in order to edit the message with the updated progress status.
- Returns:
bool|None– On success, True is returned, otherwise, in case the upload is deliberately stopped withstop_transmission(), None is returned.
Example
# Add audio file by uploading from file await app.add_profile_audio("audio.mp3") # Set audio metadata await app.add_profile_audio( "audio.mp3", title="Title", performer="Performer", duration=234) # Keep track of the progress while uploading async def progress(current, total): print(f"{current * 100 / total:.1f}%") await app.add_profile_audio("audio.mp3", progress=progress)