Merge branch 'models' into for_webui

This commit is contained in:
misyaguziya
2024-09-02 12:07:53 +09:00
4 changed files with 35 additions and 61 deletions

View File

@@ -211,23 +211,23 @@ class Config:
if value in list(translation_lang.keys()):
self._CHOICE_OUTPUT_TRANSLATOR = value
@property
def SENT_MESSAGES_LOG(self):
return self._SENT_MESSAGES_LOG
# @property
# def SENT_MESSAGES_LOG(self):
# return self._SENT_MESSAGES_LOG
@SENT_MESSAGES_LOG.setter
def SENT_MESSAGES_LOG(self, value):
if isinstance(value, list):
self._SENT_MESSAGES_LOG = value
# @SENT_MESSAGES_LOG.setter
# def SENT_MESSAGES_LOG(self, value):
# if isinstance(value, list):
# self._SENT_MESSAGES_LOG = value
@property
def CURRENT_SENT_MESSAGES_LOG_INDEX(self):
return self._CURRENT_SENT_MESSAGES_LOG_INDEX
# @property
# def CURRENT_SENT_MESSAGES_LOG_INDEX(self):
# return self._CURRENT_SENT_MESSAGES_LOG_INDEX
@CURRENT_SENT_MESSAGES_LOG_INDEX.setter
def CURRENT_SENT_MESSAGES_LOG_INDEX(self, value):
if isinstance(value, int):
self._CURRENT_SENT_MESSAGES_LOG_INDEX = value
# @CURRENT_SENT_MESSAGES_LOG_INDEX.setter
# def CURRENT_SENT_MESSAGES_LOG_INDEX(self, value):
# if isinstance(value, int):
# self._CURRENT_SENT_MESSAGES_LOG_INDEX = value
@property
def IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION(self):
@@ -769,17 +769,6 @@ class Config:
self._SEND_MESSAGE_BUTTON_TYPE = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@json_serializable('ENABLE_NOTICE_XSOVERLAY')
def ENABLE_NOTICE_XSOVERLAY(self):
return self._ENABLE_NOTICE_XSOVERLAY
@ENABLE_NOTICE_XSOVERLAY.setter
def ENABLE_NOTICE_XSOVERLAY(self, value):
if isinstance(value, bool):
self._ENABLE_NOTICE_XSOVERLAY = value
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
@property
@json_serializable('OVERLAY_SETTINGS')
def OVERLAY_SETTINGS(self):
@@ -1017,8 +1006,8 @@ class Config:
self._SOURCE_COUNTRY = "Japan"
self._TARGET_LANGUAGE = "English"
self._TARGET_COUNTRY = "United States"
self._SENT_MESSAGES_LOG = []
self._CURRENT_SENT_MESSAGES_LOG_INDEX = 0
# self._SENT_MESSAGES_LOG = []
# self._CURRENT_SENT_MESSAGES_LOG_INDEX = 0
self._IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False
self._IS_RESET_BUTTON_DISPLAYED_FOR_WHISPER = False
self._IS_EASTER_EGG_ENABLED = False
@@ -1116,7 +1105,6 @@ class Config:
self._ENABLE_AUTO_CLEAR_MESSAGE_BOX = True
self._ENABLE_SEND_ONLY_TRANSLATED_MESSAGES = False
self._SEND_MESSAGE_BUTTON_TYPE = "show"
self._ENABLE_NOTICE_XSOVERLAY = False
self._OVERLAY_SETTINGS = {
"opacity": 1.0,
"ui_scaling": 1.0,

View File

@@ -672,9 +672,6 @@ class Model:
self.speaker_energy_recorder.stop()
self.speaker_energy_recorder = None
def notificationXSOverlay(self, message):
xsoverlayForVRCT(content=f"{message}")
def createOverlayImageShort(self, message, translation):
your_language = config.TARGET_LANGUAGE
target_language = config.SOURCE_LANGUAGE

View File

@@ -99,7 +99,7 @@ class MicMessage:
}
})
elif isinstance(message, str) and len(message) > 0:
addSentMessageLog(message)
# addSentMessageLog(message)
translation = ""
if model.checkKeywords(message):
self.action("word_filter", {
@@ -224,10 +224,6 @@ class SpeakerMessage:
})
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
if config.ENABLE_NOTICE_XSOVERLAY is True:
xsoverlay_message = messageFormatter("RECEIVED", translation, message)
model.notificationXSOverlay(xsoverlay_message)
if config.ENABLE_OVERLAY_SMALL_LOG is True:
if model.overlay.initialized is True:
overlay_image = model.createOverlayImageShort(message, translation)
@@ -305,7 +301,7 @@ class ChatMessage:
id = data["id"]
message = decodeUtf8(data["message"])
if len(message) > 0:
addSentMessageLog(message)
# addSentMessageLog(message)
translation = ""
if config.ENABLE_TRANSLATION is False:
pass
@@ -353,16 +349,20 @@ class ChatMessage:
},
}
def callbackMessageBoxPressKeyEnter(data, action, *args, **kwargs) -> dict:
def callbackMessageBoxSend(data, action, *args, **kwargs) -> dict:
chat = ChatMessage(action)
response = chat.send(data)
return response
def messageBoxPressKeyAny(e):
def callbackMessageBoxTyping(*args, **kwargs) -> dict:
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
model.oscStartSendTyping()
else:
return {"status":200}
def callbackMessageBoxTypingStop(*args, **kwargs) -> dict:
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
model.oscStopSendTyping()
return {"status":200}
def messageBoxFocusIn(e):
# view.foregroundOffIfForegroundEnabled()
@@ -373,9 +373,9 @@ def messageBoxFocusOut(e):
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
model.oscStopSendTyping()
def addSentMessageLog(sent_message):
config.SENT_MESSAGES_LOG.append(sent_message)
config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG)
# def addSentMessageLog(sent_message):
# config.SENT_MESSAGES_LOG.append(sent_message)
# config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG)
# def updateMessageBox(index_offset):
# if len(config.SENT_MESSAGES_LOG) == 0:
@@ -1173,16 +1173,6 @@ def callbackSetSendMessageButtonType(data, *args, **kwargs) -> dict:
config.SEND_MESSAGE_BUTTON_TYPE = data
return {"status":200, "result":config.SEND_MESSAGE_BUTTON_TYPE}
def callbackEnableNoticeXsoverlay(*args, **kwargs) -> dict:
printLog("Enable Notice Xsoverlay")
config.ENABLE_NOTICE_XSOVERLAY = True
return {"status":200, "result":config.ENABLE_NOTICE_XSOVERLAY}
def callbackDisableNoticeXsoverlay(*args, **kwargs) -> dict:
printLog("Disable Notice Xsoverlay")
config.ENABLE_NOTICE_XSOVERLAY = False
return {"status":200, "result":config.ENABLE_NOTICE_XSOVERLAY}
def callbackEnableAutoExportMessageLogs(*args, **kwargs) -> dict:
printLog("Enable Auto Export Message Logs")
config.ENABLE_LOGGER = True

