Merge branch 'transliteration' into for_webui

This commit is contained in:
misyaguziya
2024-09-12 00:43:44 +09:00
5 changed files with 83 additions and 3 deletions

View File

@@ -98,6 +98,7 @@ class MicMessage:
elif isinstance(message, str) and len(message) > 0:
# addSentMessageLog(message)
translation = []
transliteration = []
if model.checkKeywords(message):
self.action("word_filter", {
"status":200,
@@ -121,6 +122,10 @@ class MicMessage:
}
})
if config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI is True or config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA is True:
if config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["primary"]["language"] == "Japanese":
transliteration = model.convertMessageToTransliteration(translation[0])
if config.ENABLE_TRANSCRIPTION_SEND is True:
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
if config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES is True:
@@ -136,7 +141,8 @@ class MicMessage:
"status":200,
"result": {
"message":message,
"translation":translation
"translation":translation,
"transliteration":transliteration
}
})
if config.ENABLE_LOGGER is True:
@@ -200,6 +206,7 @@ class SpeakerMessage:
})
elif isinstance(message, str) and len(message) > 0:
translation = []
transliteration = []
if model.detectRepeatReceiveMessage(message):
return
elif config.ENABLE_TRANSLATION is False:
@@ -215,6 +222,10 @@ class SpeakerMessage:
}
})
if config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI is True or config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA is True:
if config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["primary"]["language"] == "Japanese":
transliteration = model.convertMessageToTransliteration(message)
if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
if config.ENABLE_OVERLAY_SMALL_LOG is True:
if model.overlay.initialized is True:
@@ -236,7 +247,8 @@ class SpeakerMessage:
"status":200,
"result": {
"message":message,
"translation":translation
"translation":translation,
"transliteration":transliteration,
}
})
if config.ENABLE_LOGGER is True:
@@ -290,6 +302,7 @@ class ChatMessage:
if len(message) > 0:
# addSentMessageLog(message)
translation = []
transliteration = []
if config.ENABLE_TRANSLATION is False:
pass
else:
@@ -303,6 +316,10 @@ class ChatMessage:
}
})
if config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI is True or config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA is True:
if config.SELECTED_TAB_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["primary"]["language"] == "Japanese":
transliteration = model.convertMessageToTransliteration(translation[0])
# send OSC message
if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
if config.ENABLE_SEND_ONLY_TRANSLATED_MESSAGES is True:
@@ -331,6 +348,7 @@ class ChatMessage:
"id":id,
"message":message,
"translation":translation,
"transliteration":transliteration,
},
}
@@ -501,6 +519,26 @@ def callbackDisableMultiLanguageTranslation(*args, **kwargs) -> dict:
config.ENABLE_MULTI_LANGUAGE_TRANSLATION = False
return {"status":200, "result":config.ENABLE_MULTI_LANGUAGE_TRANSLATION}
def callbackEnableConvertMessageToRomaji(*args, **kwargs) -> dict:
printLog("Enable Convert Message To Romaji")
config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI = True
return {"status":200, "result":config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI}
def callbackDisableConvertMessageToRomaji(*args, **kwargs) -> dict:
printLog("Disable Convert Message To Romaji")
config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI = False
return {"status":200, "result":config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI}
def callbackEnableConvertMessageToHiragana(*args, **kwargs) -> dict:
printLog("Enable Convert Message To Hiragana")
config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA = True
return {"status":200, "result":config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA}
def callbackDisableConvertMessageToHiragana(*args, **kwargs) -> dict:
printLog("Disable Convert Message To Hiragana")
config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA = False
return {"status":200, "result":config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA}
def callbackEnableMainWindowSidebarCompactMode(*args, **kwargs) -> dict:
printLog("Enable MainWindow Sidebar Compact Mode")
config.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True