Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change volume of Python's playsound

I’m using playsound library to successfully play an mp3 file:

import playsound
playsound.playsound('audio.mp3')

However, it’s too loud relative to the other sound sources on my computer. How do I decrease the volume?

I don’t wish to use pydub or pygame since I’m having other issues with those two libraries.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Since there doesn’t seems to be any documentation about this functionality, the only way to me is to change the application volume.

Changing the application volume could technically be done with ctypes.

However, while I’m not aware of the issue pygame poses, it seems quite trivial to implement only as a mixer:

import pygame
pygame.init()
pygame.mixer.init()
sound = pygame.mixer.Sound("path/to/file")
sound.set_volume(0.5)
sound.play() 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading