-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.py
39 lines (25 loc) · 855 Bytes
/
code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
from PyQt4 import QtCore,QtGui
from Test_two import Ui_MainWindow
import time, wave, pymedia.audio.sound as sound
class Test_Two(QtGui.QMainWindow):
def __init__(self,parent=None):
QtGui.QWidget.__init__(self, parent=None)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.pushButton,QtCore.SIGNAL("clicked()"),self.file_dialog)
def file_dialog(self):
f= wave.open( 'phone-off-hook-1.wav', 'rb' )
sampleRate= f.getframerate()
channels= f.getnchannels()
format= sound.AFMT_S16_LE
snd= sound.Output( sampleRate, channels, format )
s= f.readframes( 300000 )
snd.play( s )
while snd.isPlaying(): time.sleep( 0.05 )
#print ("hello")
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = Test_Two()
myapp.show()
sys.exit(app.exec_())