Somewhat fancy voice command recognition software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. class UI(gobject.GObject):
  10. __gsignals__ = {
  11. 'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
  12. }
  13. def __init__(self,args):
  14. gobject.GObject.__init__(self)
  15. #start by making our app
  16. self.app = QApplication(args)
  17. #make a window
  18. self.window = QMainWindow()
  19. #give the window a name
  20. self.window.setWindowTitle("BlatherQt")
  21. center = QWidget()
  22. self.window.setCentralWidget(center)
  23. layout = QVBoxLayout()
  24. center.setLayout(layout)
  25. #make a listen/stop button
  26. self.lsbutton = QPushButton("Listen")
  27. layout.addWidget(self.lsbutton)
  28. #make a continuous button
  29. self.ccheckbox = QCheckBox("Continuous Listen")
  30. layout.addWidget(self.ccheckbox)
  31. #connect the buttonsc
  32. self.lsbutton.clicked.connect(self.lsbutton_clicked)
  33. self.ccheckbox.clicked.connect(self.ccheckbox_clicked)
  34. def recognizer_finished(self, x, y):
  35. if self.ccheckbox.isChecked():
  36. pass
  37. else:
  38. self.lsbutton_stopped()
  39. def ccheckbox_clicked(self):
  40. checked = self.ccheckbox.isChecked()
  41. if checked:
  42. #disable lsbutton
  43. self.lsbutton.setEnabled(False)
  44. self.lsbutton_stopped()
  45. self.emit('command', "continuous_listen")
  46. else:
  47. self.lsbutton.setEnabled(True)
  48. self.emit('command', "continuous_stop")
  49. def lsbutton_stopped(self):
  50. self.lsbutton.setText("Listen")
  51. def lsbutton_clicked(self):
  52. val = self.lsbutton.text()
  53. print val
  54. if val == "Listen":
  55. self.emit("command", "listen")
  56. self.lsbutton.setText("Stop")
  57. else:
  58. self.lsbutton_stopped()
  59. self.emit("command", "stop")
  60. def run(self):
  61. self.window.show()
  62. self.app.exec_()
  63. def finished(self, text):
  64. print text
  65. #if the continuous isn't pressed
  66. if not self.ccheckbox.isChecked():
  67. self.lsbutton_stopped()
  68. def quit(self):
  69. #sys.exit()
  70. pass