Tkinter Sound (Python)

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
vegaseat vegaseat is offline Offline Jun 26th, 2006, 12:45 am |
0
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.
Quick reply to this message  
Python Syntax
  1. # using tkSnack to play .wav .mp3 and .au sound files on Tkinter
  2. # needs Python module tkSnack developed at KTH in Stockholm, Sweden
  3. # free download: snack229-py.zip or later version
  4. # from: http://www.speech.kth.se/snack/
  5. # on my system I copied tkSnack.py to D:\Python24\Lib and the folder snacklib to D:\Python24\tcl
  6. # tested with Python24 vegaseat 25jun2006
  7.  
  8. from Tkinter import *
  9. import tkFileDialog
  10. import tkSnack
  11.  
  12. form1 = Tk()
  13. # have to initialize the sound system
  14. tkSnack.initializeSnack(form1)
  15.  
  16. def load_play_sound():
  17. mask_list = [("Sound files","*.wav *.au *.mp3")]
  18. sound_file = tkFileDialog.askopenfilename(initialdir='', filetypes=mask_list)
  19. form1.title('...'+sound_file[-15:])
  20. sound1 = tkSnack.Sound(load=sound_file)
  21. sound1.play()
  22.  
  23. label1 = Label(form1, text=' using tkSnack to play .wav .mp3 and .au sound files ')
  24. label1.pack(side=TOP)
  25. button1 = Button(form1, text=' Load Sound ', command=load_play_sound)
  26. button1.pack(side=TOP)
  27.  
  28. form1.mainloop()

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC