👍️[Update] Main : 以下のエンドポイントを元に戻した

- /get/data/ctranslate2_weight_type
- /set/data/ctranslate2_weight_type
- /get/data/whisper_weight_type
- /set/data/whisper_weight_type
This commit is contained in:
misyaguziya
2024-11-07 01:25:47 +09:00
parent 7648ebe493
commit b9160c4ecd
3 changed files with 49 additions and 55 deletions

View File

@@ -118,8 +118,6 @@ class Model:
return self.translator.isLoadedCTranslate2Model() return self.translator.isLoadedCTranslate2Model()
def checkTranscriptionWhisperModelWeight(self, weight_type:str): def checkTranscriptionWhisperModelWeight(self, weight_type:str):
if weight_type == "none":
return True
return checkWhisperWeight(config.PATH_LOCAL, weight_type) return checkWhisperWeight(config.PATH_LOCAL, weight_type)
def downloadWhisperModelWeight(self, weight_type, callback=None, end_callback=None): def downloadWhisperModelWeight(self, weight_type, callback=None, end_callback=None):
@@ -429,7 +427,7 @@ class Model:
max_phrases=config.MIC_MAX_PHRASES, max_phrases=config.MIC_MAX_PHRASES,
transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE, transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE,
root=config.PATH_LOCAL, root=config.PATH_LOCAL,
whisper_weight_type=config.WHISPER_WEIGHT_TYPE if config.WHISPER_WEIGHT_TYPE != "none" else None, whisper_weight_type=config.WHISPER_WEIGHT_TYPE,
device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"],
device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"],
) )
@@ -593,7 +591,7 @@ class Model:
max_phrases=config.SPEAKER_MAX_PHRASES, max_phrases=config.SPEAKER_MAX_PHRASES,
transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE, transcription_engine=config.SELECTED_TRANSCRIPTION_ENGINE,
root=config.PATH_LOCAL, root=config.PATH_LOCAL,
whisper_weight_type=config.WHISPER_WEIGHT_TYPE if config.WHISPER_WEIGHT_TYPE != "none" else None, whisper_weight_type=config.WHISPER_WEIGHT_TYPE,
device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"],
device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"],
) )

View File

