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.

QtUI.py 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env python2
  2. import sys
  3. import gobject
  4. # Qt stuff
  5. from PySide.QtCore import Signal, Qt
  6. from PySide.QtGui import QApplication, QWidget, QMainWindow, QVBoxLayout
  7. from PySide.QtGui import QLabel, QPushButton, QCheckBox
  8. class UI(gobject.GObject):
  9. __gsignals__ = {
  10. 'command' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,))
  11. }
  12. def __init__(self,args):
  13. gobject.GObject.__init__(self)
  14. #start by making our app
  15. self.app = QApplication(args)
  16. #make a window
  17. self.window = QMainWindow()
  18. #give the window a name
  19. self.window.setWindowTitle("BlatherQt")
  20. center = QWidget()
  21. self.window.setCentralWidget(center)
  22. layout = QVBoxLayout()
  23. center.setLayout(layout)
  24. #make a listen/stop button
  25. self.lsbutton = QPushButton("Listen")
  26. layout.addWidget(self.lsbutton)
  27. #make a continuous button
  28. self.ccheckbox = QCheckBox("Continuous Listen")
  29. layout.addWidget(self.ccheckbox)
  30. #connect the buttonsc
  31. self.lsbutton.clicked.connect(self.lsbutton_clicked)
  32. self.ccheckbox.clicked.connect(self.ccheckbox_clicked)
  33. #add a label to the UI to display the last command
  34. self.label = QLabel()
  35. layout.addWidget(self.label)
  36. def ccheckbox_clicked(self):
  37. checked = self.ccheckbox.isChecked()
  38. if checked:
  39. #disable lsbutton
  40. self.lsbutton.setEnabled(False)
  41. self.lsbutton_stopped()
  42. self.emit('command', "continuous_listen")
  43. else:
  44. self.lsbutton.setEnabled(True)
  45. self.emit('command', "continuous_stop")
  46. def lsbutton_stopped(self):
  47. self.lsbutton.setText("Listen")
  48. def lsbutton_clicked(self):
  49. val = self.lsbutton.text()
  50. if val == "Listen":
  51. self.emit("command", "listen")
  52. self.lsbutton.setText("Stop")
  53. #clear the label
  54. self.label.setText("")
  55. else:
  56. self.lsbutton_stopped()
  57. self.emit("command", "stop")
  58. def run(self):
  59. self.window.show()
  60. self.app.exec_()
  61. self.emit("command", "quit")
  62. def quit(self):
  63. pass
  64. def finished(self, text):
  65. print text
  66. #if the continuous isn't pressed
  67. if not self.ccheckbox.isChecked():
  68. self.lsbutton_stopped()
  69. self.label.setText(text)
  70. def quit(self):
  71. #sys.exit()
  72. pass