👍️[Update] Model : overlay_show_only_translated_messagesのendpointを追加

This commit is contained in:
misyaguziya
2024-12-02 11:15:10 +09:00
parent c0942b0fbc
commit bf49715209
3 changed files with 31 additions and 12 deletions

View File

@@ -811,14 +811,14 @@ class Config:
self.saveConfig(inspect.currentframe().f_code.co_name, self.OVERLAY_LARGE_LOG_SETTINGS)
@property
@json_serializable('OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE')
def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE(self):
return self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE
@json_serializable('OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES')
def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES(self):
return self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES
@OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE.setter
def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE(self, value):
@OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES.setter
def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES(self, value):
if isinstance(value, bool):
self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE = value
self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = value
self.saveConfig(inspect.currentframe().f_code.co_name, value)
@property
@@ -1119,7 +1119,7 @@ class Config:
"ui_scaling": 1.0,
"tracker": "LeftHand",
}
self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE = False
self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = False
self._SEND_MESSAGE_TO_VRC = True
self._SEND_RECEIVED_MESSAGE_TO_VRC = False
self._LOGGER_FEATURE = False

View File

@@ -251,7 +251,7 @@ class Controller:
model.logger.info(f"[SENT] {message}{translation}")
if config.OVERLAY_LARGE_LOG is True and model.overlay.initialized is True:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0:
overlay_image = model.createOverlayImageLargeLog("send", translation[0], "")
else:
overlay_image = model.createOverlayImageLargeLog("send", message, translation[0] if len(translation) > 0 else "")
@@ -293,14 +293,14 @@ class Controller:
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
if config.OVERLAY_SMALL_LOG is True and model.overlay.initialized is True:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0:
overlay_image = model.createOverlayImageSmallLog(translation[0], "")
else:
overlay_image = model.createOverlayImageSmallLog(message, translation[0] if len(translation) > 0 else "")
model.updateOverlaySmallLog(overlay_image)
if config.OVERLAY_LARGE_LOG is True and model.overlay.initialized is True:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0:
overlay_image = model.createOverlayImageLargeLog("receive", translation[0], "")
else:
overlay_image = model.createOverlayImageLargeLog("receive", message, translation[0] if len(translation) > 0 else "")
@@ -370,7 +370,7 @@ class Controller:
model.oscSendMessage(osc_message)
if config.OVERLAY_LARGE_LOG is True:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0:
if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0:
overlay_image = model.createOverlayImageLargeLog("send", translation[0], "")
else:
overlay_image = model.createOverlayImageLargeLog("send", message, translation[0] if len(translation) > 0 else "")
@@ -1240,6 +1240,20 @@ class Controller:
model.updateOverlayLargeLogSettings()
return {"status":200, "result":config.OVERLAY_LARGE_LOG_SETTINGS}
@staticmethod
def getOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES}
@staticmethod
def setEnableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict:
config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = True
return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES}
@staticmethod
def setDisableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict:
config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = False
return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES}
@staticmethod
def getSendMessageToVrc(*args, **kwargs) -> dict:
return {"status":200, "result":config.SEND_MESSAGE_TO_VRC}

View File

@@ -132,12 +132,13 @@ mapping = {
"/get/data/main_window_geometry": {"status": True, "variable":controller.getMainWindowGeometry},
"/set/data/main_window_geometry": {"status": True, "variable":controller.setMainWindowGeometry},
# Translation
# Compute device
"/get/data/compute_mode": {"status": True, "variable":controller.getComputeMode},
"/get/data/translation_compute_device_list": {"status": True, "variable":controller.getComputeDeviceList},
"/get/data/selected_translation_compute_device": {"status": True, "variable":controller.getSelectedTranslationComputeDevice},
"/set/data/selected_translation_compute_device": {"status": True, "variable":controller.setSelectedTranslationComputeDevice},
# Translation
"/get/data/selectable_ctranslate2_weight_type_dict": {"status": True, "variable":controller.getSelectableCtranslate2WeightTypeDict},
"/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType},
@@ -263,6 +264,10 @@ mapping = {
"/get/data/overlay_large_log_settings": {"status": True, "variable":controller.getOverlayLargeLogSettings},
"/set/data/overlay_large_log_settings": {"status": True, "variable":controller.setOverlayLargeLogSettings},
"/get/data/overlay_show_only_translated_messages": {"status": True, "variable":controller.getOverlayShowOnlyTranslatedMessages},
"/set/enable/overlay_show_only_translated_messages": {"status": True, "variable":controller.setEnableOverlayShowOnlyTranslatedMessages},
"/set/disable/overlay_show_only_translated_messages": {"status": True, "variable":controller.setDisableOverlayShowOnlyTranslatedMessages},
# Others
"/get/data/auto_clear_message_box": {"status": True, "variable":controller.getAutoClearMessageBox},
"/set/enable/auto_clear_message_box": {"status": True, "variable":controller.setEnableAutoClearMessageBox},