@@ -514,33 +514,12 @@ class Controller:
@staticmethod @staticmethod
def getSelectedTranslationEngines(*args, **kwargs) -> dict: def getSelectedTranslationEngines(*args, **kwargs) -> dict:
data = { return {"status":200, "result":config.SELECTED_TRANSLATION_ENGINES}
"engines":config.SELECTED_TRANSLATION_ENGINES,
"weight_type":config.CTRANSLATE2_WEIGHT_TYPE,
}
return {"status":200, "result":data}
@staticmethod @staticmethod
def setSelectedTranslationEngines(data:dict, *args, **kwargs) -> dict: def setSelectedTranslationEngines(data:dict, *args, **kwargs) -> dict:
config.SELECTED_TRANSLATION_ENGINES = data.get("engines", { config.SELECTED_TRANSLATION_ENGINES = data
"1":"CTranslate2", return {"status":200,"result":config.SELECTED_TRANSLATION_ENGINES}
"2":"CTranslate2",
"3":"CTranslate2",
})
config.CTRANSLATE2_WEIGHT_TYPE = data.get("weight_type", "small")
if model.checkTranslatorCTranslate2ModelWeight(config.CTRANSLATE2_WEIGHT_TYPE):
def callback():
model.changeTranslatorCTranslate2Model()
th_callback = Thread(target=callback)
th_callback.daemon = True
th_callback.start()
data = {
"engines":config.SELECTED_TRANSLATION_ENGINES,
"weight_type":config.CTRANSLATE2_WEIGHT_TYPE,
}
return {"status":200,"result":data}
@staticmethod @staticmethod
def getSelectedYourLanguages(*args, **kwargs) -> dict: def getSelectedYourLanguages(*args, **kwargs) -> dict:
@@ -562,21 +541,12 @@ class Controller:
@staticmethod @staticmethod
def getSelectedTranscriptionEngine(*args, **kwargs) -> dict: def getSelectedTranscriptionEngine(*args, **kwargs) -> dict:
data = { return {"status":200, "result":config.SELECTED_TRANSCRIPTION_ENGINE}
"engine":config.SELECTED_TRANSCRIPTION_ENGINE,
"weight_type":config.WHISPER_WEIGHT_TYPE,
}
return {"status":200, "result":data}
@staticmethod @staticmethod
def setSelectedTranscriptionEngine(data:dict, *args, **kwargs) -> dict: def setSelectedTranscriptionEngine(data, *args, **kwargs) -> dict:
config.SELECTED_TRANSCRIPTION_ENGINE = data["engine"] config.SELECTED_TRANSCRIPTION_ENGINE = str(data)
config.WHISPER_WEIGHT_TYPE = data["weight_type"] return {"status":200, "result":config.SELECTED_TRANSCRIPTION_ENGINE}
data = {
"engine":config.SELECTED_TRANSCRIPTION_ENGINE,
"weight_type":config.WHISPER_WEIGHT_TYPE,
}
return {"status":200, "result":data}
@staticmethod @staticmethod
def getMultiLanguageTranslation(*args, **kwargs) -> dict: def getMultiLanguageTranslation(*args, **kwargs) -> dict:
@@ -1132,6 +1102,30 @@ class Controller:
self.updateTranslationEngineAndEngineList() self.updateTranslationEngineAndEngineList()
return {"status":200, "result":config.AUTH_KEYS["DeepL_API"]} return {"status":200, "result":config.AUTH_KEYS["DeepL_API"]}
@staticmethod
def getCtranslate2WeightType(*args, **kwargs) -> dict:
return {"status":200, "result":config.CTRANSLATE2_WEIGHT_TYPE}
@staticmethod
def setCtranslate2WeightType(data, *args, **kwargs) -> dict:
config.CTRANSLATE2_WEIGHT_TYPE = str(data)
if model.checkTranslatorCTranslate2ModelWeight(config.CTRANSLATE2_WEIGHT_TYPE):
def callback():
model.changeTranslatorCTranslate2Model()
th_callback = Thread(target=callback)
th_callback.daemon = True
th_callback.start()
return {"status":200, "result":config.CTRANSLATE2_WEIGHT_TYPE}
@staticmethod
def getWhisperWeightType(*args, **kwargs) -> dict:
return {"status":200, "result":config.WHISPER_WEIGHT_TYPE}
@staticmethod
def setWhisperWeightType(data, *args, **kwargs) -> dict:
config.WHISPER_WEIGHT_TYPE = str(data)
return {"status":200, "result": config.WHISPER_WEIGHT_TYPE}
@staticmethod @staticmethod
def getAutoClearMessageBox(*args, **kwargs) -> dict: def getAutoClearMessageBox(*args, **kwargs) -> dict:
return {"status":200, "result":config.AUTO_CLEAR_MESSAGE_BOX} return {"status":200, "result":config.AUTO_CLEAR_MESSAGE_BOX}
@@ -1439,9 +1433,6 @@ class Controller:
def downloadWhisperWeight(self, data:str, *args, **kwargs) -> dict: def downloadWhisperWeight(self, data:str, *args, **kwargs) -> dict:
weight_type = str(data) weight_type = str(data)
if weight_type == "none":
pass
else:
download_whisper = self.DownloadWhisper( download_whisper = self.DownloadWhisper(
self.run_mapping, self.run_mapping,
weight_type, weight_type,
@@ -1591,9 +1582,8 @@ class Controller:
def updateTranscriptionEngine(self): def updateTranscriptionEngine(self):
weight_type_dict = config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT weight_type_dict = config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT
weight_type = config.WHISPER_WEIGHT_TYPE weight_type = config.WHISPER_WEIGHT_TYPE
if config.SELECTED_TRANSCRIPTION_ENGINE == "Whisper" and (weight_type == "none" or weight_type_dict[weight_type] is False): if config.SELECTED_TRANSCRIPTION_ENGINE == "Whisper" and weight_type_dict[weight_type] is False:
config.SELECTED_TRANSCRIPTION_ENGINE = "Google" config.SELECTED_TRANSCRIPTION_ENGINE = "Google"
config.WHISPER_WEIGHT_TYPE = "none"
def startCheckMicEnergy(self) -> None: def startCheckMicEnergy(self) -> None:
while self.device_access_status is False: while self.device_access_status is False:

View File

@@ -137,6 +137,10 @@ mapping = {
"/set/data/selected_translation_compute_device": {"status": True, "variable":controller.setSelectedTranslationComputeDevice}, "/set/data/selected_translation_compute_device": {"status": True, "variable":controller.setSelectedTranslationComputeDevice},
"/get/data/selectable_ctranslate2_weight_type_dict": {"status": True, "variable":controller.getSelectableCtranslate2WeightTypeDict}, "/get/data/selectable_ctranslate2_weight_type_dict": {"status": True, "variable":controller.getSelectableCtranslate2WeightTypeDict},
"/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType},
"/set/data/ctranslate2_weight_type": {"status": True, "variable":controller.setCtranslate2WeightType},
"/run/download_ctranslate2_weight": {"status": True, "variable":controller.downloadCtranslate2Weight}, "/run/download_ctranslate2_weight": {"status": True, "variable":controller.downloadCtranslate2Weight},
"/get/data/deepl_auth_key": {"status": False, "variable":controller.getDeepLAuthKey}, "/get/data/deepl_auth_key": {"status": False, "variable":controller.getDeepLAuthKey},
@@ -238,6 +242,8 @@ mapping = {
"/set/data/selected_transcription_compute_device": {"status": True, "variable":controller.setSelectedTranscriptionComputeDevice}, "/set/data/selected_transcription_compute_device": {"status": True, "variable":controller.setSelectedTranscriptionComputeDevice},
"/get/data/selectable_whisper_weight_type_dict": {"status": True, "variable":controller.getSelectableWhisperWeightTypeDict}, "/get/data/selectable_whisper_weight_type_dict": {"status": True, "variable":controller.getSelectableWhisperWeightTypeDict},
"/get/data/whisper_weight_type": {"status": True, "variable":controller.getWhisperWeightType},
"/set/data/whisper_weight_type": {"status": True, "variable":controller.setWhisperWeightType},
"/run/download_whisper_weight": {"status": True, "variable":controller.downloadWhisperWeight}, "/run/download_whisper_weight": {"status": True, "variable":controller.downloadWhisperWeight},
# VR # VR