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