frontengine 0.0.26__py3-none-any.whl → 0.0.28__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  import pyttsx3
2
2
  from PySide6.QtCore import QTimer
3
- from PySide6.QtGui import QScreen
4
3
  from PySide6.QtWidgets import QBoxLayout, QWidget, QPushButton, QHBoxLayout, QTextEdit, QMessageBox
5
4
 
6
5
  from frontengine.show.chat.chat_toast import ChatToast
@@ -0,0 +1,69 @@
1
+ import queue
2
+ import sys
3
+ import time
4
+
5
+ from PySide6.QtCore import QTimer
6
+ from PySide6.QtWidgets import QWidget, QPushButton, QBoxLayout, QLineEdit
7
+ from speech_recognition import Microphone
8
+ from speech_recognition import Recognizer
9
+ from speech_recognition import RequestError, UnknownValueError
10
+ from threading import Thread
11
+
12
+ from frontengine.utils.multi_language.language_wrapper import language_wrapper
13
+
14
+ LISTENER_QUEUE = queue.Queue()
15
+
16
+
17
+ def callback(recognizer: Recognizer, audio):
18
+ try:
19
+ text = recognizer.recognize_google(audio)
20
+ LISTENER_QUEUE.put_nowait(text)
21
+ except (RequestError, UnknownValueError) as error:
22
+ print(repr(error), file=sys.stderr)
23
+
24
+
25
+ class ChatSpeechToText(QWidget):
26
+
27
+ def __init__(self):
28
+ super().__init__()
29
+ # UI
30
+ self.box_layout = QBoxLayout(QBoxLayout.Direction.LeftToRight)
31
+ self.voice_text_edit = QLineEdit()
32
+ self.start_listen_button = QPushButton(
33
+ language_wrapper.language_word_dict.get("chat_recognizer_voice_button"))
34
+ self.start_listen_button.clicked.connect(self.start_listener_thread)
35
+ self.send_text_button = QPushButton(
36
+ language_wrapper.language_word_dict.get("chat_scene_send_chat"))
37
+ self.box_layout.addWidget(self.voice_text_edit)
38
+ self.box_layout.addWidget(self.start_listen_button)
39
+ self.box_layout.addWidget(self.send_text_button)
40
+ self.setLayout(self.box_layout)
41
+ # Listener Timer
42
+ self.listener_timer = QTimer()
43
+ self.listener_timer.setInterval(100)
44
+ self.listener_timer.timeout.connect(self.update_voice_edit)
45
+ self.listener_timer.start()
46
+
47
+ def start_listener_thread(self):
48
+ listener_thread = Thread(target=self.start_listener)
49
+ listener_thread.daemon = True
50
+ listener_thread.start()
51
+
52
+ @classmethod
53
+ def start_listener(cls):
54
+ recognizer = Recognizer()
55
+ microphone = Microphone()
56
+ with microphone as source:
57
+ recognizer.adjust_for_ambient_noise(source, duration=0.1)
58
+ stop_listening = recognizer.listen_in_background(microphone, callback)
59
+ for receive_sound_time in range(50):
60
+ time.sleep(0.1)
61
+ stop_listening(wait_for_stop=False)
62
+
63
+ def update_voice_edit(self):
64
+ if not LISTENER_QUEUE.empty():
65
+ self.voice_text_edit.setText(str(LISTENER_QUEUE.get_nowait()))
66
+
67
+ def close(self) -> bool:
68
+ self.listener_timer.stop()
69
+ return super().close()
@@ -7,6 +7,7 @@ from frontengine.show.scene.scene import SceneManager
7
7
  from frontengine.ui.chat.chat_model import load_scene_json, chat_model
8
8
  from frontengine.ui.chat.chat_scene_input import ChatInputDialog
9
9
  from frontengine.ui.chat.chatthread import ChatThread, DELEGATE_CHAT
10
+ from frontengine.ui.chat.speech_to_text import ChatSpeechToText
10
11
  from frontengine.utils.logging.loggin_instance import front_engine_logger
11
12
  from frontengine.utils.multi_language.language_wrapper import language_wrapper
12
13
 
@@ -15,6 +16,7 @@ class ChatSceneUI(QWidget):
15
16
 
16
17
  def __init__(self):
17
18
  super().__init__()
19
+ self.voice_input = None
18
20
  self.grid_layout = QGridLayout()
19
21
  self.grid_layout = QGridLayout(self)
20
22
  self.grid_layout.setContentsMargins(0, 0, 0, 0)
@@ -79,6 +81,10 @@ class ChatSceneUI(QWidget):
79
81
  self.local_box = QBoxLayout(QBoxLayout.Direction.LeftToRight)
80
82
  self.local_box.addWidget(self.locale_label)
81
83
  self.local_box.addWidget(self.locale_input)
84
+ # Start voice input
85
+ self.start_voice_input_button = QPushButton(
86
+ language_wrapper.language_word_dict.get("start_chat_voice_input_ui"))
87
+ self.start_voice_input_button.clicked.connect(self.start_voice_input)
82
88
  # Add to layout
83
89
  self.grid_layout.addWidget(self.choose_style_combobox, 0, 0)
84
90
  self.grid_layout.addWidget(self.close_delay_label, 0, 1)
@@ -88,7 +94,8 @@ class ChatSceneUI(QWidget):
88
94
  self.grid_layout.addLayout(self.local_box, 0, 5)
89
95
  self.grid_layout.addWidget(self.new_topic_button, 0, 6)
90
96
  self.grid_layout.addWidget(self.scene_input_button, 0, 7)
91
- self.grid_layout.addWidget(self.start_button, 0, 8)
97
+ self.grid_layout.addWidget(self.start_voice_input_button, 0, 8)
98
+ self.grid_layout.addWidget(self.start_button, 0, 9)
92
99
  self.grid_layout.addWidget(self.chat_panel_scroll_area, 1, 0, -1, -1)
93
100
  self.setLayout(self.grid_layout)
94
101
 
@@ -102,6 +109,16 @@ class ChatSceneUI(QWidget):
102
109
  if chat_model.rowCount() > 0:
103
110
  self.start_scene()
104
111
 
112
+ def start_voice_input(self):
113
+ self.voice_input = ChatSpeechToText()
114
+ self.voice_input.show()
115
+ self.voice_input.send_text_button.clicked.connect(self.send_voice_chat)
116
+
117
+ def send_voice_chat(self):
118
+ chat_thread = ChatThread(
119
+ self.chat_panel, self.voice_input.voice_text_edit.text(), self.locale_input.text())
120
+ chat_thread.start()
121
+
105
122
  def send_chat(self):
106
123
  chat_thread = ChatThread(
107
124
  self.chat_panel, self.chat_input.chat_input.toPlainText(), self.locale_input.text())
@@ -107,4 +107,7 @@ english_word_dict = {
107
107
  "chat_scene_precise": "precise",
108
108
  "chat_scene_balanced": "balanced",
109
109
  "chat_gpt_exception": "GPT error, pls retry or new topic",
110
+ # Chat voice input
111
+ "start_chat_voice_input_ui": "Open voice input ui",
112
+ "chat_recognizer_voice_button": "Start listen voice"
110
113
  }
