M
M
Maxim0452019-12-08 21:48:05
Python
Maxim045, 2019-12-08 21:48:05

How to adjust the playback speed of an mp3 file in python using the pygame module?

I need to run audio in python. For this, I chose the pygame module. It turned out that he plays mp3 very slowly. Please tell me how to change its playback speed?

import pygame
from pygame import mixer

mixer.init()
mixer.music.load('c:\\Music2\\Numb.mp3')
mixer.music.play()
input()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Web Dentist, 2019-12-08
@Maxim045

import pygame, mutagen.mp3

song_file = "c:\\Music2\\Numb.mp3"

mp3 = mutagen.mp3.MP3(song_file)
pygame.mixer.init(frequency=mp3.info.sample_rate)

pygame.mixer.music.load(song_file)
pygame.mixer.music.play()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question