ConfigクラスにSELECTED_TAB_TARGET_LANGUAGES_NO_LISTプロパティを追加し、メッセージの変換処理を改善
This commit is contained in:
@@ -107,6 +107,10 @@ class Config:
|
||||
def SELECTABLE_TAB_NO_LIST(self):
|
||||
return self._SELECTABLE_TAB_NO_LIST
|
||||
|
||||
@property
|
||||
def SELECTED_TAB_TARGET_LANGUAGES_NO_LIST(self):
|
||||
return self._SELECTED_TAB_TARGET_LANGUAGES_NO_LIST
|
||||
|
||||
@property
|
||||
def SELECTABLE_CTRANSLATE2_WEIGHT_TYPE_LIST(self):
|
||||
return self._SELECTABLE_CTRANSLATE2_WEIGHT_TYPE_LIST
|
||||
@@ -1115,24 +1119,17 @@ class Config:
|
||||
},
|
||||
}
|
||||
self._SELECTED_TARGET_LANGUAGES = {}
|
||||
self._SELECTED_TAB_TARGET_LANGUAGES_NO_LIST = ["1", "2", "3"]
|
||||
for tab_no in self.SELECTABLE_TAB_NO_LIST:
|
||||
self._SELECTED_TARGET_LANGUAGES[tab_no] = {
|
||||
"1": {
|
||||
"language": "English",
|
||||
"country": "United States",
|
||||
"enable": True,
|
||||
},
|
||||
"2": {
|
||||
"language": "English",
|
||||
"country": "United States",
|
||||
"enable": False,
|
||||
},
|
||||
"3": {
|
||||
"language": "English",
|
||||
"country": "United States",
|
||||
"enable": False,
|
||||
},
|
||||
}
|
||||
for tab_target_lang_no in self.SELECTED_TAB_TARGET_LANGUAGES_NO_LIST:
|
||||
if tab_no not in self._SELECTED_TARGET_LANGUAGES:
|
||||
self.SELECTED_TARGET_LANGUAGES[tab_no] = {}
|
||||
if tab_target_lang_no not in self._SELECTED_TARGET_LANGUAGES[tab_no]:
|
||||
self.SELECTED_TARGET_LANGUAGES[tab_no][tab_target_lang_no] = {
|
||||
"language": "English",
|
||||
"country": "United States",
|
||||
"enable": True,
|
||||
}
|
||||
self._SELECTED_TRANSCRIPTION_ENGINE = "Google"
|
||||
self._CONVERT_MESSAGE_TO_ROMAJI = False
|
||||
self._CONVERT_MESSAGE_TO_HIRAGANA = False
|
||||
|
||||
@@ -298,14 +298,28 @@ class Controller:
|
||||
# その他のエラーは通常通り処理
|
||||
raise
|
||||
|
||||
transliteration_message = []
|
||||
transliteration_translation = []
|
||||
if config.CONVERT_MESSAGE_TO_HIRAGANA is True or config.CONVERT_MESSAGE_TO_ROMAJI is True:
|
||||
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
|
||||
transliteration = model.convertMessageToTransliteration(
|
||||
translation[0],
|
||||
if config.SELECTED_YOUR_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
|
||||
transliteration_message = model.convertMessageToTransliteration(
|
||||
message,
|
||||
hiragana=config.CONVERT_MESSAGE_TO_HIRAGANA,
|
||||
romaji=config.CONVERT_MESSAGE_TO_ROMAJI
|
||||
)
|
||||
|
||||
for i, no in enumerate(config.SELECTED_TAB_TARGET_LANGUAGES_NO_LIST):
|
||||
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO][no]["language"] == "Japanese":
|
||||
transliteration_translation.append(
|
||||
model.convertMessageToTransliteration(
|
||||
translation[i],
|
||||
hiragana=config.CONVERT_MESSAGE_TO_HIRAGANA,
|
||||
romaji=config.CONVERT_MESSAGE_TO_ROMAJI
|
||||
)
|
||||
)
|
||||
else:
|
||||
transliteration_translation.append([])
|
||||
|
||||
if config.ENABLE_TRANSCRIPTION_SEND is True:
|
||||
if config.SEND_MESSAGE_TO_VRC is True:
|
||||
if config.SEND_ONLY_TRANSLATED_MESSAGES is True:
|
||||
@@ -321,9 +335,16 @@ class Controller:
|
||||
200,
|
||||
self.run_mapping["transcription_mic"],
|
||||
{
|
||||
"message":message,
|
||||
"translation":translation,
|
||||
"transliteration":transliteration
|
||||
"original": {
|
||||
"message": message,
|
||||
"transliteration": transliteration_message
|
||||
},
|
||||
"translations": [
|
||||
{
|
||||
"message": translation_message,
|
||||
"transliteration": transliteration
|
||||
} for translation_message, transliteration in zip(translation, transliteration_translation)
|
||||
]
|
||||
})
|
||||
|
||||
if config.OVERLAY_LARGE_LOG is True and model.overlay.initialized is True:
|
||||
@@ -429,14 +450,24 @@ class Controller:
|
||||
# その他のエラーは通常通り処理
|
||||
raise
|
||||
|
||||
transliteration_message = []
|
||||
transliteration_translation = []
|
||||
if config.CONVERT_MESSAGE_TO_HIRAGANA is True or config.CONVERT_MESSAGE_TO_ROMAJI is True:
|
||||
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
|
||||
transliteration = model.convertMessageToTransliteration(
|
||||
if language == "Japanese":
|
||||
transliteration_message = model.convertMessageToTransliteration(
|
||||
message,
|
||||
hiragana=config.CONVERT_MESSAGE_TO_HIRAGANA,
|
||||
romaji=config.CONVERT_MESSAGE_TO_ROMAJI
|
||||
)
|
||||
|
||||
transliteration_translation = []
|
||||
if config.SELECTED_YOUR_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
|
||||
transliteration_translation = model.convertMessageToTransliteration(
|
||||
translation[0],
|
||||
hiragana=config.CONVERT_MESSAGE_TO_HIRAGANA,
|
||||
romaji=config.CONVERT_MESSAGE_TO_ROMAJI
|
||||
)
|
||||
|
||||
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_MESSAGES is True:
|
||||
@@ -492,9 +523,16 @@ class Controller:
|
||||
200,
|
||||
self.run_mapping["transcription_speaker"],
|
||||
{
|
||||
"message":message,
|
||||
"translation":translation,
|
||||
"transliteration":transliteration,
|
||||
"original": {
|
||||
"message": message,
|
||||
"transliteration": transliteration_message
|
||||
},
|
||||
"translations": [
|
||||
{
|
||||
"message": translation_message,
|
||||
"transliteration": transliteration
|
||||
} for translation_message, transliteration in zip(translation, transliteration_translation)
|
||||
]
|
||||
})
|
||||
|
||||
if model.checkWebSocketServerAlive() is True:
|
||||
@@ -570,22 +608,41 @@ class Controller:
|
||||
"result":
|
||||
{
|
||||
"id":id,
|
||||
"message":message,
|
||||
"translation":[],
|
||||
"transliteration":[],
|
||||
"original": {
|
||||
"message":message,
|
||||
"transliteration":[]
|
||||
},
|
||||
}
|
||||
"translations": [
|
||||
{
|
||||
"message": "",
|
||||
"transliteration": []
|
||||
} for _ in config.SELECTED_TAB_TARGET_LANGUAGES_NO_LIST
|
||||
]
|
||||
},
|
||||
}
|
||||
else:
|
||||
# その他のエラーは通常通り処理
|
||||
raise
|
||||
|
||||
transliteration_message = []
|
||||
transliteration_translation = []
|
||||
if config.CONVERT_MESSAGE_TO_HIRAGANA is True or config.CONVERT_MESSAGE_TO_ROMAJI is True:
|
||||
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
|
||||
transliteration = model.convertMessageToTransliteration(
|
||||
translation[0],
|
||||
if config.SELECTED_YOUR_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
|
||||
transliteration_message = model.convertMessageToTransliteration(
|
||||
message,
|
||||
hiragana=config.CONVERT_MESSAGE_TO_HIRAGANA,
|
||||
romaji=config.CONVERT_MESSAGE_TO_ROMAJI
|
||||
)
|
||||
for i, no in enumerate(config.SELECTED_TAB_TARGET_LANGUAGES_NO_LIST):
|
||||
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO][no]["language"] == "Japanese":
|
||||
transliteration = model.convertMessageToTransliteration(
|
||||
translation[i],
|
||||
hiragana=config.CONVERT_MESSAGE_TO_HIRAGANA,
|
||||
romaji=config.CONVERT_MESSAGE_TO_ROMAJI
|
||||
)
|
||||
transliteration_translation.append(transliteration)
|
||||
else:
|
||||
transliteration_translation.append([])
|
||||
|
||||
# send OSC message
|
||||
if config.SEND_MESSAGE_TO_VRC is True:
|
||||
@@ -635,14 +692,21 @@ class Controller:
|
||||
translation_text = f" ({'/'.join(translation)})" if translation else ""
|
||||
model.logger.info(f"[CHAT] {message}{translation_text}")
|
||||
|
||||
return {"status":200,
|
||||
return {
|
||||
"status":200,
|
||||
"result":{
|
||||
"id":id,
|
||||
"message":message,
|
||||
"translation":translation,
|
||||
"transliteration":transliteration,
|
||||
"original": {
|
||||
"message":message,
|
||||
"transliteration":transliteration_message
|
||||
},
|
||||
}
|
||||
"translations": [
|
||||
{
|
||||
"message": translation_message,
|
||||
"transliteration": transliteration
|
||||
} for translation_message, transliteration in zip(translation, transliteration_translation)
|
||||
]
|
||||
}}
|
||||
|
||||
@staticmethod
|
||||
def getVersion(*args, **kwargs) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user