blob: 230f0551d683159a31f1256771f2f0189c3eb4df (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/usr/bin/env python2
import sys
import signal
import gobject
# Qt stuff
from PySide.QtCore import Signal, Qt
from PySide.QtGui import QApplication, QWidget, QMainWindow, QVBoxLayout
from PySide.QtGui import QLabel, QPushButton, QCheckBox
from TTS import TTS
class Blather:
def __init__(self):
self.tts = TTS();
self.tts.connect('finished',self.tts_finished)
#make a window
self.window = QMainWindow()
center = QWidget()
self.window.setCentralWidget(center)
layout = QVBoxLayout()
center.setLayout(layout)
#make a listen/stop button
self.lsbutton = QPushButton("Listen")
layout.addWidget(self.lsbutton)
#make a continuous button
self.ccheckbox = QCheckBox("Continuous Listen")
layout.addWidget(self.ccheckbox)
#connect the buttonsc
self.lsbutton.clicked.connect(self.lsbutton_clicked)
self.ccheckbox.clicked.connect(self.ccheckbox_clicked)
def tts_finished(self, x, y):
if self.ccheckbox.isChecked():
pass
else:
self.lsbutton_stopped()
def ccheckbox_clicked(self):
checked = self.ccheckbox.isChecked()
if checked:
#disable lsbutton
self.lsbutton.setEnabled(False)
self.tts.listen()
else:
self.lsbutton.setEnabled(True)
def lsbutton_stopped(self):
self.tts.pause()
self.lsbutton.setText("Listen")
def lsbutton_clicked(self):
val = self.lsbutton.text()
print val
if val == "Listen":
self.tts.listen()
self.lsbutton.setText("Stop")
else:
self.lsbutton_stopped()
def run(self):
self.window.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
b = Blather()
b.run()
signal.signal(signal.SIGINT, signal.SIG_DFL)
#start the app running
sys.exit(app.exec_())
|