@@ -107,4 +107,7 @@ traditional_chinese_word_dict = {
107
107
  "chat_scene_precise": "精準",
108
108
  "chat_scene_balanced": "平衡",
109
109
  "chat_gpt_exception": "GPT 錯誤,請重試或開始一個新話題",
110
+ # Chat voice input
111
+ "start_chat_voice_input_ui": "開啟聲音輸入介面",
112
+ "chat_recognizer_voice_button": "開始錄製聲音"
110
113
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: frontengine
3
- Version: 0.0.26
3
+ Version: 0.0.28
4
4
  Summary: FrontEngine is BingGPT that can use-define front end or only use like screen saver
5
5
  Author-email: JE-Chen <jechenmailman@gmail.com>
6
6
  License: MIT
@@ -19,6 +19,9 @@ License-File: LICENSE
19
19
  Requires-Dist: PySide6
20
20
  Requires-Dist: qt-material
21
21
  Requires-Dist: EdgeGPT
22
+ Requires-Dist: pyttsx3
23
+ Requires-Dist: SpeechRecognition
24
+ Requires-Dist: PyAudio
22
25
 
23
26
 
24
27
  [![Downloads](https://static.pepy.tech/badge/frontengine)](https://pepy.tech/project/frontengine)
@@ -24,8 +24,9 @@ frontengine/show/web/webview.py,sha256=iUGPA3qXpr07v9SriCudicvC3usT9mBYhOLuGIdEG
24
24
  frontengine/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  frontengine/ui/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  frontengine/ui/chat/chat_model.py,sha256=qmd1yh3q1Kv9GQHYD9YCVBLO-vI66t7OGVUxJnwSpg4,2775
27
- frontengine/ui/chat/chat_scene_input.py,sha256=kZjYo0_BOeEkcK0ckLLzxy33hWBfwUR2goRqIiRG38w,2518
27
+ frontengine/ui/chat/chat_scene_input.py,sha256=9feBPap11cqXh4x5qu5dC0eSXHrzU7mthAdoy8W4bwI,2483
28
28
  frontengine/ui/chat/chatthread.py,sha256=NsmdMBQgFUR1Z1ih1K5YC-rCSoTFlcIXtKJ0eVmeftY,2590
29
+ frontengine/ui/chat/speech_to_text.py,sha256=PzNDtYw6Ju5JqBeRIKICHVtlYq2hwpUTTF8jvHTjOPw,2548
29
30
  frontengine/ui/color/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
31
  frontengine/ui/color/global_color.py,sha256=Rh-R-X2BHVjcK5MTBZ1nEMVHgLj1rP4nk-wTQKbiwFA,125
31
32
  frontengine/ui/dialog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -36,7 +37,7 @@ frontengine/ui/main/language_menu.py,sha256=hY4W5pKeJTff_9JEfS0aSUh7Bi5zArLvSrhg
36
37
  frontengine/ui/main/main_ui.py,sha256=AkCaMPvZUEcVbfG-xixUkqgHNq6fr7MO6WKtHv2mz_I,6367
37
38
  frontengine/ui/setting/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
39
  frontengine/ui/setting/chat_scene/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- frontengine/ui/setting/chat_scene/chat_scene_setting.py,sha256=xrTjYPXfRskv_5mkgl2sMMbRgWwqwrozI4m_kPAIPVw,6795
40
+ frontengine/ui/setting/chat_scene/chat_scene_setting.py,sha256=CbdUm8goEY8abbqGOSCi4WD-mtYbjaPm-Dpo8ElU2nQ,7603
40
41
  frontengine/ui/setting/control_center/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
42
  frontengine/ui/setting/control_center/control_center_ui.py,sha256=Y3ZuOxkYOQ_Cc1mecJwJMhyqLyIi-LZand4X0k3vzfE,8318
42
43
  frontengine/ui/setting/gif/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -93,13 +94,13 @@ frontengine/utils/json_format/json_process.py,sha256=xJt_4Hm_o3sNDoeGtRW9Q7fsRj3
93
94
  frontengine/utils/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
94
95
  frontengine/utils/logging/loggin_instance.py,sha256=4sXnOHo5yyyHp1w7HcBd28-MXc6CTORQ0xAdMcb4tyU,579
95
96
  frontengine/utils/multi_language/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
- frontengine/utils/multi_language/english.py,sha256=1BlyJ82lo7XAEizvYOVP0Jsz5kK5R2y327Uq0-D96Yw,4692
97
+ frontengine/utils/multi_language/english.py,sha256=FEGbsVTh9e_Ruz77vfqInW2sdOCCddqxRalyyYj5VL8,4831
97
98
  frontengine/utils/multi_language/language_wrapper.py,sha256=KBqsG6ng5LSJkGqmu_YDxI8yAjXwgHM12DOzVgh_HXI,848
98
- frontengine/utils/multi_language/traditional_chinese.py,sha256=LJr-4gLGNHHeG3qT-QU0PKXSMNjEXNmZiuG3TwKFM9o,4838
99
+ frontengine/utils/multi_language/traditional_chinese.py,sha256=Oeabbu7iFNz5WNt_2P0-qc9DtYP3Ccska6MrclOSMYI,4982
99
100
  frontengine/utils/redirect_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
101
  frontengine/utils/redirect_manager/redirect_manager_class.py,sha256=zGJeVpjRU12MCnhVAdksAIhK_IhddI4cNKVb7DMgOZA,1888
101
- frontengine-0.0.26.dist-info/LICENSE,sha256=b3VlPBXnrDylKGffOEOLWMgOX-yfd65XC7PA1_sox2o,1085
102
- frontengine-0.0.26.dist-info/METADATA,sha256=ZE0G4ZgpoEMzS6VX8V5DDUnNbxhj5oMGbaAkVjNnM1o,2867
103
- frontengine-0.0.26.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
104
- frontengine-0.0.26.dist-info/top_level.txt,sha256=btCybScN_ubeQ8phsSDBB0T-HyHjqt7b-WPy61uTox0,12
105
- frontengine-0.0.26.dist-info/RECORD,,
102
+ frontengine-0.0.28.dist-info/LICENSE,sha256=b3VlPBXnrDylKGffOEOLWMgOX-yfd65XC7PA1_sox2o,1085
103
+ frontengine-0.0.28.dist-info/METADATA,sha256=uoq15uR017ACQnHFr8DDc5bpDUf17USjCYJTidEsHps,2949
104
+ frontengine-0.0.28.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
105
+ frontengine-0.0.28.dist-info/top_level.txt,sha256=btCybScN_ubeQ8phsSDBB0T-HyHjqt7b-WPy61uTox0,12
106
+ frontengine-0.0.28.dist-info/RECORD,,