1414from metrics_gpu import GPU_Monitor
1515from metrics_system import SystemMonitor
1616from initialize import determine_compute_device , is_nvidia_gpu , get_os_name
17-
18- styles = {
19- "button" : 'background-color: #323842; color: light gray; font: 10pt "Segoe UI Historic"; width: 29;' ,
20- "frame" : 'background-color: #161b22;' ,
21- "input" : 'background-color: #2e333b; color: light gray; font: 13pt "Segoe UI Historic";' ,
22- "text" : 'background-color: #092327; color: light gray; font: 12pt "Segoe UI Historic";'
23- }
17+ from voice_recorder_module import VoiceRecorder
18+ from gui_tabs import create_tabs
19+ from gui_threads import CreateDatabaseThread , SubmitButtonThread
2420
2521with open ('config.yaml' , 'r' ) as config_file :
2622 config = yaml .safe_load (config_file )
2723
2824tabs_config = config .get ('tabs' , [])
29-
30- class CreateDatabaseThread (QThread ):
31- def run (self ):
32- create_database .main ()
33-
34- class SubmitButtonThread (QThread ):
35- responseSignal = Signal (str )
36-
37- def __init__ (self , user_question , parent = None ):
38- super (SubmitButtonThread , self ).__init__ (parent )
39- self .user_question = user_question
40-
41- def run (self ):
42- response = server_connector .ask_local_chatgpt (self .user_question )
43- self .responseSignal .emit (response ['answer' ])
25+ styles = config .get ('styles' , {})
4426
4527class DocQA_GUI (QWidget ):
4628 def __init__ (self ):
@@ -64,20 +46,10 @@ def init_ui(self):
6446 self .setGeometry (300 , 300 , 850 , 910 )
6547 self .setMinimumSize (550 , 610 )
6648
67- self .left_frame = QFrame () # Changed here
49+ self .left_frame = QFrame ()
6850 left_vbox = QVBoxLayout ()
69- tab_widget = QTabWidget ()
70- tab_widget .setTabPosition (QTabWidget .South )
71-
72- tab_widgets = [QTextEdit (tab .get ('placeholder' , '' )) for tab in tabs_config ]
73- for i , tab in enumerate (tabs_config ):
74- tab_widget .addTab (tab_widgets [i ], tab .get ('name' , '' ))
75-
76- tutorial_tab = QWebEngineView ()
77- tab_widget .addTab (tutorial_tab , 'Tutorial' )
78- user_manual_folder = os .path .join (os .path .dirname (__file__ ), 'User_Manual' )
79- html_file_path = os .path .join (user_manual_folder , 'number_format.html' )
80- tutorial_tab .setUrl (QUrl .fromLocalFile (html_file_path ))
51+
52+ tab_widget = create_tabs (tabs_config )
8153 left_vbox .addWidget (tab_widget )
8254
8355 button_data = [
@@ -108,9 +80,21 @@ def init_ui(self):
10880 submit_button .setStyleSheet (styles .get ('button' , '' ))
10981 submit_button .clicked .connect (self .on_submit_button_clicked )
11082
111- right_vbox .addWidget (self .read_only_text , 5 )
83+ right_vbox .addWidget (self .read_only_text , 4 )
11284 right_vbox .addWidget (self .text_input , 1 )
11385 right_vbox .addWidget (submit_button )
86+
87+ self .recorder = VoiceRecorder ()
88+
89+ self .start_button = QPushButton ("Start Recording" )
90+ self .start_button .setStyleSheet (styles .get ('button' , '' ))
91+ self .start_button .clicked .connect (self .start_recording )
92+ right_vbox .addWidget (self .start_button )
93+
94+ self .stop_button = QPushButton ("Stop Recording" )
95+ self .stop_button .setStyleSheet (styles .get ('button' , '' ))
96+ self .stop_button .clicked .connect (self .stop_recording )
97+ right_vbox .addWidget (self .stop_button )
11498
11599 right_frame .setLayout (right_vbox )
116100 right_frame .setStyleSheet (styles .get ('frame' , '' ))
@@ -140,7 +124,6 @@ def resizeEvent(self, event):
140124 self .left_frame .setMaximumWidth (self .width () * 0.5 )
141125 super ().resizeEvent (event )
142126
143-
144127 def on_create_button_clicked (self ):
145128 self .create_database_thread = CreateDatabaseThread (self )
146129 self .create_database_thread .start ()
@@ -151,6 +134,12 @@ def on_submit_button_clicked(self):
151134 self .submit_button_thread .responseSignal .connect (self .update_response )
152135 self .submit_button_thread .start ()
153136
137+ def start_recording (self ):
138+ self .recorder .start_recording ()
139+
140+ def stop_recording (self ):
141+ self .recorder .stop_recording ()
142+
154143 def update_response (self , response ):
155144 self .read_only_text .setPlainText (response )
156145
0 commit comments