class Thread1(QtCore.QThread):
def __init__(self):
super().__init__()
def run(self) -> None:
with sr.Microphone() as source:
audio = r.listen(source)
try:
print("You said " + r.recognize_google(audio))
except LookupError:
print("Could not understand audio")
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
pybutton = QPushButton('Click me', self)
pybutton.clicked.connect(self.clickMethod)
pybutton.resize(100,32)
pybutton.move(50, 50)
def clickMethod(self):
Thread1().start()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
sys.exit(app.exec_())
If i call this function program is crashing but if i call in debug mode code is working. What's the wrong here?