Merge remote-tracking branch 'origin/UI_2.0' into UI_2.0

This commit is contained in:
Sakamoto Shiina
2023-09-15 09:59:45 +09:00
3 changed files with 49 additions and 24 deletions

View File

@@ -12,11 +12,11 @@ from models.transcription.transcription_languages import transcription_lang
from models.transcription.transcription_utils import getInputDevices, getOutputDevices, getDefaultInputDevice, getDefaultOutputDevice
def saveJson(path, key, value):
with open(path, "r") as fp:
with open(path, "r", encoding="utf-8") as fp:
json_data = load(fp)
json_data[key] = value
with open(path, "w") as fp:
dump(json_data, fp, indent=4)
with open(path, "w", encoding="utf-8") as fp:
json_dump(json_data, fp, indent=4, ensure_ascii=False)
class Config:
_instance = None
@@ -543,13 +543,13 @@ class Config:
def load_config(self):
if os_path.isfile(self.PATH_CONFIG) is not False:
with open(self.PATH_CONFIG, 'r') as fp:
with open(self.PATH_CONFIG, 'r', encoding="utf-8") as fp:
config = json_load(fp)
for key in config.keys():
setattr(self, key, config[key])
with open(self.PATH_CONFIG, 'w') as fp:
with open(self.PATH_CONFIG, 'w', encoding="utf-8") as fp:
setter_methods = [
name for name, obj in vars(type(self)).items()
if isinstance(obj, property) and obj.fset is not None
@@ -557,6 +557,6 @@ class Config:
config = {}
for method in setter_methods:
config[method] = getattr(self, method)
json_dump(config, fp, indent=4)
json_dump(config, fp, indent=4, ensure_ascii=False)
config = Config()

59
main.py
View File

@@ -49,6 +49,18 @@ def stopTranscriptionSendMessage():
model.stopMicTranscript()
view.setMainWindowAllWidgetsStatusToNormal()
def startThreadingTranscriptionSendMessage():
view.printToTextbox_enableTranscriptionSend()
th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage)
th_startTranscriptionSendMessage.daemon = True
th_startTranscriptionSendMessage.start()
def stopThreadingTranscriptionSendMessage():
view.printToTextbox_disableTranscriptionSend()
th_stopTranscriptionSendMessage = Thread(target=stopTranscriptionSendMessage)
th_stopTranscriptionSendMessage.daemon = True
th_stopTranscriptionSendMessage.start()
# func transcription receive message
def receiveSpeakerMessage(message):
if len(message) > 0:
@@ -83,6 +95,18 @@ def stopTranscriptionReceiveMessage():
model.stopSpeakerTranscript()
view.setMainWindowAllWidgetsStatusToNormal()
def startThreadingTranscriptionReceiveMessage():
view.printToTextbox_enableTranscriptionReceive()
th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage)
th_startTranscriptionReceiveMessage.daemon = True
th_startTranscriptionReceiveMessage.start()
def stopThreadingTranscriptionReceiveMessage():
view.printToTextbox_disableTranscriptionReceive()
th_stopTranscriptionReceiveMessage = Thread(target=stopTranscriptionReceiveMessage)
th_stopTranscriptionReceiveMessage.daemon = True
th_stopTranscriptionReceiveMessage.start()
# func message box
def sendChatMessage(message):
if len(message) > 0:
@@ -184,29 +208,17 @@ def callbackToggleTranscriptionSend(is_turned_on):
view.setMainWindowAllWidgetsStatusToDisabled()
config.ENABLE_TRANSCRIPTION_SEND = is_turned_on
if config.ENABLE_TRANSCRIPTION_SEND is True:
view.printToTextbox_enableTranscriptionSend()
th_startTranscriptionSendMessage = Thread(target=startTranscriptionSendMessage)
th_startTranscriptionSendMessage.daemon = True
th_startTranscriptionSendMessage.start()
startThreadingTranscriptionSendMessage()
else:
view.printToTextbox_disableTranscriptionSend()
th_stopTranscriptionSendMessage = Thread(target=stopTranscriptionSendMessage)
th_stopTranscriptionSendMessage.daemon = True
th_stopTranscriptionSendMessage.start()
stopThreadingTranscriptionSendMessage()
def callbackToggleTranscriptionReceive(is_turned_on):
view.setMainWindowAllWidgetsStatusToDisabled()
config.ENABLE_TRANSCRIPTION_RECEIVE = is_turned_on
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
view.printToTextbox_enableTranscriptionReceive()
th_startTranscriptionReceiveMessage = Thread(target=startTranscriptionReceiveMessage)
th_startTranscriptionReceiveMessage.daemon = True
th_startTranscriptionReceiveMessage.start()
startThreadingTranscriptionReceiveMessage()
else:
view.printToTextbox_disableTranscriptionReceive()
th_stopTranscriptionReceiveMessage = Thread(target=stopTranscriptionReceiveMessage)
th_stopTranscriptionReceiveMessage.daemon = True
th_stopTranscriptionReceiveMessage.start()
stopThreadingTranscriptionReceiveMessage()
def callbackToggleForeground(is_turned_on):
config.ENABLE_FOREGROUND = is_turned_on
@@ -217,8 +229,21 @@ def callbackToggleForeground(is_turned_on):
view.printToTextbox_disableForeground()
view.foregroundOff()
# Config Window
def callbackOpenConfigWindow():
if config.ENABLE_TRANSCRIPTION_SEND is True:
stopThreadingTranscriptionSendMessage()
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
stopThreadingTranscriptionReceiveMessage()
def callbackCloseConfigWindow():
if config.ENABLE_TRANSCRIPTION_SEND is True:
startThreadingTranscriptionSendMessage()
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
startThreadingTranscriptionReceiveMessage()
model.stopCheckMicEnergy()
model.stopCheckSpeakerEnergy()
# Compact Mode Switch
def callbackEnableConfigWindowCompactMode():
config.IS_CONFIG_WINDOW_COMPACT_MODE = True

View File

@@ -67,7 +67,7 @@ class Model:
self.translator = Translator()
def resetKeywordProcessor(self):
del self.translator
del self.keyword_processor
self.keyword_processor = KeywordProcessor()
def authenticationTranslator(self, fnc, choice_translator=None, auth_key=None):