The module tkSnack from our friends at KTH in Stockholm, Sweden allows you to play a variety of sound files using the Tkinter GUI. Supported sound files are WAV, MP3, AU, SND and AIFF formats.
# using tkSnack to play .wav .mp3 and .au sound files on Tkinter # needs Python module tkSnack developed at KTH in Stockholm, Sweden # free download: snack229-py.zip or later version # from: http://www.speech.kth.se/snack/ # on my system I copied tkSnack.py to D:\Python24\Lib and the folder snacklib to D:\Python24\tcl # tested with Python24 vegaseat 25jun2006 from Tkinter import * import tkFileDialog import tkSnack form1 = Tk() # have to initialize the sound system tkSnack.initializeSnack(form1) def load_play_sound(): mask_list = [("Sound files","*.wav *.au *.mp3")] sound_file = tkFileDialog.askopenfilename(initialdir='', filetypes=mask_list) form1.title('...'+sound_file[-15:]) sound1 = tkSnack.Sound(load=sound_file) sound1.play() label1 = Label(form1, text=' using tkSnack to play .wav .mp3 and .au sound files ') label1.pack(side=TOP) button1 = Button(form1, text=' Load Sound ', command=load_play_sound) button1.pack(side=TOP) form1.mainloop()
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.