👍[Update] Model : 翻訳エンジンへのrequestが失敗した場合にエラーログを出力する機能を追加

This commit is contained in:
misyaguziya
2023-10-20 10:29:46 +09:00
parent d9e9c4d2ba
commit 12175a0788
3 changed files with 47 additions and 51 deletions

View File

@@ -26,9 +26,10 @@ def sendMicMessage(message):
view.printToTextbox_AuthenticationError() view.printToTextbox_AuthenticationError()
else: else:
translation = model.getInputTranslate(message) translation = model.getInputTranslate(message)
if translation == False:
if translation == None: config.ENABLE_TRANSLATION = False
translation = "" translation = ""
view.translationEngineLimitErrorProcess()
if config.ENABLE_TRANSCRIPTION_SEND is True: if config.ENABLE_TRANSCRIPTION_SEND is True:
if config.ENABLE_SEND_MESSAGE_TO_VRC is True: if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
@@ -91,9 +92,10 @@ def receiveSpeakerMessage(message):
view.printToTextbox_AuthenticationError() view.printToTextbox_AuthenticationError()
else: else:
translation = model.getOutputTranslate(message) translation = model.getOutputTranslate(message)
if translation == False:
if translation == None: config.ENABLE_TRANSLATION = False
translation = "" translation = ""
view.translationEngineLimitErrorProcess()
if config.ENABLE_TRANSCRIPTION_RECEIVE is True: if config.ENABLE_TRANSCRIPTION_RECEIVE is True:
if config.ENABLE_NOTICE_XSOVERLAY is True: if config.ENABLE_NOTICE_XSOVERLAY is True:
@@ -158,9 +160,10 @@ def sendChatMessage(message):
view.printToTextbox_AuthenticationError() view.printToTextbox_AuthenticationError()
else: else:
translation = model.getInputTranslate(message) translation = model.getInputTranslate(message)
if translation == False:
if translation == None: config.ENABLE_TRANSLATION = False
translation = "" translation = ""
view.translationEngineLimitErrorProcess()
# send OSC message # send OSC message
if config.ENABLE_SEND_MESSAGE_TO_VRC is True: if config.ENABLE_SEND_MESSAGE_TO_VRC is True:
@@ -389,7 +392,6 @@ def callbackSetDeeplAuthkey(value):
config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE)
else: else:
view.printToTextbox_AuthenticationError() view.printToTextbox_AuthenticationError()
print(config.AUTH_KEYS, config.CHOICE_TRANSLATOR)
# Transcription Tab (Mic) # Transcription Tab (Mic)
def callbackSetMicHost(value): def callbackSetMicHost(value):

View File

@@ -142,7 +142,6 @@ class Model:
return self.translator.translator_status[config.CHOICE_TRANSLATOR] return self.translator.translator_status[config.CHOICE_TRANSLATOR]
def getInputTranslate(self, message): def getInputTranslate(self, message):
try:
if config.CHOICE_TRANSLATOR == "DeepL_API": if config.CHOICE_TRANSLATOR == "DeepL_API":
if config.TARGET_LANGUAGE == "English": if config.TARGET_LANGUAGE == "English":
if config.TARGET_COUNTRY in ["United States", "Canada", "Philippines"]: if config.TARGET_COUNTRY in ["United States", "Canada", "Philippines"]:
@@ -161,12 +160,9 @@ class Model:
target_language=config.TARGET_LANGUAGE, target_language=config.TARGET_LANGUAGE,
message=message message=message
) )
except:
translation = None
return translation return translation
def getOutputTranslate(self, message): def getOutputTranslate(self, message):
try:
if config.CHOICE_TRANSLATOR == "DeepL_API": if config.CHOICE_TRANSLATOR == "DeepL_API":
if config.SOURCE_LANGUAGE == "English": if config.SOURCE_LANGUAGE == "English":
if config.SOURCE_COUNTRY in ["United States", "Canada", "Philippines"]: if config.SOURCE_COUNTRY in ["United States", "Canada", "Philippines"]:
@@ -185,8 +181,6 @@ class Model:
target_language=config.SOURCE_LANGUAGE, target_language=config.SOURCE_LANGUAGE,
message=message message=message
) )
except:
translation = None
return translation return translation
def addKeywords(self): def addKeywords(self):

View File

@@ -66,5 +66,5 @@ class Translator():
to_language=target_language, to_language=target_language,
) )
except: except:
pass result = False
return result return result