-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAI_Vtuber_GUI.py
3397 lines (2469 loc) · 125 KB
/
AI_Vtuber_GUI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import os
import threading
import multiprocessing
import queue
import time
import configparser
from PySide6 import QtWidgets, QtCore, QtGui
import GUI_control_panel.GUI_py.AI_Vtuber_control_panel_ui_pysd6 as gui
import AI_Vtuber_UI as aivtui
import VTubeStudioPlugin.VTubeStudioPlugin as vtsp
import OBS_websocket.OBS_websocket as obsws
import OpenAI.whisper.OpenAI_Whisper as whisper
import OpenAI.whisper.OpenAI_Whisper_API as whisper_api
import OpenAI.gpt.OpenAI_GPT_API as gpt
import TextToSpeech.edgeTTS as edgetts
import TextToSpeech.OpenAITTS as openaitts
import Google.gemini.GoogleAI_Gemini_API as gemini
import Sentiment_Analysis.NLP_API as sa_nlp
import Live_Chat.Live_Chat as live_chat
import Play_Audio as plau
import Mic_Record as mcrc
from My_Tools.AIVT_print import aprint
GUI_config = configparser.ConfigParser()
GUI_config_path = "GUI_control_panel/GUI_config.ini"
class AI_Vtuber_GUI(gui.Ui_MainWindow, QtWidgets.QMainWindow, QtWidgets.QPushButton): #, QtWidgets.QAction
# Initialize GUI
def __init__(self):
super().__init__()
# Set up GUI
self.setupUi(self)
global GUI_config, GUI_config_path
# Make the icon show correctly
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("GUI_control_panel\GUI_icon\AI_Vtuber_GUI_control_panel_01.ico"))
self.setWindowIcon(icon)
self.MW_Tab.setCurrentIndex(0)
### Make the icon show correctly
# load gui config
GUI_config.read(GUI_config_path, encoding="utf-8")
### load gui config
# Show chat role
enble = GUI_config["Main"]["show_chat_role"] == "True"
self.CH_cB_Show_chat_role.setChecked(enble)
GUI_config["Main"]["show_chat_role"] = str(enble)
### Show chat role
# User name
self.St_LE_User_Name.setText(str(GUI_config["Setting"]["user_name"]))
aivtui.GUI_User_Name = str(GUI_config["Setting"]["user_name"])
### User name
# character
aivtui.Load_AIVT_Character()
for name in aivtui.AIVT_Character_Names:
self.St_CB_Character_select.addItem(name)
GUI_Setting_Character = str(GUI_config["Setting"]["character"])
if GUI_Setting_Character in aivtui.AIVT_Character_Names:
self.St_CB_Character_select.setCurrentText(GUI_Setting_Character)
else:
GUI_Setting_Character = self.St_CB_Character_select.currentText()
GUI_config["Setting"]["character"] = GUI_Setting_Character
aivtui.AIVT_Using_character = GUI_Setting_Character
### character
# tab position
tabp = GUI_config["Setting"]["tab_position"]
self.St_CB_Tab_position.setCurrentText(tabp)
tab_position_map = {
"North": QtWidgets.QTabWidget.North,
"South": QtWidgets.QTabWidget.South,
"West": QtWidgets.QTabWidget.West,
"East": QtWidgets.QTabWidget.East
}
self.MW_Tab.setTabPosition(tab_position_map[tabp])
### tab position
# ai voice output device name
Available_output_device_list = plau.Get_available_output_devices_List()
for name in Available_output_device_list:
self.St_CB_AI_Voice_output_devices.addItem(name)
AI_Voice_output_devices_name = str(GUI_config["Setting"]["ai_voice_output_device_name"])
if AI_Voice_output_devices_name in Available_output_device_list:
self.St_CB_AI_Voice_output_devices.setCurrentText(AI_Voice_output_devices_name)
else:
AI_Voice_output_devices_name = self.St_CB_AI_Voice_output_devices.currentText()
GUI_config["Setting"]["ai_voice_output_device_name"] = AI_Voice_output_devices_name
plau.play_audio_parameters["ai_voice_output_device_name"] = AI_Voice_output_devices_name
### ai voice output device name
# user mic input device name
Available_input_device_list = mcrc.Get_available_input_devices_List()
for name in Available_input_device_list:
self.St_CB_User_Mic_iutput_devices.addItem(name)
User_Mic_input_devices_name = str(GUI_config["Setting"]["user_mic_input_device_name"])
if User_Mic_input_devices_name in Available_input_device_list:
self.St_CB_User_Mic_iutput_devices.setCurrentText(User_Mic_input_devices_name)
else:
User_Mic_input_devices_name = self.St_CB_User_Mic_iutput_devices.currentText()
GUI_config["Setting"]["user_mic_input_device_name"] = User_Mic_input_devices_name
mcrc.User_Mic_parameters["input_device_name"] = User_Mic_input_devices_name
### user mic input device name
# read user chat
enble = str(GUI_config["Setting"]["read_user_chat"]) == "True"
aivtui.GUI_Setting_read_chat_now = enble
self.St_cB_Read_user_chat.setChecked(enble)
### read user chat
# user mic hotkey 1 using
enble = str(GUI_config["Setting"]["user_mic_hotkey_1_using"]) == "True"
mcrc.user_mic_status["mic_hotkey_1_using"] = enble
self.St_cB_User_mic_hotkey1.setChecked(enble)
mcrc.user_mic_status["mic_hotkeys_using"] = enble
### user mic hotkey 1 using
# user mic hotkey 1
hotkey = str(GUI_config["Setting"]["user_mic_hotkey_1"])
mcrc.user_mic_status["mic_hotkey_1"] = hotkey
self.St_cB_User_mic_hotkey1.setText(f"Mic Hotkey 1 : {hotkey}")
### user mic hotkey 1
# user mic hotkey 2 using
enble = str(GUI_config["Setting"]["user_mic_hotkey_2_using"]) == "True"
mcrc.user_mic_status["mic_hotkey_2_using"] = enble
self.St_cB_User_mic_hotkey2.setChecked(enble)
if not mcrc.user_mic_status["mic_hotkey_1_using"]:
mcrc.user_mic_status["mic_hotkeys_using"] = enble
### user mic hotkey 2 using
# user mic hotkey 2
hotkey = str(GUI_config["Setting"]["user_mic_hotkey_2"])
mcrc.user_mic_status["mic_hotkey_2"] = hotkey
self.St_cB_User_mic_hotkey2.setText(f"Mic Hotkey 2 : {hotkey}")
### user mic hotkey 2
# doing now
wdn = str(GUI_config["Setting"]["doing_now"])
aivtui.GUI_LLM_parameters["wdn_prompt"] = wdn
self.St_TE_Doing_now.setPlainText(wdn)
### doing now
# YouTube channel name
p = "yt"
name = str(GUI_config["Live_Chat"][f"{p}_channel_name"]).strip()
self.LC_LE_yt_channel_name.setText(name)
live_chat.Live_chat_parameters[f"{p}_channel_name"] = name
GUI_config["Live_Chat"][f"{p}_channel_name"] = name
### YouTube channel name
# YouTube live id
p = "yt"
live_id = str(GUI_config["Live_Chat"][f"{p}_live_id"]).strip()
self.LC_LE_yt_live_id.setText(live_id)
live_chat.Live_chat_parameters[f"{p}_live_id"] = live_id
GUI_config["Live_Chat"][f"{p}_live_id"] = live_id
### YouTube live id
# YouTube response chatroom
p = "yt"
enble = GUI_config["Live_Chat"][f"{p}_response_chatroom"] == "True"
self.LC_cB_yt_chatroom.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_chatroom"] = enble
GUI_config["Live_Chat"][f"{p}_response_chatroom"] = str(enble)
### YouTube response chatroom
# YouTube live chat read chat now
p = "yt"
enble = GUI_config["Live_Chat"][f"{p}_live_chat_read_chat_now"] == "True"
self.LC_cB_yt_read_chat_now.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_live_chat_read_chat_now"] = enble
GUI_config["Live_Chat"][f"{p}_live_chat_read_chat_now"] = str(enble)
### YouTube live chat read chat now
# YouTube response owner
p = "yt"
enble = GUI_config["Live_Chat"][f"{p}_response_owner"] == "True"
self.LC_cB_yt_owner.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_owner"] = enble
GUI_config["Live_Chat"][f"{p}_response_owner"] = str(enble)
### YouTube response owner
# YouTube response vip
p = "yt"
enble = GUI_config["Live_Chat"][f"{p}_response_vip"] == "True"
self.LC_cB_yt_vip.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_vip"] = enble
GUI_config["Live_Chat"][f"{p}_response_vip"] = str(enble)
### YouTube response vip
# YouTube response individual
p = "yt"
enble = GUI_config["Live_Chat"][f"{p}_response_individual"] == "True"
self.LC_cB_yt_response_individual.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_individual"] = enble
GUI_config["Live_Chat"][f"{p}_response_individual"] = str(enble)
### YouTube response individual
# YouTube wait list max
p = "yt"
num = int(GUI_config["Live_Chat"][f"{p}_wait_list_max"])
self.LC_SB_yt_chat_max_wait_list.setValue(num)
live_chat.Live_chat_parameters[f"{p}_wait_list_max"] = num
GUI_config["Live_Chat"][f"{p}_wait_list_max"] = str(num)
### YouTube wait list max
# YouTube chat max tokens
p = "yt"
num = int(GUI_config["Live_Chat"][f"{p}_chat_max_tokens"])
self.LC_SB_yt_chat_max_tokens.setValue(num)
live_chat.Live_chat_parameters[f"{p}_chat_max_tokens"] = num
GUI_config["Live_Chat"][f"{p}_chat_max_tokens"] = str(num)
### YouTube chat max tokens
# YouTube chat max response
p = "yt"
num = int(GUI_config["Live_Chat"][f"{p}_chat_max_response"])
self.LC_SB_yt_chat_max_response.setValue(num)
live_chat.Live_chat_parameters[f"{p}_chat_max_response"] = num
GUI_config["Live_Chat"][f"{p}_chat_max_response"] = str(num)
### YouTube chat max response
# YouTube live chat vip names
p = "yt"
text = str(GUI_config["Live_Chat"][f"{p}_live_chat_vip_names"])
self.LC_TE_yt_vip_names.setPlainText(text)
live_chat.Live_chat_parameters[f"{p}_live_chat_vip_names"] = [name.strip() for name in text.split("/") if name.strip()]
### YouTube live chat vip names
# YouTube yt live chat ban names
p = "yt"
text = str(GUI_config["Live_Chat"][f"{p}_live_chat_ban_names"])
self.LC_TE_yt_ban_names.setPlainText(text)
live_chat.Live_chat_parameters[f"{p}_live_chat_ban_names"] = [name.strip() for name in text.split("/") if name.strip()]
### YouTube live chat ban names
# Twitch channel name
p = "tw"
name = str(GUI_config["Live_Chat"][f"{p}_channel_name"]).strip()
self.LC_LE_tw_channel_name.setText(name)
live_chat.Live_chat_parameters[f"{p}_channel_name"] = name
GUI_config["Live_Chat"][f"{p}_channel_name"] = name
### Twitch channel name
# Twitch response chatroom
p = "tw"
enble = GUI_config["Live_Chat"][f"{p}_response_chatroom"] == "True"
self.LC_cB_tw_chatroom.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_chatroom"] = enble
GUI_config["Live_Chat"][f"{p}_response_chatroom"] = str(enble)
### Twitch response chatroom
# Twitch live chat read chat now
p = "tw"
enble = GUI_config["Live_Chat"][f"{p}_live_chat_read_chat_now"] == "True"
self.LC_cB_tw_read_chat_now.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_live_chat_read_chat_now"] = enble
GUI_config["Live_Chat"][f"{p}_live_chat_read_chat_now"] = str(enble)
### Twitch live chat read chat now
# Twitch response owner
p = "tw"
enble = GUI_config["Live_Chat"][f"{p}_response_owner"] == "True"
self.LC_cB_tw_owner.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_owner"] = enble
GUI_config["Live_Chat"][f"{p}_response_owner"] = str(enble)
### Twitch response owner
# Twitch response vip
p = "tw"
enble = GUI_config["Live_Chat"][f"{p}_response_vip"] == "True"
self.LC_cB_tw_vip.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_vip"] = enble
GUI_config["Live_Chat"][f"{p}_response_vip"] = str(enble)
### Twitch response vip
# Twitch response individual
p = "tw"
enble = GUI_config["Live_Chat"][f"{p}_response_individual"] == "True"
self.LC_cB_tw_response_individual.setChecked(enble)
live_chat.Live_chat_parameters[f"{p}_response_individual"] = enble
GUI_config["Live_Chat"][f"{p}_response_individual"] = str(enble)
### Twitch response individual
# Twitch wait list max
p = "tw"
num = int(GUI_config["Live_Chat"][f"{p}_wait_list_max"])
self.LC_SB_tw_chat_max_wait_list.setValue(num)
live_chat.Live_chat_parameters[f"{p}_wait_list_max"] = num
GUI_config["Live_Chat"][f"{p}_wait_list_max"] = str(num)
### Twitch wait list max
# Twitch chat max tokens
p = "tw"
num = int(GUI_config["Live_Chat"][f"{p}_chat_max_tokens"])
self.LC_SB_tw_chat_max_tokens.setValue(num)
live_chat.Live_chat_parameters[f"{p}_chat_max_tokens"] = num
GUI_config["Live_Chat"][f"{p}_chat_max_tokens"] = str(num)
### Twitch chat max tokens
# Twitch chat max response
p = "tw"
num = int(GUI_config["Live_Chat"][f"{p}_chat_max_response"])
self.LC_SB_tw_chat_max_response.setValue(num)
live_chat.Live_chat_parameters[f"{p}_chat_max_response"] = num
GUI_config["Live_Chat"][f"{p}_chat_max_response"] = str(num)
### Twitch chat max response
# Twitch live chat vip names
p = "tw"
text = str(GUI_config["Live_Chat"][f"{p}_live_chat_vip_names"])
self.LC_TE_tw_vip_names.setPlainText(text)
live_chat.Live_chat_parameters[f"{p}_live_chat_vip_names"] = [name.strip() for name in text.split("/") if name.strip()]
### Twitch live chat vip names
# Twitch yt live chat ban names
p = "tw"
text = str(GUI_config["Live_Chat"][f"{p}_live_chat_ban_names"])
self.LC_TE_tw_ban_names.setPlainText(text)
live_chat.Live_chat_parameters[f"{p}_live_chat_ban_names"] = [name.strip() for name in text.split("/") if name.strip()]
### Twitch live chat ban names
# LLM using
llm_using = GUI_config["LLM"]["using"]
if llm_using == "Gemini":
self.LLM_RB_Gemini.setChecked(True)
elif llm_using == "GPT":
self.LLM_RB_GPT.setChecked(True)
else:
llm_using = "Gemini"
GUI_config["LLM"]["using"] = llm_using
self.LLM_RB_Gemini.setChecked(True)
aivtui.GUI_LLM_parameters["model"] = llm_using
### LLM using
# LLM Instruction enhance
instruction_enhance = GUI_config["LLM"]["instruction_enhance"] == "True"
aivtui.GUI_LLM_parameters["instruction_enhance"] = instruction_enhance
self.LLM_cB_Instruction_enhance.setChecked(instruction_enhance)
prompt = aivtui.get_instruction_enhance_prompt(aivtui.AIVT_Using_character)
self.LLM_TE_Instruction_enhance.setPlainText(prompt)
aivtui.GUI_LLM_parameters["instruction_enhance_prompt"] = prompt
### LLM Instruction enhance
# LLM Instruction enhance i
instruction_enhance_i = int(GUI_config["LLM"]["instruction_enhance_i"])
aivtui.GUI_LLM_parameters["instruction_enhance_i"] = instruction_enhance_i
self.LLM_SB_Instruction_enhance.setValue(instruction_enhance_i)
### LLM Instruction enhance i
# LLM Gemini model
gemini_model_names_list = [name for name in gemini.gemini_models_max_input_tokens.keys()]
for name in gemini_model_names_list:
self.LLM_CB_Ge_Model.addItem(name)
gemini_model = str(GUI_config["LLM_Gemini"]["model"])
if gemini_model in gemini_model_names_list:
self.LLM_CB_Ge_Model.setCurrentText(gemini_model)
else:
gemini_model = self.LLM_CB_Ge_Model.currentText()
GUI_config["LLM_Gemini"]["model"] = gemini_model
gemini.gemini_parameters["model"] = gemini_model
### LLM Gemini model
# LLM Gemini max input tokens
gemini_max_input_tokens = int(GUI_config["LLM_Gemini"]["max_input_tokens"])
gemini_models_max_input_tokens = gemini.gemini_models_max_input_tokens[gemini.gemini_parameters["model"]]
self.LLM_SB_Ge_Max_input_tokens.setMaximum(gemini_models_max_input_tokens)
if gemini_max_input_tokens < 1024:
gemini_max_input_tokens = 1024
elif gemini_max_input_tokens > gemini_models_max_input_tokens:
gemini_max_input_tokens = gemini_models_max_input_tokens
GUI_config["LLM_Gemini"]["max_input_tokens"] = str(gemini_max_input_tokens)
self.LLM_SB_Ge_Max_input_tokens.setValue(gemini_max_input_tokens)
gemini.gemini_parameters["max_input_tokens"] = gemini_max_input_tokens
### LLM Gemini max input tokens
# LLM Gemini max output tokens
gemini_max_output_tokens = int(GUI_config["LLM_Gemini"]["max_output_tokens"])
gemini_models_max_output_tokens = gemini.gemini_models_max_output_tokens[gemini.gemini_parameters["model"]]
self.LLM_SB_Ge_Max_output_tokens.setMaximum(gemini_models_max_output_tokens)
if gemini_max_output_tokens < 128:
gemini_max_output_tokens = 128
elif gemini_max_output_tokens > gemini_models_max_output_tokens:
gemini_max_output_tokens = gemini_models_max_output_tokens
GUI_config["LLM_Gemini"]["max_output_tokens"] = str(gemini_max_output_tokens)
self.LLM_SB_Ge_Max_output_tokens.setValue(gemini_max_output_tokens)
gemini.gemini_parameters["max_output_tokens"] = gemini_max_output_tokens
### LLM Gemini max output tokens
# LLM Gemini temperature
gemini_temperature = round(float(GUI_config["LLM_Gemini"]["temperature"]), 2)
if gemini_temperature < 0:
gemini_temperature = 0.00
elif gemini_temperature > 1:
gemini_temperature = 1.00
GUI_config["LLM_Gemini"]["temperature"] = str(gemini_temperature)
self.LLM_DSB_Ge_Temperature.setValue(gemini_temperature)
gemini.gemini_parameters["temperature"] = gemini_temperature
### LLM Gemini temperature
# LLM Gemini timeout
gemini_timeout = int(GUI_config["LLM_Gemini"]["timeout"])
if gemini_timeout < 5:
gemini_timeout = 5
elif gemini_timeout > 60:
gemini_timeout = 60
GUI_config["LLM_Gemini"]["timeout"] = str(gemini_timeout)
self.LLM_SB_Ge_Timeout.setValue(gemini_timeout)
gemini.gemini_parameters["timeout"] = gemini_timeout
### LLM Gemini timeout
# LLM Gemini retry
gemini_retry = int(GUI_config["LLM_Gemini"]["retry"])
if gemini_retry < 1:
gemini_retry = 1
elif gemini_retry > 10:
gemini_retry = 10
GUI_config["LLM_Gemini"]["retry"] = str(gemini_retry)
self.LLM_SB_Ge_Retry.setValue(gemini_retry)
gemini.gemini_parameters["retry"] = gemini_retry
### LLM Gemini retry
# LLM GPT model
gpt_model_names_list = [name for name in gpt.gpt_models_max_input_tokens.keys()]
for name in gpt_model_names_list:
self.LLM_CB_GPT_Model.addItem(name)
gpt_model = str(GUI_config["LLM_GPT"]["model"])
if gpt_model in gpt_model_names_list:
self.LLM_CB_GPT_Model.setCurrentText(gpt_model)
else:
gpt_model = self.LLM_CB_GPT_Model.currentText()
GUI_config["LLM_GPT"]["model"] = gpt_model
gpt.gpt_parameters["model"] = gpt_model
### LLM GPT model
# LLM GPT max input tokens
gpt_max_input_tokens = int(GUI_config["LLM_GPT"]["max_input_tokens"])
gpt_models_max_input_tokens = gpt.gpt_models_max_input_tokens[gpt.gpt_parameters["model"]]
self.LLM_SB_GPT_Max_input_tokens.setMaximum(gpt_models_max_input_tokens)
if gpt_max_input_tokens < 1024:
gpt_max_input_tokens = 1024
elif gpt_max_input_tokens > gpt_models_max_input_tokens:
gpt_max_input_tokens = gpt_models_max_input_tokens
GUI_config["LLM_GPT"]["max_input_tokens"] = str(gpt_max_input_tokens)
self.LLM_SB_GPT_Max_input_tokens.setValue(gpt_max_input_tokens)
gpt.gpt_parameters["max_input_tokens"] = gpt_max_input_tokens
### LLM GPT max input tokens
# LLM GPT max output tokens
gpt_max_output_tokens = int(GUI_config["LLM_GPT"]["max_output_tokens"])
gpt_models_max_output_tokens = gpt.gpt_models_max_output_tokens[gpt.gpt_parameters["model"]]
self.LLM_SB_GPT_Max_output_tokens.setMaximum(gpt_models_max_output_tokens)
if gpt_max_output_tokens < 128:
gpt_max_output_tokens = 128
elif gpt_max_output_tokens > gpt_models_max_output_tokens:
gpt_max_output_tokens = gpt_models_max_output_tokens
GUI_config["LLM_GPT"]["max_output_tokens"] = str(gpt_max_output_tokens)
self.LLM_SB_GPT_Max_output_tokens.setValue(gpt_max_output_tokens)
gpt.gpt_parameters["max_output_tokens"] = gpt_max_output_tokens
### LLM GPT max output tokens
# LLM GPT temperature
gpt_temperature = round(float(GUI_config["LLM_GPT"]["temperature"]), 2)
if gpt_temperature < 0:
gpt_temperature = 0.00
elif gpt_temperature > 2:
gpt_temperature = 2.00
GUI_config["LLM_GPT"]["temperature"] = str(gpt_temperature)
self.LLM_DSB_GPT_Temperature.setValue(gpt_temperature)
gpt.gpt_parameters["temperature"] = gpt_temperature
### LLM GPT temperature
# LLM GPT timeout
gpt_timeout = int(GUI_config["LLM_GPT"]["timeout"])
if gpt_timeout < 5:
gpt_timeout = 5
elif gpt_timeout > 60:
gpt_timeout = 60
GUI_config["LLM_GPT"]["timeout"] = str(gpt_timeout)
self.LLM_SB_GPT_Timeout.setValue(gpt_timeout)
gpt.gpt_parameters["timeout"] = gpt_timeout
### LLM GPT timeout
# LLM GPT retry
gpt_retry = int(GUI_config["LLM_GPT"]["retry"])
if gpt_retry < 1:
gpt_retry = 1
elif gpt_retry > 10:
gpt_retry = 10
GUI_config["LLM_GPT"]["retry"] = str(gpt_retry)
self.LLM_SB_GPT_Retry.setValue(gpt_retry)
gpt.gpt_parameters["retry"] = gpt_retry
### LLM GPT retry
# TextToSpeech using
TextToSpeech_using = GUI_config["TextToSpeech"]["using"]
if TextToSpeech_using == "EdgeTTS":
self.TTS_RB_EdgeTTS.setChecked(True)
elif TextToSpeech_using == "OpenAITTS":
self.TTS_RB_OpenAITTS.setChecked(True)
else:
self.TTS_RB_EdgeTTS.setChecked(True)
TextToSpeech_using = "EdgeTTS"
GUI_config["TextToSpeech"]["using"] = TextToSpeech_using
aivtui.GUI_TTS_Using = TextToSpeech_using
### TextToSpeech using
# EdgeTTS voice
edgetts.EdgeTTS_Voice_dict = edgetts.create_voices_dict("TextToSpeech/edgeTTS_speakers.txt")
voice_list = edgetts.filter_voices_by_gender(edgetts.EdgeTTS_Voice_dict, "All")
for name in voice_list:
self.TTS_CB_ET_Voice.addItem(name)
voice = GUI_config["EdgeTTS"]["voice"]
if voice in voice_list:
self.TTS_CB_ET_Voice.setCurrentText(voice)
else:
voice = self.TTS_CB_ET_Voice.currentText()
GUI_config["EdgeTTS"]["voice"] = voice
edgetts.edgetts_parameters["voice"] = voice
### EdgeTTS voice
# EdgeTTS pitch
EdgeTTS_pitch = int(GUI_config["EdgeTTS"]["pitch"])
if EdgeTTS_pitch < -100:
EdgeTTS_pitch = -100
elif EdgeTTS_pitch > 100:
EdgeTTS_pitch = 100
GUI_config["EdgeTTS"]["pitch"] = str(EdgeTTS_pitch)
self.TTS_SB_ET_Pitch.setValue(EdgeTTS_pitch)
if EdgeTTS_pitch >= 0:
EdgeTTS_pitch = f"+{EdgeTTS_pitch}Hz"
else:
EdgeTTS_pitch = f"{EdgeTTS_pitch}Hz"
edgetts.edgetts_parameters["pitch"] = EdgeTTS_pitch
### EdgeTTS pitch
# EdgeTTS rate
EdgeTTS_rate = int(GUI_config["EdgeTTS"]["rate"])
if EdgeTTS_rate < -100:
EdgeTTS_rate = -100
elif EdgeTTS_rate > 100:
EdgeTTS_rate = 100
GUI_config["EdgeTTS"]["rate"] = str(EdgeTTS_rate)
self.TTS_SB_ET_Rate.setValue(EdgeTTS_rate)
if EdgeTTS_rate >= 0:
EdgeTTS_rate = f"+{EdgeTTS_rate}%"
else:
EdgeTTS_rate = f"{EdgeTTS_rate}%"
edgetts.edgetts_parameters["rate"] = EdgeTTS_rate
### EdgeTTS rate
# EdgeTTS volume
EdgeTTS_volume = int(GUI_config["EdgeTTS"]["volume"])
if EdgeTTS_volume < -100:
EdgeTTS_volume = -100
elif EdgeTTS_volume > 100:
EdgeTTS_volume = 100
GUI_config["EdgeTTS"]["volume"] = str(EdgeTTS_volume)
self.TTS_SB_ET_Volume.setValue(EdgeTTS_volume)
if EdgeTTS_volume >= 0:
EdgeTTS_volume = f"+{EdgeTTS_volume}%"
else:
EdgeTTS_volume = f"{EdgeTTS_volume}%"
edgetts.edgetts_parameters["volume"] = EdgeTTS_volume
### EdgeTTS volume
# EdgeTTS timeout
EdgeTTS_timeout = int(GUI_config["EdgeTTS"]["timeout"])
if EdgeTTS_timeout < 5:
EdgeTTS_timeout = 5
elif EdgeTTS_timeout > 60:
EdgeTTS_timeout = 60
GUI_config["EdgeTTS"]["timeout"] = str(EdgeTTS_timeout)
self.TTS_SB_ET_Timeout.setValue(EdgeTTS_timeout)
edgetts.edgetts_parameters["timeout"] = EdgeTTS_timeout
### EdgeTTS timeout
# OpenAITTS voice
voice_list = openaitts.OpenAITTS_Voice_list
for name in voice_list:
self.TTS_CB_OT_Voice.addItem(name)
voice = GUI_config["OpenAITTS"]["voice"]
if voice in voice_list:
self.TTS_CB_OT_Voice.setCurrentText(voice)
else:
voice = self.TTS_CB_OT_Voice.currentText()
GUI_config["OpenAITTS"]["voice"] = voice
openaitts.openaitts_parameters["voice"] = voice
### OpenAITTS voice
# OpenAITTS model
model_list = openaitts.OpenAITTS_Model_list
for name in model_list:
self.TTS_CB_OT_Model.addItem(name)
model = GUI_config["OpenAITTS"]["model"]
if model in model_list:
self.TTS_CB_OT_Model.setCurrentText(model)
else:
model = self.TTS_CB_OT_Model.currentText()
GUI_config["OpenAITTS"]["model"] = model
openaitts.openaitts_parameters["model"] = model
### OpenAITTS model
# OpenAITTS speed
OpenAITTS_speed = round(float(GUI_config["OpenAITTS"]["speed"]), 2)
if OpenAITTS_speed < 0.25:
OpenAITTS_speed = 0.25
elif OpenAITTS_speed > 4.00:
OpenAITTS_speed = 4.00
GUI_config["OpenAITTS"]["speed"] = str(OpenAITTS_speed)
self.TTS_DSB_OT_Speed.setValue(OpenAITTS_speed)
openaitts.openaitts_parameters["speed"] = OpenAITTS_speed
### OpenAITTS speed
# OpenAITTS timeout
OpenAITTS_timeout = int(GUI_config["OpenAITTS"]["timeout"])
if OpenAITTS_timeout < 5:
OpenAITTS_timeout = 5
elif OpenAITTS_timeout > 60:
OpenAITTS_timeout = 60
GUI_config["OpenAITTS"]["timeout"] = str(OpenAITTS_timeout)
self.TTS_SB_OT_Timeout.setValue(OpenAITTS_timeout)
openaitts.openaitts_parameters["timeout"] = round(float(OpenAITTS_timeout), 1)
### OpenAITTS timeout
# whisper inference
aivtui.OpenAI_Whisper_Inference = str(GUI_config["Whisper"]["inference"])
self.Wh_CB_Inference.setCurrentText(aivtui.OpenAI_Whisper_Inference)
# whisper inference
# whisper model name list
Available_model_names_list = whisper.get_available_model_names_list()
for name in Available_model_names_list:
self.Wh_CB_Whisper_model_name.addItem(name)
gui_selected_model = str(GUI_config["Whisper"]["model_name"])
if gui_selected_model in Available_model_names_list:
self.Wh_CB_Whisper_model_name.setCurrentText(gui_selected_model)
else:
gui_selected_model = self.Wh_CB_Whisper_model_name.currentText()
GUI_config["Whisper"]["model_name"] = gui_selected_model
whisper.whisper_status["gui_selected_model"] = gui_selected_model
### whisper model name list
# whisper language
language_names = [name for name in whisper.Whisper_LANGUAGES.keys()]
for name in language_names:
self.Wh_CB_Language.addItem(name)
whisper_lang = str(GUI_config["Whisper"]["language"])
if whisper_lang in language_names:
self.Wh_CB_Language.setCurrentText(whisper_lang)
else:
whisper_lang = self.Wh_CB_Language.currentText()
GUI_config["Whisper"]["language"] = whisper_lang
whisper.whisper_parameters["user_mic_language"] = whisper_lang
whisper_api.whisper_parameters["user_mic_language"] = whisper_lang
### whisper language
# whisper max tokens
tokens = int(GUI_config["Whisper"]["max_tokens"])
if tokens < 0:
tokens = 0
elif tokens > 9999:
tokens = 9999
GUI_config["Whisper"]["max_tokens"] = str(tokens)
self.Wh_SB_Max_tokens.setValue(tokens)
whisper.whisper_parameters["max_tokens"] = tokens
### whisper max tokens
# whisper temperature
whisper_temp = float(GUI_config["Whisper"]["temperature"])
if whisper_temp < 0:
whisper_temp = 0.0
elif whisper_temp > 1:
whisper_temp = 1.0
GUI_config["Whisper"]["temperature"] = str(whisper_temp)
self.Wh_DSB_Temperature.setValue(whisper_temp)
whisper.whisper_parameters["temperature"] = whisper_temp
whisper_api.whisper_parameters["temperature"] = whisper_temp
### whisper temperature
# whisper timeout
whisper_timeout = int(GUI_config["Whisper"]["timeout"])
if whisper_timeout < 5:
whisper_timeout = 5
elif whisper_timeout > 60:
whisper_timeout = 60
GUI_config["Whisper"]["timeout"] = str(whisper_timeout)
self.Wh_SB_Timeout.setValue(whisper_timeout)
whisper.whisper_parameters["timeout"] = whisper_timeout
whisper_api.whisper_parameters["timeout"] = whisper_timeout
### whisper timeout
# whisper prompt
whisper_prompt = str(GUI_config["Whisper"]["prompt"])
self.Wh_TE_Prompt.setPlainText(whisper_prompt)
whisper.whisper_parameters["prompt"] = whisper_prompt
whisper_api.whisper_parameters["prompt"] = whisper_prompt
### whisper prompt
# OBS Subtitles formatter
subtitles_formatter = GUI_config["OBS_Subtitles"]["subtitles_formatter"] == "True"
obsws.OBS_subtitles_parameters["subtitles_formatter"] = subtitles_formatter
self.OBS_cB_Subtitles_formatter.setChecked(subtitles_formatter)
### OBS Subtitles formatter
# OBS Subtitles formatter version
sub_ver_list = obsws.OBS_subtitles_formatter_versions
for name in sub_ver_list:
self.OBS_CB_Subtitles_formatter_version.addItem(name)
sub_ver = str(GUI_config["OBS_Subtitles"]["subtitles_formatter_version"])
if sub_ver in sub_ver_list:
self.OBS_CB_Subtitles_formatter_version.setCurrentText(sub_ver)
else:
sub_ver = self.OBS_CB_Subtitles_formatter_version.currentText()
GUI_config["OBS_Subtitles"]["subtitles_formatter_version"] = sub_ver
obsws.OBS_subtitles_parameters["subtitles_formatter_version"] = sub_ver
### OBS Subtitles formatter version
# OBS Chat now sub
show_sub = GUI_config["OBS_Chat_now_sub"]["show"] == "True"
obsws.OBS_chat_now_sub_parameters["show"] = show_sub
self.OBS_cB_Chat_now.setChecked(show_sub)
### OBS Chat now sub
# OBS Chat now sub clear
clear_sub = GUI_config["OBS_Chat_now_sub"]["clear"] == "True"
obsws.OBS_chat_now_sub_parameters["clear"] = clear_sub
self.OBS_cB_cn_Clear.setChecked(clear_sub)
### OBS Chat now sub clear
# OBS Chat now sub name
sub_name = GUI_config["OBS_Chat_now_sub"]["sub_name"].strip()
obsws.OBS_chat_now_sub_parameters["sub_name"] = sub_name
self.OBS_LE_cn_Sub_name.setText(sub_name)
GUI_config["OBS_Chat_now_sub"]["sub_name"] = sub_name
### OBS Chat now sub name
# OBS Chat now sub time
sub_time = round(float(GUI_config["OBS_Chat_now_sub"]["sub_time"]), 1)
if sub_time < 0:
sub_time = 0.0
elif sub_time > 60:
sub_time = 60.0
GUI_config["OBS_Chat_now_sub"]["sub_time"] = str(sub_time)
self.OBS_DSB_cn_Sub_time.setValue(sub_time)
obsws.OBS_chat_now_sub_parameters["sub_time"] = sub_time
### OBS Chat now sub time
# OBS Chat now sub max length
sub_max_length = int(GUI_config["OBS_Chat_now_sub"]["sub_max_length"])
if sub_max_length < 1:
sub_max_length = 1
elif sub_max_length > 999:
sub_max_length = 999
GUI_config["OBS_Chat_now_sub"]["sub_max_length"] = str(sub_max_length)
self.OBS_SB_cn_Max_length.setValue(sub_max_length)
obsws.OBS_chat_now_sub_parameters["sub_max_length"] = sub_max_length
### OBS Chat now sub max length
# OBS Chat now sub english char length
en_char_len = round(float(GUI_config["OBS_Chat_now_sub"]["sub_english_char_length"]), 2)
if en_char_len < 0.01:
en_char_len = 0.01
elif en_char_len > 1.00:
en_char_len = 1.00
GUI_config["OBS_Chat_now_sub"]["sub_english_char_length"] = str(en_char_len)
self.OBS_DSB_cn_English_char_length.setValue(en_char_len)
obsws.OBS_chat_now_sub_parameters["sub_english_char_length"] = en_char_len
### OBS Chat now sub english char length
# OBS Chat now sub base line count
sub_blc = int(GUI_config["OBS_Chat_now_sub"]["sub_base_line_count"])
if sub_blc < 1:
sub_blc = 1
elif sub_blc > 999:
sub_blc = 999
GUI_config["OBS_Chat_now_sub"]["sub_base_line_count"] = str(sub_blc)
self.OBS_SB_cn_Base_line_count.setValue(sub_blc)
obsws.OBS_chat_now_sub_parameters["sub_base_line_count"] = sub_blc
### OBS Chat now sub base line count
# OBS Chat now sub end delay
sub_end_delay = round(float(GUI_config["OBS_Chat_now_sub"]["sub_end_delay"]), 1)
if sub_end_delay < 0:
sub_end_delay = 0.0
elif sub_end_delay > 60:
sub_end_delay = 60.0
GUI_config["OBS_Chat_now_sub"]["sub_end_delay"] = str(sub_end_delay)
self.OBS_DSB_cn_End_delay.setValue(sub_end_delay)
obsws.OBS_chat_now_sub_parameters["sub_end_delay"] = sub_end_delay
### OBS Chat now sub end delay
# OBS Chat now show sub filter names
filter_names = [name for name in GUI_config["OBS_Chat_now_sub"]["show_sub_filter_names"].split('/') if name.strip() != '']
obsws.OBS_chat_now_sub_parameters["show_sub_filter_names"] = filter_names
text = GUI_config["OBS_Chat_now_sub"]["show_sub_filter_names"].strip()