👍️ [Update] Model : 日本語ひらがな/ローマ字 変換の実装

ローマ字/ひらがな有効でかつ以下の場合に動作
- 送信の翻訳時にtargetのプライマリが日本語の場合
- 受診時にtargetのプライマリが日本語の場合
This commit is contained in:
misyaguziya
2024-09-12 00:42:49 +09:00
parent ab2dc073b9
commit ce28366278
3 changed files with 47 additions and 9 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,9 +316,9 @@ class ChatMessage:
}
})
message_romaji = []
if config.ENABLE_CONVERT_MESSAGE_TO_ROMAJI is True or config.ENABLE_CONVERT_MESSAGE_TO_HIRAGANA is True:
message_romaji = model.convertMessageToRomajiAndHiragana(message)
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:
@@ -335,7 +348,7 @@ class ChatMessage:
"id":id,
"message":message,
"translation":translation,
"romaji":message_romaji,
"transliteration":transliteration,
},
}
@@ -505,6 +518,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