View File

@@ -3,7 +3,7 @@ import json
import time
from config import config
import webui_controller as controller
from utils import printLog
from utils import printLog, encodeUtf8
config_mapping = {
"/config/version": "VERSION",
@@ -73,7 +73,6 @@ config_mapping = {
"/config/enable_auto_clear_message_box": "ENABLE_AUTO_CLEAR_MESSAGE_BOX",
"/config/enable_send_only_translated_messages": "ENABLE_SEND_ONLY_TRANSLATED_MESSAGES",
"/config/send_message_button_type": "SEND_MESSAGE_BUTTON_TYPE",
"/config/enable_notice_xsoverlay": "ENABLE_NOTICE_XSOVERLAY",
"/config/overlay_settings": "OVERLAY_SETTINGS",
"/config/enable_overlay_small_log": "ENABLE_OVERLAY_SMALL_LOG",
"/config/overlay_small_log_settings": "OVERLAY_SMALL_LOG_SETTINGS",
@@ -110,7 +109,9 @@ controller_mapping = {
"/controller/callback_disable_transcription_send": controller.callbackDisableTranscriptionSend,
"/controller/callback_enable_transcription_receive": controller.callbackEnableTranscriptionReceive,
"/controller/callback_disable_transcription_receive": controller.callbackDisableTranscriptionReceive,
"/controller/callback_messagebox_press_key_enter": controller.callbackMessageBoxPressKeyEnter,
"/controller/callback_messagebox_send": controller.callbackMessageBoxSend,
"/controller/callback_messagebox_typing": controller.callbackMessageBoxTyping,
"/controller/callback_messagebox_typing_stop": controller.callbackMessageBoxTypingStop,
"/controller/callback_enable_foreground": controller.callbackEnableForeground,
"/controller/callback_disable_foreground": controller.callbackDisableForeground,
"/controller/set_your_language_and_country": controller.setYourLanguageAndCountry,
@@ -175,8 +176,6 @@ controller_mapping = {
"/controller/callback_enable_send_only_translated_messages": controller.callbackEnableSendOnlyTranslatedMessages,
"/controller/callback_disable_send_only_translated_messages": controller.callbackDisableSendOnlyTranslatedMessages,
"/controller/callback_set_send_message_button_type": controller.callbackSetSendMessageButtonType,
"/controller/callback_enable_notice_xsoverlay": controller.callbackEnableNoticeXsoverlay,
"/controller/callback_disable_notice_xsoverlay": controller.callbackDisableNoticeXsoverlay,
"/controller/callback_enable_auto_export_message_logs": controller.callbackEnableAutoExportMessageLogs,
"/controller/callback_disable_auto_export_message_logs": controller.callbackDisableAutoExportMessageLogs,
"/controller/callback_enable_vrc_mic_mute_sync": controller.callbackEnableVrcMicMuteSync,
@@ -234,7 +233,7 @@ action_mapping = {
"stopped":"/action/check_speaker_threshold_energy_stopped",
"error_device":"/action/error_device",
},
"/controller/callback_messagebox_press_key_enter": {
"/controller/callback_messagebox_send": {
"error_translation_engine":"/action/error_translation_engine"
},
"/controller/callback_download_ctranslate2_weight": {
@@ -373,8 +372,8 @@ if __name__ == "__main__":
printLog("endpoint", endpoint)
match endpoint:
case "/controller/callback_messagebox_press_key_enter":
data = "テスト"
case "/controller/callback_messagebox_send":
data = {"id":"123456", "message":encodeUtf8("テスト")}
case "/controller/set_your_language_and_country":
data = {"language": "English", "country": "Hong Kong"}
case "/controller/set_target_language_and_country":