How to Add Audio in Presentation using Python

In this simple article, we will focus on how to add audio in Presentation using Python by configuring the environment using the well defined steps and executing the example code. This application can be used in any Python and .NET Core configured environments in operating systems like Windows, macOS or Linux to embed audio in PPTX using Python.

Steps to Insert Audio in Presentation using Python

  1. Establish the environment to use Aspose.Slides for Python via .NET in your application to add an audio frame
  2. Use the Presentation class object to create an empty presentation to embed an audio frame inside the presentation
  3. Load the selected slide from the presentation slides collection to add an audio frame
  4. Access the audio file from the disk and insert an audio frame on the slide using that audio
  5. Load the image from the disk and set that as an audio frame visible image on the slide
  6. Save the presentation having an embedded audio frame on the disk

By following the above mentioned steps in Python inserting audio in PowerPoint presentation is easily achievable, whereby the process will start with the creation of an empty presentation using the Presentation class instance and gaining access to the desired slide inside the slides collection. We will access the audio file from the disk to add an audio frame to the selected slide. Finally, an image from the disk will be loaded and set as a display image for the audio frame before saving the presentation having an embedded audio file on the disk.

Code to Insert Audio in Presentation using Python

With the help of a fairly simple code in Python saving MP3 audio in PPT presentation is easily possible using a very simple API interface. The IAudioFrame class is used to insert the audio, which also contains the setters for the properties like play audio in a loop, rewind mode, play mode and hiding audio to name a few.

In this short topic, we have focused on how to insert audio in Presentation using Python. If you are interested in learning about embedding a video file inside the presentation, refer to the article on how to add Video in Presentation using Python.

 English