Somewhat fancy voice command recognition software
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

blather.py 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python2
  2. import sys
  3. import signal
  4. import gobject
  5. # Qt stuff
  6. from PySide.QtCore import Signal, Qt
  7. from PySide.QtGui import QApplication, QWidget, QMainWindow, QVBoxLayout
  8. from PySide.QtGui import QLabel, QPushButton, QCheckBox
  9. from TTS import TTS
  10. class Blather:
  11. def __init__(self):
  12. self.tts = TTS();
  13. self.tts.connect('finished',self.tts_finished)
  14. #make a window
  15. self.window = QMainWindow()
  16. center = QWidget()
  17. self.window.setCentralWidget(center)
  18. layout = QVBoxLayout()
  19. center.setLayout(layout)
  20. #make a listen/stop button
  21. self.lsbutton = QPushButton("Listen")
  22. layout.addWidget(self.lsbutton)
  23. #make a continuous button
  24. self.ccheckbox = QCheckBox("Continuous Listen")
  25. layout.addWidget(self.ccheckbox)
  26. #connect the buttonsc
  27. self.lsbutton.clicked.connect(self.lsbutton_clicked)
  28. self.ccheckbox.clicked.connect(self.ccheckbox_clicked)
  29. def tts_finished(self, x, y):
  30. if self.ccheckbox.isChecked():
  31. pass
  32. else:
  33. self.lsbutton_stopped()
  34. def ccheckbox_clicked(self):
  35. checked = self.ccheckbox.isChecked()
  36. if checked:
  37. #disable lsbutton
  38. self.lsbutton.setEnabled(False)
  39. self.tts.listen()
  40. else:
  41. self.lsbutton.setEnabled(True)
  42. def lsbutton_stopped(self):
  43. self.tts.pause()
  44. self.lsbutton.setText("Listen")
  45. def lsbutton_clicked(self):
  46. val = self.lsbutton.text()
  47. print val
  48. if val == "Listen":
  49. self.tts.listen()
  50. self.lsbutton.setText("Stop")
  51. else:
  52. self.lsbutton_stopped()
  53. def run(self):
  54. self.window.show()
  55. if __name__ == "__main__":
  56. app = QApplication(sys.argv)
  57. b = Blather()
  58. b.run()
  59. signal.signal(signal.SIGINT, signal.SIG_DFL)
  60. #start the app running
  61. sys.exit(app.exec_())