frontengine 0.0.27__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,8 @@
1
+ import queue
1
2
  import sys
2
3
  import time
3
4
 
5
+ from PySide6.QtCore import QTimer
4
6
  from PySide6.QtWidgets import QWidget, QPushButton, QBoxLayout, QLineEdit
5
7
  from speech_recognition import Microphone
6
8
  from speech_recognition import Recognizer
@@ -9,10 +11,13 @@ from threading import Thread
9
11
 
10
12
  from frontengine.utils.multi_language.language_wrapper import language_wrapper
11
13
 
14
+ LISTENER_QUEUE = queue.Queue()
15
+
12
16
 
13
17
  def callback(recognizer: Recognizer, audio):
14
18
  try:
15
- print(recognizer.recognize_google(audio))
19
+ text = recognizer.recognize_google(audio)
20
+ LISTENER_QUEUE.put_nowait(text)
16
21
  except (RequestError, UnknownValueError) as error:
17
22
  print(repr(error), file=sys.stderr)
18
23
 
@@ -21,12 +26,6 @@ class ChatSpeechToText(QWidget):
21
26
 
22
27
  def __init__(self):
23
28
  super().__init__()
24
- # Recognize
25
- self.recognizer = Recognizer()
26
- try:
27
- self.microphone = Microphone()
28
- except IOError as error:
29
- print(repr(error), file=sys.stderr)
30
29
  # UI
31
30
  self.box_layout = QBoxLayout(QBoxLayout.Direction.LeftToRight)
32
31
  self.voice_text_edit = QLineEdit()
@@ -39,16 +38,32 @@ class ChatSpeechToText(QWidget):
39
38
  self.box_layout.addWidget(self.start_listen_button)
40
39
  self.box_layout.addWidget(self.send_text_button)
41
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()
42
46
 
43
47
  def start_listener_thread(self):
44
48
  listener_thread = Thread(target=self.start_listener)
45
49
  listener_thread.daemon = True
46
50
  listener_thread.start()
47
51
 
48
- def start_listener(self):
49
- with self.microphone as source:
50
- self.recognizer.adjust_for_ambient_noise(source, duration=0.3)
51
- stop_listening = self.recognizer.listen_in_background(self.microphone, callback)
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)
52
59
  for receive_sound_time in range(50):
53
60
  time.sleep(0.1)
54
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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: frontengine
3
- Version: 0.0.27
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
@@ -26,7 +26,7 @@ frontengine/ui/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
26
26
  frontengine/ui/chat/chat_model.py,sha256=qmd1yh3q1Kv9GQHYD9YCVBLO-vI66t7OGVUxJnwSpg4,2775
27
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=OzPAFwyRgUG6omkN35Ro0uEyHDq4aXMTcAESW935WSc,2089
29
+ frontengine/ui/chat/speech_to_text.py,sha256=PzNDtYw6Ju5JqBeRIKICHVtlYq2hwpUTTF8jvHTjOPw,2548
30
30
  frontengine/ui/color/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  frontengine/ui/color/global_color.py,sha256=Rh-R-X2BHVjcK5MTBZ1nEMVHgLj1rP4nk-wTQKbiwFA,125
32
32
  frontengine/ui/dialog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -99,8 +99,8 @@ frontengine/utils/multi_language/language_wrapper.py,sha256=KBqsG6ng5LSJkGqmu_YD
99
99
  frontengine/utils/multi_language/traditional_chinese.py,sha256=Oeabbu7iFNz5WNt_2P0-qc9DtYP3Ccska6MrclOSMYI,4982
100
100
  frontengine/utils/redirect_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
101
101
  frontengine/utils/redirect_manager/redirect_manager_class.py,sha256=zGJeVpjRU12MCnhVAdksAIhK_IhddI4cNKVb7DMgOZA,1888
102
- frontengine-0.0.27.dist-info/LICENSE,sha256=b3VlPBXnrDylKGffOEOLWMgOX-yfd65XC7PA1_sox2o,1085
103
- frontengine-0.0.27.dist-info/METADATA,sha256=3grKveM-28r1r1cZYUaypJvHEeJ13J9xv5-OisLRyB8,2949
104
- frontengine-0.0.27.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
105
- frontengine-0.0.27.dist-info/top_level.txt,sha256=btCybScN_ubeQ8phsSDBB0T-HyHjqt7b-WPy61uTox0,12
106
- frontengine-0.0.27.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,,