Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,41 +6,39 @@ from easySpeech import speech
|
|
| 6 |
from backend.core import core
|
| 7 |
from backend.speak import speak
|
| 8 |
|
| 9 |
-
|
| 10 |
class MainThread(QtCore.QThread):
|
| 11 |
def __init__(self):
|
| 12 |
-
super(MainThread,self).__init__()
|
| 13 |
|
| 14 |
@QtCore.pyqtSlot()
|
| 15 |
def run(self):
|
| 16 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 17 |
try:
|
| 18 |
-
future = executor.submit(speech.speech,"google")
|
| 19 |
return_value = future.result()
|
| 20 |
except:
|
| 21 |
-
return_value=""
|
| 22 |
print(return_value)
|
| 23 |
with concurrent.futures.ThreadPoolExecutor() as main:
|
| 24 |
try:
|
| 25 |
-
main_core = main.submit(core,return_value)
|
| 26 |
value = main_core.result()
|
| 27 |
speak(value)
|
| 28 |
except:
|
| 29 |
pass
|
| 30 |
|
| 31 |
-
|
| 32 |
class Widget(QtWidgets.QWidget):
|
| 33 |
def __init__(self, parent=None):
|
| 34 |
super(Widget, self).__init__(parent)
|
| 35 |
-
#
|
| 36 |
self.shortcut_open = QtWidgets.QShortcut(QtGui.QKeySequence('f5'), self)
|
| 37 |
self.shortcut_open.activated.connect(self.download)
|
| 38 |
self.setWindowTitle("CHESS")
|
| 39 |
self.setFixedSize(330, 620)
|
| 40 |
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
|
| 41 |
-
self.setStyleSheet('background-color: black;color:white')
|
| 42 |
self.view = QtWebEngineWidgets.QWebEngineView()
|
| 43 |
-
self.view
|
| 44 |
self.view.page().profile().downloadRequested.connect(self.on_downloadRequested)
|
| 45 |
self.view.load(QtCore.QUrl("https://j-dogcoder.github.io/AI/templates/"))
|
| 46 |
hbox = QtWidgets.QHBoxLayout(self)
|
|
@@ -49,23 +47,20 @@ class Widget(QtWidgets.QWidget):
|
|
| 49 |
|
| 50 |
def download(self):
|
| 51 |
try:
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
th.start()
|
| 56 |
except:
|
| 57 |
-
pass
|
| 58 |
|
| 59 |
-
#yes you are right i am using download requested to call python function
|
| 60 |
@QtCore.pyqtSlot("QWebEngineDownloadItem*")
|
| 61 |
-
def on_downloadRequested(self):
|
| 62 |
try:
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
th.start()
|
| 67 |
except:
|
| 68 |
-
pass
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
import sys
|
|
|
|
| 6 |
from backend.core import core
|
| 7 |
from backend.speak import speak
|
| 8 |
|
|
|
|
| 9 |
class MainThread(QtCore.QThread):
|
| 10 |
def __init__(self):
|
| 11 |
+
super(MainThread, self).__init__()
|
| 12 |
|
| 13 |
@QtCore.pyqtSlot()
|
| 14 |
def run(self):
|
| 15 |
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 16 |
try:
|
| 17 |
+
future = executor.submit(speech.speech, "google")
|
| 18 |
return_value = future.result()
|
| 19 |
except:
|
| 20 |
+
return_value = ""
|
| 21 |
print(return_value)
|
| 22 |
with concurrent.futures.ThreadPoolExecutor() as main:
|
| 23 |
try:
|
| 24 |
+
main_core = main.submit(core, return_value)
|
| 25 |
value = main_core.result()
|
| 26 |
speak(value)
|
| 27 |
except:
|
| 28 |
pass
|
| 29 |
|
|
|
|
| 30 |
class Widget(QtWidgets.QWidget):
|
| 31 |
def __init__(self, parent=None):
|
| 32 |
super(Widget, self).__init__(parent)
|
| 33 |
+
# Define shortcut
|
| 34 |
self.shortcut_open = QtWidgets.QShortcut(QtGui.QKeySequence('f5'), self)
|
| 35 |
self.shortcut_open.activated.connect(self.download)
|
| 36 |
self.setWindowTitle("CHESS")
|
| 37 |
self.setFixedSize(330, 620)
|
| 38 |
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
|
| 39 |
+
self.setStyleSheet('background-color: black; color: white')
|
| 40 |
self.view = QtWebEngineWidgets.QWebEngineView()
|
| 41 |
+
self.view.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
|
| 42 |
self.view.page().profile().downloadRequested.connect(self.on_downloadRequested)
|
| 43 |
self.view.load(QtCore.QUrl("https://j-dogcoder.github.io/AI/templates/"))
|
| 44 |
hbox = QtWidgets.QHBoxLayout(self)
|
|
|
|
| 47 |
|
| 48 |
def download(self):
|
| 49 |
try:
|
| 50 |
+
thread = threading.Thread(target=MainThread().run)
|
| 51 |
+
thread.daemon = True
|
| 52 |
+
thread.start()
|
|
|
|
| 53 |
except:
|
| 54 |
+
pass
|
| 55 |
|
|
|
|
| 56 |
@QtCore.pyqtSlot("QWebEngineDownloadItem*")
|
| 57 |
+
def on_downloadRequested(self, download):
|
| 58 |
try:
|
| 59 |
+
thread = threading.Thread(target=MainThread().run)
|
| 60 |
+
thread.daemon = True
|
| 61 |
+
thread.start()
|
|
|
|
| 62 |
except:
|
| 63 |
+
pass
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
import sys
|