Home Pygame will only play some .wav files
Reply: 1

Pygame will only play some .wav files

Andrew Bell
Andrew Bell Published in 2017-12-04 19:47:04Z

I am currently trying to programme some Christmas lights using the GPIO pins on the raspberry pi 3. and the lights work, so i decided to put some Christmas music to it as well. when using Pygame, Python won't let me use .mp3 files, and it only lets me play certain .wav files, so when i downloaded some christmas songs from http://www.thewavsite.com/christmas.htm, none of them worked. i will attach the code that i used. I hope you can be of help.

import pygame

s = pygame.mixer.Sound("all_i_want_for_christmas.wav")
print "Happy christmas!!"
furas Reply to 2017-12-04 21:31:28Z

I checked one of christmas songs using on Linux commands file and ffprobe and both show that this .wav uses mp3 compression :)

You will have to convert to real wav before you use it with PyGame.

file shows

A Christmas To Remember - Kenny Rogers & Dolly Parton.wav: 
 RIFF (little-endian) data, WAVE audio, MPEG Layer 3, mono 22050 Hz

ffprobe shows

Input #0, wav, from 'A Christmas To Remember - Kenny Rogers & Dolly Parton.wav':
  Duration: 00:03:39.75, bitrate: 32 kb/s
    Stream #0:0: Audio: mp3 (U[0][0][0] / 0x0055), 22050 Hz, mono, s16p, 32 kb/s
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301259 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO