Play Wave Sound Files with PySide/PyQT

vegaseat 1 Tallied Votes 3K Views Share

The PySide (PyQT) GUI toolkit can be used to play wave sound files.

''' ps_test_QSound1.py
a simple template to test PySide widgets like QSound

PySide is the official LGPL-licensed version of PyQT
for free PySide Windows installers see:
http://developer.qt.nokia.com/wiki/PySide_Binaries_Windows
or
http://www.lfd.uci.edu/~gohlke/pythonlibs/
tested with Python33 and Pyside112  by vegaseat  29jul2013
'''

import time
from PySide.QtCore import *
from PySide.QtGui import *

# replace [] with sys.argv for command line option
app = QApplication([])

# ----- start your widget test code ----

# pick a sound file (.wav only) you have
sound_file = "Pop.wav"
QSound.play(sound_file)

# create a label to show file (allows for proper exit too)
label = QLabel(sound_file)
label.show()

# ---- end of widget test code -----

app.exec_()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Mac OS X All sound file formats that NSSound supports, including QuickTime formats.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.