From 245855d0ca9d0ee316f0e183be800b2959404c17 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Wed, 17 Sep 2025 10:35:34 +0900 Subject: [PATCH 01/11] [Update] Add compute type management for CTranslate2 and Whisper models --- src-python/config.py | 38 ++++++++++++++++++- src-python/controller.py | 33 ++++++++++++++++ src-python/mainloop.py | 8 ++++ src-python/model.py | 12 ++++-- .../transcription_transcriber.py | 4 +- .../transcription/transcription_whisper.py | 5 ++- .../translation/translation_translator.py | 5 ++- src-python/utils.py | 5 ++- 8 files changed, 98 insertions(+), 12 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index c544727d..1a605701 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -11,7 +11,7 @@ from models.translation.translation_languages import translation_lang from models.translation.translation_utils import ctranslate2_weights from models.transcription.transcription_languages import transcription_lang from models.transcription.transcription_whisper import _MODELS as whisper_models -from utils import errorLogging, validateDictStructure +from utils import errorLogging, validateDictStructure, getComputeTypeList json_serializable_vars = {} def json_serializable(var_name): @@ -135,6 +135,14 @@ class Config: def SELECTABLE_COMPUTE_DEVICE_LIST(self): return self._SELECTABLE_COMPUTE_DEVICE_LIST + @property + def SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST(self): + return self._SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST + + @property + def SELECTABLE_WHISPER_COMPUTE_TYPE_LIST(self): + return self._SELECTABLE_WHISPER_COMPUTE_TYPE_LIST + @property def SEND_MESSAGE_BUTTON_TYPE_LIST(self): return self._SEND_MESSAGE_BUTTON_TYPE_LIST @@ -814,6 +822,18 @@ class Config: self._CTRANSLATE2_WEIGHT_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) + @property + @json_serializable('CTRANSLATE2_COMPUTE_TYPE') + def CTRANSLATE2_COMPUTE_TYPE(self): + return self._CTRANSLATE2_COMPUTE_TYPE + + @CTRANSLATE2_COMPUTE_TYPE.setter + def CTRANSLATE2_COMPUTE_TYPE(self, value): + if isinstance(value, str): + if value in self.SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST: + self._CTRANSLATE2_COMPUTE_TYPE = value + self.saveConfig(inspect.currentframe().f_code.co_name, value) + @property @json_serializable('WHISPER_WEIGHT_TYPE') def WHISPER_WEIGHT_TYPE(self): @@ -826,6 +846,18 @@ class Config: self._WHISPER_WEIGHT_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) + @property + @json_serializable('WHISPER_COMPUTE_TYPE') + def WHISPER_COMPUTE_TYPE(self): + return self._WHISPER_COMPUTE_TYPE + + @WHISPER_COMPUTE_TYPE.setter + def WHISPER_COMPUTE_TYPE(self, value): + if isinstance(value, str): + if value in self.SELECTABLE_WHISPER_COMPUTE_TYPE_LIST: + self._WHISPER_COMPUTE_TYPE = value + self.saveConfig(inspect.currentframe().f_code.co_name, value) + @property @json_serializable('AUTO_CLEAR_MESSAGE_BOX') def AUTO_CLEAR_MESSAGE_BOX(self): @@ -1051,6 +1083,8 @@ class Config: for i in range(torch.cuda.device_count()): self._SELECTABLE_COMPUTE_DEVICE_LIST.append({"device":"cuda", "device_index": i, "device_name": torch.cuda.get_device_name(i)}) self._SELECTABLE_COMPUTE_DEVICE_LIST.append({"device":"cpu", "device_index": 0, "device_name": "cpu"}) + self._SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST = ["auto"] + getComputeTypeList() + self._SELECTABLE_WHISPER_COMPUTE_TYPE_LIST = ["auto"] + getComputeTypeList() self._SEND_MESSAGE_BUTTON_TYPE_LIST = ["show", "hide", "show_and_disable_enter_key"] self._SEND_MESSAGE_FORMAT_PARTS = { "message": { @@ -1189,7 +1223,9 @@ class Config: self._SELECTED_TRANSLATION_COMPUTE_DEVICE = copy.deepcopy(self.SELECTABLE_COMPUTE_DEVICE_LIST[0]) self._SELECTED_TRANSCRIPTION_COMPUTE_DEVICE = copy.deepcopy(self.SELECTABLE_COMPUTE_DEVICE_LIST[0]) self._CTRANSLATE2_WEIGHT_TYPE = "small" + self._CTRANSLATE2_COMPUTE_TYPE = "auto" self._WHISPER_WEIGHT_TYPE = "base" + self._WHISPER_COMPUTE_TYPE = "auto" self._AUTO_CLEAR_MESSAGE_BOX = True self._SEND_ONLY_TRANSLATED_MESSAGES = False self._OVERLAY_SMALL_LOG = False diff --git a/src-python/controller.py b/src-python/controller.py index c34abaf8..afa9d266 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -652,6 +652,14 @@ class Controller: def getComputeDeviceList(*args, **kwargs) -> dict: return {"status":200, "result":config.SELECTABLE_COMPUTE_DEVICE_LIST} + @staticmethod + def getCTranslate2ComputeTypeList(*args, **kwargs) -> dict: + return {"status":200, "result":config.SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST} + + @staticmethod + def getWhisperComputeTypeList(*args, **kwargs) -> dict: + return {"status":200, "result":config.SELECTABLE_WHISPER_COMPUTE_TYPE_LIST} + @staticmethod def getSelectedTranslationComputeDevice(*args, **kwargs) -> dict: return {"status":200, "result":config.SELECTED_TRANSLATION_COMPUTE_DEVICE} @@ -1447,6 +1455,22 @@ class Controller: th_callback.join() return {"status":200, "result":config.CTRANSLATE2_WEIGHT_TYPE} + @staticmethod + def getCtranslateComputeType(*args, **kwargs) -> dict: + return {"status":200, "result":config.CTRANSLATE2_COMPUTE_TYPE} + + @staticmethod + def setCtranslateComputeType(data, *args, **kwargs) -> dict: + config.CTRANSLATE2_COMPUTE_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() + th_callback.join() + return {"status":200, "result":config.CTRANSLATE2_COMPUTE_TYPE} + @staticmethod def getWhisperWeightType(*args, **kwargs) -> dict: return {"status":200, "result":config.WHISPER_WEIGHT_TYPE} @@ -1456,6 +1480,15 @@ class Controller: config.WHISPER_WEIGHT_TYPE = str(data) return {"status":200, "result": config.WHISPER_WEIGHT_TYPE} + @staticmethod + def getWhisperComputeType(*args, **kwargs) -> dict: + return {"status":200, "result":config.WHISPER_COMPUTE_TYPE} + + @staticmethod + def setWhisperComputeType(data, *args, **kwargs) -> dict: + config.WHISPER_COMPUTE_TYPE = str(data) + return {"status":200, "result":config.WHISPER_COMPUTE_TYPE} + @staticmethod def getSendMessageFormatParts(*args, **kwargs) -> dict: return {"status":200, "result":config.SEND_MESSAGE_FORMAT_PARTS} diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 0010b98a..2ad6e078 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -162,6 +162,9 @@ mapping = { "/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType}, "/set/data/ctranslate2_weight_type": {"status": True, "variable":controller.setCtranslate2WeightType}, + "/get/data/ctranslate2_compute_type": {"status": True, "variable":controller.getCtranslateComputeType}, + "/set/data/ctranslate2_compute_type": {"status": True, "variable":controller.setCtranslateComputeType}, + "/run/download_ctranslate2_weight": {"status": True, "variable":controller.downloadCtranslate2Weight}, "/get/data/deepl_auth_key": {"status": False, "variable":controller.getDeepLAuthKey}, @@ -261,8 +264,13 @@ mapping = { "/set/disable/check_speaker_threshold": {"status": True, "variable":controller.setDisableCheckSpeakerThreshold}, "/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}, + + "/get/data/whisper_compute_type": {"status": True, "variable":controller.getWhisperComputeType}, + "/set/data/whisper_compute_type": {"status": True, "variable":controller.setWhisperComputeType}, + "/run/download_whisper_weight": {"status": True, "variable":controller.downloadWhisperWeight}, # VR diff --git a/src-python/model.py b/src-python/model.py index 333f1394..445b0a5e 100644 --- a/src-python/model.py +++ b/src-python/model.py @@ -112,10 +112,12 @@ class Model: def changeTranslatorCTranslate2Model(self): self.translator.changeCTranslate2Model( - config.PATH_LOCAL, - config.CTRANSLATE2_WEIGHT_TYPE, - config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device"], - config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device_index"]) + path=config.PATH_LOCAL, + model_type=config.CTRANSLATE2_WEIGHT_TYPE, + device=config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device"], + device_index=config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device_index"], + compute_type=config.CTRANSLATE2_COMPUTE_TYPE + ) def downloadCTranslate2ModelWeight(self, weight_type, callback=None, end_callback=None): return downloadCTranslate2Weight(config.PATH_LOCAL, weight_type, callback, end_callback) @@ -438,6 +440,7 @@ class Model: whisper_weight_type=config.WHISPER_WEIGHT_TYPE, device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], + compute_type=config.WHISPER_COMPUTE_TYPE, ) def sendMicTranscript(): try: @@ -621,6 +624,7 @@ class Model: whisper_weight_type=config.WHISPER_WEIGHT_TYPE, device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], + compute_type=config.WHISPER_COMPUTE_TYPE, ) def sendSpeakerTranscript(): try: diff --git a/src-python/models/transcription/transcription_transcriber.py b/src-python/models/transcription/transcription_transcriber.py index 5407253a..9d874b30 100644 --- a/src-python/models/transcription/transcription_transcriber.py +++ b/src-python/models/transcription/transcription_transcriber.py @@ -21,7 +21,7 @@ PHRASE_TIMEOUT = 3 MAX_PHRASES = 10 class AudioTranscriber: - def __init__(self, speaker, source, phrase_timeout, max_phrases, transcription_engine, root=None, whisper_weight_type=None, device="cpu", device_index=0): + def __init__(self, speaker, source, phrase_timeout, max_phrases, transcription_engine, root=None, whisper_weight_type=None, device="cpu", device_index=0, compute_type="auto"): self.speaker = speaker self.phrase_timeout = phrase_timeout self.max_phrases = max_phrases @@ -41,7 +41,7 @@ class AudioTranscriber: } if transcription_engine == "Whisper" and checkWhisperWeight(root, whisper_weight_type) is True: - self.whisper_model = getWhisperModel(root, whisper_weight_type, device=device, device_index=device_index) + self.whisper_model = getWhisperModel(root, whisper_weight_type, device=device, device_index=device_index, compute_type=compute_type) self.transcription_engine = "Whisper" def transcribeAudioQueue(self, audio_queue, languages, countries, avg_logprob=-0.8, no_speech_prob=0.6): diff --git a/src-python/models/transcription/transcription_whisper.py b/src-python/models/transcription/transcription_whisper.py index 04f89626..5f61a121 100644 --- a/src-python/models/transcription/transcription_whisper.py +++ b/src-python/models/transcription/transcription_whisper.py @@ -74,9 +74,10 @@ def downloadWhisperWeight(root, weight_type, callback=None, end_callback=None): if isinstance(end_callback, Callable): end_callback() -def getWhisperModel(root, weight_type, device="cpu", device_index=0): +def getWhisperModel(root, weight_type, device="cpu", device_index=0, compute_type="auto"): path = os_path.join(root, "weights", "whisper", weight_type) - compute_type = getBestComputeType(device, device_index) + if compute_type == "auto": + compute_type = getBestComputeType(device, device_index) try: model = WhisperModel( path, diff --git a/src-python/models/translation/translation_translator.py b/src-python/models/translation/translation_translator.py index 42eb828e..897fcd1b 100644 --- a/src-python/models/translation/translation_translator.py +++ b/src-python/models/translation/translation_translator.py @@ -36,14 +36,15 @@ class Translator(): result = False return result - def changeCTranslate2Model(self, path, model_type, device="cpu", device_index=0): + def changeCTranslate2Model(self, path, model_type, device="cpu", device_index=0, compute_type="auto"): self.is_loaded_ctranslate2_model = False directory_name = ctranslate2_weights[model_type]["directory_name"] tokenizer = ctranslate2_weights[model_type]["tokenizer"] weight_path = os_path.join(path, "weights", "ctranslate2", directory_name) tokenizer_path = os_path.join(path, "weights", "ctranslate2", directory_name, "tokenizer") - compute_type = getBestComputeType(device, device_index) + if compute_type == "auto": + compute_type = getBestComputeType(device, device_index) self.ctranslate2_translator = ctranslate2.Translator( weight_path, device=device, diff --git a/src-python/utils.py b/src-python/utils.py index c3a857f2..1b28fcf6 100644 --- a/src-python/utils.py +++ b/src-python/utils.py @@ -78,10 +78,13 @@ def isValidIpAddress(ip_address: str) -> bool: except ValueError: return False +def getComputeTypeList() -> list: + return ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"] + def getBestComputeType(device, device_index) -> str: compute_types = get_supported_compute_types(device, device_index) compute_types = set(compute_types) - preferred_types = ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"] + preferred_types = getComputeTypeList() for preferred_type in preferred_types: if preferred_type in compute_types: From 5f0f9186422c887040a60c9bb66873cc7fa6ade2 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Wed, 17 Sep 2025 10:52:56 +0900 Subject: [PATCH 02/11] [Update] Rename and add methods for CTranslate2 compute type management in Controller --- src-python/controller.py | 8 ++++++-- src-python/mainloop.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src-python/controller.py b/src-python/controller.py index afa9d266..77717918 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -1456,11 +1456,15 @@ class Controller: return {"status":200, "result":config.CTRANSLATE2_WEIGHT_TYPE} @staticmethod - def getCtranslateComputeType(*args, **kwargs) -> dict: + def getCtranslate2ComputeTypeList(*args, **kwargs) -> dict: + return {"status":200, "result":config.SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST} + + @staticmethod + def getCtranslate2ComputeType(*args, **kwargs) -> dict: return {"status":200, "result":config.CTRANSLATE2_COMPUTE_TYPE} @staticmethod - def setCtranslateComputeType(data, *args, **kwargs) -> dict: + def setCtranslate2ComputeType(data, *args, **kwargs) -> dict: config.CTRANSLATE2_COMPUTE_TYPE = str(data) if model.checkTranslatorCTranslate2ModelWeight(config.CTRANSLATE2_WEIGHT_TYPE): def callback(): diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 2ad6e078..c7b03ea6 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -162,8 +162,10 @@ mapping = { "/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType}, "/set/data/ctranslate2_weight_type": {"status": True, "variable":controller.setCtranslate2WeightType}, - "/get/data/ctranslate2_compute_type": {"status": True, "variable":controller.getCtranslateComputeType}, - "/set/data/ctranslate2_compute_type": {"status": True, "variable":controller.setCtranslateComputeType}, + "/get/data/ctranslate2_compute_type_list": {"status": True, "variable":controller.getCtranslate2ComputeTypeList}, + + "/get/data/ctranslate2_compute_type": {"status": True, "variable":controller.getCtranslate2ComputeType}, + "/set/data/ctranslate2_compute_type": {"status": True, "variable":controller.setCtranslate2ComputeType}, "/run/download_ctranslate2_weight": {"status": True, "variable":controller.downloadCtranslate2Weight}, @@ -268,6 +270,8 @@ mapping = { "/get/data/whisper_weight_type": {"status": True, "variable":controller.getWhisperWeightType}, "/set/data/whisper_weight_type": {"status": True, "variable":controller.setWhisperWeightType}, + "/get/data/whisper_compute_type_list": {"status": True, "variable":controller.getWhisperComputeTypeList}, + "/get/data/whisper_compute_type": {"status": True, "variable":controller.getWhisperComputeType}, "/set/data/whisper_compute_type": {"status": True, "variable":controller.setWhisperComputeType}, From 4808dcbc96c57fbf627b1a824804dffbada68705 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 19 Sep 2025 14:43:13 +0900 Subject: [PATCH 03/11] [Update/Chore] Config Page: Add 'CTranslate2 Compute Type' Selection. UI: Rename 'CTranslate2 compute device' to 'Translation compute device'. --- locales/en.yml | 6 +- locales/ja.yml | 6 +- locales/ko.yml | 6 +- locales/zh-Hans.yml | 4 +- locales/zh-Hant.yml | 4 +- .../setting_box/translation/Translation.jsx | 62 ++++++++---- .../configs/translation/useTranslation.js | 96 ++++++++++++++----- src-ui/logics/useReceiveRoutes.js | 11 ++- src-ui/store.js | 9 +- 9 files changed, 148 insertions(+), 56 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 1faf9639..e96de8fb 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -133,8 +133,10 @@ config_page: desc: "You can choose the translation model when using the {{ctranslate2}} translation engine." small: "Basic Model ({{capacity}})" large: "High Accuracy Model ({{capacity}})" - ctranslate2_compute_device: - label: "Processing device for AI translation {{ctranslate2}}" + ctranslate2_compute_type: + label: "Processing type for AI translation {{ctranslate2}}" + translation_compute_device: + label: "Processing device for AI translation" deepl_auth_key: label: "DeepL Auth Key" desc: "When using it, please change {{translator}} on the main screen to DeepL_API. ※Some languages may not be supported." diff --git a/locales/ja.yml b/locales/ja.yml index d3da554e..a16b6b1d 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -133,8 +133,10 @@ config_page: desc: "翻訳エンジン「{{ctranslate2}}」で翻訳する際に、使用する翻訳モデルを選択できます。" small: "通常モデル ({{capacity}})" large: "高精度モデル ({{capacity}})" - ctranslate2_compute_device: - label: "AI翻訳 {{ctranslate2}} の処理デバイス" + ctranslate2_compute_type: + label: "AI翻訳 {{ctranslate2}} の処理タイプ" + translation_compute_device: + label: "AI翻訳の処理デバイス" deepl_auth_key: label: "DeepL APIキーの登録" desc: "使用の際は、メイン画面にある {{translator}} をDeepL_APIに変更してください。\n※対応していない言語もあります。" diff --git a/locales/ko.yml b/locales/ko.yml index d2e171ac..df188d5f 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -133,8 +133,10 @@ config_page: desc: "오프라인 번역 시의 번역 모델을 변경합니다." small: "일반 모델 ({{capacity}})" large: "정밀 모델 ({{capacity}})" - ctranslate2_compute_device: - label: "AI 번역 {{ctranslate2}} 처리 장치" + ctranslate2_compute_type: + label: + translation_compute_device: + label: "AI 번역 처리 장치" deepl_auth_key: label: "DeepL 인증키" desc: "사용시 메인화면에 있는 {{translator}}를 DeepL_API로 변경해 주세요.\n지원하지 않는 언어도 있습니다." diff --git a/locales/zh-Hans.yml b/locales/zh-Hans.yml index 71a75390..e2bd4a14 100644 --- a/locales/zh-Hans.yml +++ b/locales/zh-Hans.yml @@ -133,7 +133,9 @@ config_page: desc: "可以选择用于离线翻译的翻译模型" small: "普通模型 ({{capacity}})" large: "高精度模型 ({{capacity}})" - ctranslate2_compute_device: + ctranslate2_compute_type: + label: + translation_compute_device: label: deepl_auth_key: label: "DeepL 授权密匙" diff --git a/locales/zh-Hant.yml b/locales/zh-Hant.yml index f091fd03..bc190b25 100644 --- a/locales/zh-Hant.yml +++ b/locales/zh-Hant.yml @@ -133,7 +133,9 @@ config_page: desc: "你可以選擇用於離線翻譯引擎的翻譯模型。" small: "基本模型({{capacity}})" large: "高準確率模型({{capacity}})" - ctranslate2_compute_device: + ctranslate2_compute_type: + label: + translation_compute_device: label: deepl_auth_key: label: "DeepL 授權金鑰" diff --git a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx index 38c5a1e3..cdb8d351 100644 --- a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx @@ -18,7 +18,8 @@ export const Translation = () => { return ( <> - + + ); @@ -62,7 +63,7 @@ const CTranslate2WeightType_Box = () => { "config_page.translation.ctranslate2_weight_type.desc", {ctranslate2: "CTranslate2"} )} - name="ctransalte2_weight_type" + name="ctranslate2_weight_type" options={c_translate2_weight_types} checked_variable={currentSelectedCTranslate2WeightType} selectFunction={selectFunction} @@ -72,47 +73,72 @@ const CTranslate2WeightType_Box = () => { ); }; -// Duplicate -import { useComputeMode } from "@logics_common"; -const CTranslation2ComputeDevice_Box = () => { +const CTranslate2ComputeType_Box = () => { const { t } = useI18n(); - const { currentSelectedCTranslate2ComputeDevice, setSelectedCTranslate2ComputeDevice } = useTranslation(); - const { currentSelectableCTranslate2ComputeDeviceList } = useTranslation(); + const { currentSelectableCTranslate2ComputeTypeList } = useTranslation(); + const { currentSelectedCTranslate2ComputeType, setSelectedCTranslate2ComputeType } = useTranslation(); const selectFunction = (selected_data) => { - const target_obj = currentSelectableCTranslate2ComputeDeviceList.data[selected_data.selected_id]; - setSelectedCTranslate2ComputeDevice(target_obj); + setSelectedCTranslate2ComputeType(selected_data.selected_id); }; - const list_for_ui = transformDeviceArray(currentSelectableCTranslate2ComputeDeviceList.data); + const ctranslate2_compute_type_label = t("config_page.translation.ctranslate2_compute_type.label", { + ctranslate2: "CTranslate2" + }); - const target_index = findKeyByDeviceValue(currentSelectableCTranslate2ComputeDeviceList.data, currentSelectedCTranslate2ComputeDevice.data); + return ( + + ); +}; + +// Duplicate +import { useComputeMode } from "@logics_common"; +const TranslationComputeDevice_Box = () => { + const { t } = useI18n(); + const { currentSelectedTranslationComputeDevice, setSelectedTranslationComputeDevice } = useTranslation(); + const { currentSelectableTranslationComputeDeviceList } = useTranslation(); + + const selectFunction = (selected_data) => { + const target_obj = currentSelectableTranslationComputeDeviceList.data[selected_data.selected_id]; + setSelectedTranslationComputeDevice(target_obj); + }; + + const list_for_ui = transformDeviceArray(currentSelectableTranslationComputeDeviceList.data); + + const target_index = findKeyByDeviceValue(currentSelectableTranslationComputeDeviceList.data, currentSelectedTranslationComputeDevice.data); const { currentComputeMode } = useComputeMode(); - const ctranslate2_compute_device_label = t("config_page.translation.ctranslate2_compute_device.label", { - ctranslate2: "Ctranslate2" + const translation_compute_device_label = t("config_page.translation.translation_compute_device.label", { + ctranslate2: "CTranslate2" }); if (currentComputeMode.data === "cpu") { return ( ) } return ( ); }; diff --git a/src-ui/logics/configs/translation/useTranslation.js b/src-ui/logics/configs/translation/useTranslation.js index b282bf90..28ab10a4 100644 --- a/src-ui/logics/configs/translation/useTranslation.js +++ b/src-ui/logics/configs/translation/useTranslation.js @@ -1,13 +1,15 @@ import { useStore_CTranslate2WeightTypeStatus, useStore_SelectedCTranslate2WeightType, - useStore_SelectableCTranslate2ComputeDeviceList, - useStore_SelectedCTranslate2ComputeDevice, + useStore_SelectableCTranslate2ComputeTypeList, + useStore_SelectedCTranslate2ComputeType, + useStore_SelectableTranslationComputeDeviceList, + useStore_SelectedTranslationComputeDevice, useStore_DeepLAuthKey, } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; import { useI18n } from "@useI18n"; -import { transformToIndexedArray } from "@utils"; +import { transformToIndexedArray, arrayToObject } from "@utils"; import { useNotificationStatus } from "@logics_common"; export const useTranslation = () => { @@ -17,8 +19,13 @@ export const useTranslation = () => { const { currentCTranslate2WeightTypeStatus, updateCTranslate2WeightTypeStatus, pendingCTranslate2WeightTypeStatus } = useStore_CTranslate2WeightTypeStatus(); const { currentSelectedCTranslate2WeightType, updateSelectedCTranslate2WeightType, pendingSelectedCTranslate2WeightType } = useStore_SelectedCTranslate2WeightType(); - const { currentSelectableCTranslate2ComputeDeviceList, updateSelectableCTranslate2ComputeDeviceList, pendingSelectableCTranslate2ComputeDeviceList } = useStore_SelectableCTranslate2ComputeDeviceList(); - const { currentSelectedCTranslate2ComputeDevice, updateSelectedCTranslate2ComputeDevice, pendingSelectedCTranslate2ComputeDevice } = useStore_SelectedCTranslate2ComputeDevice(); + + const { currentSelectableCTranslate2ComputeTypeList, updateSelectableCTranslate2ComputeTypeList, pendingSelectableCTranslate2ComputeTypeList } = useStore_SelectableCTranslate2ComputeTypeList(); + const { currentSelectedCTranslate2ComputeType, updateSelectedCTranslate2ComputeType, pendingSelectedCTranslate2ComputeType } = useStore_SelectedCTranslate2ComputeType(); + + const { currentSelectableTranslationComputeDeviceList, updateSelectableTranslationComputeDeviceList, pendingSelectableTranslationComputeDeviceList } = useStore_SelectableTranslationComputeDeviceList(); + const { currentSelectedTranslationComputeDevice, updateSelectedTranslationComputeDevice, pendingSelectedTranslationComputeDevice } = useStore_SelectedTranslationComputeDevice(); + const { currentDeepLAuthKey, updateDeepLAuthKey, pendingDeepLAuthKey } = useStore_DeepLAuthKey(); @@ -80,28 +87,56 @@ export const useTranslation = () => { }; - const getSelectableCTranslate2ComputeDeviceList = () => { - pendingSelectableCTranslate2ComputeDeviceList(); + + const getSelectableCTranslate2ComputeTypeList = () => { + pendingSelectableCTranslate2ComputeTypeList(); + asyncStdoutToPython("/get/data/ctranslate2_compute_type_list"); + }; + + const updateSelectableCTranslate2ComputeTypeList_FromBackend = (payload) => { + updateSelectableCTranslate2ComputeTypeList(arrayToObject(payload)); + }; + + + const getSelectedCTranslate2ComputeType = () => { + pendingSelectedCTranslate2ComputeType(); + asyncStdoutToPython("/get/data/ctranslate2_compute_type"); + }; + + const setSelectedCTranslate2ComputeType = (selected_ctranslate2_compute_type) => { + pendingSelectedCTranslate2ComputeType(); + asyncStdoutToPython("/set/data/ctranslate2_compute_type", selected_ctranslate2_compute_type); + }; + + const setSuccessSelectedCTranslate2ComputeType = (selected_ctranslate2_compute_type) => { + updateSelectedCTranslate2ComputeType(selected_ctranslate2_compute_type); + showNotification_SaveSuccess(); + }; + + + + const getSelectableTranslationComputeDeviceList = () => { + pendingSelectableTranslationComputeDeviceList(); asyncStdoutToPython("/get/data/translation_compute_device_list"); }; - const updateSelectableCTranslate2ComputeDeviceList_FromBackend = (payload) => { - updateSelectableCTranslate2ComputeDeviceList(transformToIndexedArray(payload)); + const updateSelectableTranslationComputeDeviceList_FromBackend = (payload) => { + updateSelectableTranslationComputeDeviceList(transformToIndexedArray(payload)); }; - const getSelectedCTranslate2ComputeDevice = () => { - pendingSelectedCTranslate2ComputeDevice(); + const getSelectedTranslationComputeDevice = () => { + pendingSelectedTranslationComputeDevice(); asyncStdoutToPython("/get/data/selected_translation_compute_device"); }; - const setSelectedCTranslate2ComputeDevice = (selected_translation_compute_device) => { - pendingSelectedCTranslate2ComputeDevice(); + const setSelectedTranslationComputeDevice = (selected_translation_compute_device) => { + pendingSelectedTranslationComputeDevice(); asyncStdoutToPython("/set/data/selected_translation_compute_device", selected_translation_compute_device); }; - const setSuccessSelectedCTranslate2ComputeDevice = (selected_translation_compute_device) => { - updateSelectedCTranslate2ComputeDevice(selected_translation_compute_device); + const setSuccessSelectedTranslationComputeDevice = (selected_translation_compute_device) => { + updateSelectedTranslationComputeDevice(selected_translation_compute_device); showNotification_SaveSuccess(); }; @@ -146,16 +181,29 @@ export const useTranslation = () => { setSelectedCTranslate2WeightType, setSuccessSelectedCTranslate2WeightType, - currentSelectableCTranslate2ComputeDeviceList, - getSelectableCTranslate2ComputeDeviceList, - updateSelectableCTranslate2ComputeDeviceList, - updateSelectableCTranslate2ComputeDeviceList_FromBackend, - currentSelectedCTranslate2ComputeDevice, - getSelectedCTranslate2ComputeDevice, - updateSelectedCTranslate2ComputeDevice, - setSelectedCTranslate2ComputeDevice, - setSuccessSelectedCTranslate2ComputeDevice, + currentSelectableCTranslate2ComputeTypeList, + getSelectableCTranslate2ComputeTypeList, + updateSelectableCTranslate2ComputeTypeList, + updateSelectableCTranslate2ComputeTypeList_FromBackend, + + currentSelectedCTranslate2ComputeType, + getSelectedCTranslate2ComputeType, + updateSelectedCTranslate2ComputeType, + setSelectedCTranslate2ComputeType, + setSuccessSelectedCTranslate2ComputeType, + + + currentSelectableTranslationComputeDeviceList, + getSelectableTranslationComputeDeviceList, + updateSelectableTranslationComputeDeviceList, + updateSelectableTranslationComputeDeviceList_FromBackend, + + currentSelectedTranslationComputeDevice, + getSelectedTranslationComputeDevice, + updateSelectedTranslationComputeDevice, + setSelectedTranslationComputeDevice, + setSuccessSelectedTranslationComputeDevice, currentDeepLAuthKey, getDeepLAuthKey, diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index c36b5fa7..d3452721 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -168,19 +168,22 @@ export const ROUTE_META_LIST = [ { endpoint: "/delete/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "deleteSuccessDeepLAuthKey" }, // Translation (AI Models) + { endpoint: "/get/data/selectable_ctranslate2_weight_type_dict", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadedCTranslate2WeightTypeStatus" }, { endpoint: "/get/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2WeightType" }, { endpoint: "/set/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2WeightType" }, - { endpoint: "/get/data/selectable_ctranslate2_weight_type_dict", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadedCTranslate2WeightTypeStatus" }, + { endpoint: "/get/data/ctranslate2_compute_type_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableCTranslate2ComputeTypeList_FromBackend" }, + { endpoint: "/get/data/ctranslate2_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2ComputeType" }, + { endpoint: "/set/data/ctranslate2_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2ComputeType" }, { endpoint: "/run/downloaded_ctranslate2_weight", ns: configs, hook_name: "useTranslation", method_name: "downloadedCTranslate2WeightType" }, { endpoint: "/run/download_ctranslate2_weight", ns: null, hook_name: null, method_name: null }, { endpoint: "/run/download_progress_ctranslate2_weight", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadProgressCTranslate2WeightTypeStatus" }, - { endpoint: "/get/data/translation_compute_device_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableCTranslate2ComputeDeviceList_FromBackend" }, + { endpoint: "/get/data/translation_compute_device_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableTranslationComputeDeviceList_FromBackend" }, - { endpoint: "/get/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2ComputeDevice" }, - { endpoint: "/set/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2ComputeDevice" }, + { endpoint: "/get/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeDevice" }, + { endpoint: "/set/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeDevice" }, // Transcription diff --git a/src-ui/store.js b/src-ui/store.js index e36aad46..ba00127b 100644 --- a/src-ui/store.js +++ b/src-ui/store.js @@ -218,10 +218,15 @@ export const { atomInstance: Atom_MicWordFilterList, useHook: useStore_MicWordFi // Translation export const { atomInstance: Atom_DeepLAuthKey, useHook: useStore_DeepLAuthKey } = createAtomWithHook(null, "DeepLAuthKey"); export const { atomInstance: Atom_SelectedCTranslate2WeightType, useHook: useStore_SelectedCTranslate2WeightType } = createAtomWithHook("", "SelectedCTranslate2WeightType"); -export const { atomInstance: Atom_SelectableCTranslate2ComputeDeviceList, useHook: useStore_SelectableCTranslate2ComputeDeviceList } = createAtomWithHook({}, "SelectableCTranslate2ComputeDeviceList"); -export const { atomInstance: Atom_SelectedCTranslate2ComputeDevice, useHook: useStore_SelectedCTranslate2ComputeDevice } = createAtomWithHook("", "SelectedCTranslate2ComputeDevice"); export const { atomInstance: Atom_CTranslate2WeightTypeStatus, useHook: useStore_CTranslate2WeightTypeStatus } = createAtomWithHook(ctranslate2_weight_type_status, "CTranslate2WeightTypeStatus"); +export const { atomInstance: Atom_SelectableCTranslate2ComputeTypeList, useHook: useStore_SelectableCTranslate2ComputeTypeList } = createAtomWithHook({}, "SelectableCTranslate2ComputeTypeList"); +export const { atomInstance: Atom_SelectedCTranslate2ComputeType, useHook: useStore_SelectedCTranslate2ComputeType } = createAtomWithHook("", "SelectedCTranslate2ComputeType"); + + +export const { atomInstance: Atom_SelectableTranslationComputeDeviceList, useHook: useStore_SelectableTranslationComputeDeviceList } = createAtomWithHook({}, "SelectableTranslationComputeDeviceList"); +export const { atomInstance: Atom_SelectedTranslationComputeDevice, useHook: useStore_SelectedTranslationComputeDevice } = createAtomWithHook("", "SelectedTranslationComputeDevice"); + // Transcription export const { atomInstance: Atom_MicRecordTimeout, useHook: useStore_MicRecordTimeout } = createAtomWithHook(0, "MicRecordTimeout"); export const { atomInstance: Atom_MicPhraseTimeout, useHook: useStore_MicPhraseTimeout } = createAtomWithHook(0, "MicPhraseTimeout"); From 9fd61677f9ea8fd4fd9792d1b0f484ee5bb0de06 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:58:19 +0900 Subject: [PATCH 04/11] [Update/Chore] Config Page: Add 'Whisper Compute Type' Selection. UI: Rename 'Whisper compute device' to 'Transcription compute device'. --- locales/en.yml | 6 +- locales/ja.yml | 6 +- locales/ko.yml | 6 +- locales/zh-Hans.yml | 4 +- locales/zh-Hant.yml | 4 +- .../transcription/Transcription.jsx | 53 +++++++--- .../configs/transcription/useTranscription.js | 98 ++++++++++++++----- src-ui/logics/useReceiveRoutes.js | 12 ++- src-ui/store.js | 8 +- 9 files changed, 144 insertions(+), 53 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index e96de8fb..25b04e62 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -179,8 +179,10 @@ config_page: desc: "Larger models have higher accuracy, but they also consume more CPU or GPU resources.\nEspecially for models larger than medium, it may be difficult or even impossible to use them depending on the performance of your CPU/GPU." model_template: "{{model_name}} model ({{capacity}})" recommended_model_template: "{{model_name}} model ({{capacity}}) (Recommended)" - whisper_compute_device: - label: "Processing Device Used For Whisper" + whisper_compute_type: + label: "Processing type for AI transcription {{whisper}}" + transcription_compute_device: + label: "Processing Device Used For AI transcription" vr: single_line: "Single line" diff --git a/locales/ja.yml b/locales/ja.yml index a16b6b1d..39542767 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -179,8 +179,10 @@ config_page: desc: "容量が大きいモデルほど精度は高いですが、その分CPUやGPUを占有します。\n※特にmediumより容量の大きいモデルは、CPU/GPUの性能によっては使用すらも困難です。" model_template: "{{model_name}} モデル ({{capacity}})" recommended_model_template: "{{model_name}} モデル ({{capacity}}) [推奨]" - whisper_compute_device: - label: "Whisperで使用する処理デバイス" + whisper_compute_type: + label: "AI音声認識 {{whisper}} の処理タイプ" + transcription_compute_device: + label: "AI音声認識で使用する処理デバイス" vr: single_line: "一行" diff --git a/locales/ko.yml b/locales/ko.yml index df188d5f..288c63e3 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -179,8 +179,10 @@ config_page: desc: "용량이 큰 모델일수록 정확도는 높지만, 그만큼 CPU나 GPU를 많이 차지합니다. * 특히 medium보다 용량이 큰 모델은 CPU/GPU 성능에 따라 사용 자체가 어려울 수 있습니다." model_template: "{{model_name}} 모델 ({{capacity}})" recommended_model_template: "{{model_name}} 모델 ({{capacity}}) (권장)" - whisper_compute_device: - label: "Whisper에서 사용할 처리 장치" + whisper_compute_type: + label: + transcription_compute_device: + label: vr: single_line: "한 줄" diff --git a/locales/zh-Hans.yml b/locales/zh-Hans.yml index e2bd4a14..7cfc594e 100644 --- a/locales/zh-Hans.yml +++ b/locales/zh-Hans.yml @@ -179,7 +179,9 @@ config_page: desc: model_template: "{{model_name}} 模型 ({{capacity}})" recommended_model_template: "{{model_name}} 模型 ({{capacity}}) (推荐)" - whisper_compute_device: + whisper_compute_type: + label: + transcription_compute_device: label: vr: diff --git a/locales/zh-Hant.yml b/locales/zh-Hant.yml index bc190b25..039b60ba 100644 --- a/locales/zh-Hant.yml +++ b/locales/zh-Hant.yml @@ -179,7 +179,9 @@ config_page: desc: model_template: "{{model_name}}模型({{capacity}})" recommended_model_template: "{{model_name}}模型({{capacity}})(推薦)" - whisper_compute_device: + whisper_compute_type: + label: + transcription_compute_device: label: vr: diff --git a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx index 7416c970..2e0daf92 100644 --- a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx @@ -201,7 +201,8 @@ const TranscriptionEngine_Container = () => { - + + ); }; @@ -274,46 +275,70 @@ const WhisperWeightType_Box = () => { ); }; +const WhisperComputeType_Box = () => { + const { t } = useI18n(); + const { currentSelectableWhisperComputeTypeList } = useTranscription(); + const { currentSelectedWhisperComputeType, setSelectedWhisperComputeType } = useTranscription(); + + const selectFunction = (selected_data) => { + setSelectedWhisperComputeType(selected_data.selected_id); + }; + + const whisper_compute_type_label = t("config_page.transcription.whisper_compute_type.label", { + whisper: "Whisper" + }); + + return ( + + ); +}; // Duplicate import { useComputeMode } from "@logics_common"; -const WhisperComputeDevice_Box = () => { +const TranscriptionComputeDevice_Box = () => { const { t } = useI18n(); - const { currentSelectedWhisperComputeDevice, setSelectedWhisperComputeDevice } = useTranscription(); - const { currentSelectableWhisperComputeDeviceList } = useTranscription(); + const { currentSelectedTranscriptionComputeDevice, setSelectedTranscriptionComputeDevice } = useTranscription(); + const { currentSelectableTranscriptionComputeDeviceList } = useTranscription(); const selectFunction = (selected_data) => { - const target_obj = currentSelectableWhisperComputeDeviceList.data[selected_data.selected_id]; - setSelectedWhisperComputeDevice(target_obj); + const target_obj = currentSelectableTranscriptionComputeDeviceList.data[selected_data.selected_id]; + setSelectedTranscriptionComputeDevice(target_obj); }; - const list_for_ui = transformDeviceArray(currentSelectableWhisperComputeDeviceList.data); + const list_for_ui = transformDeviceArray(currentSelectableTranscriptionComputeDeviceList.data); - const target_index = findKeyByDeviceValue(currentSelectableWhisperComputeDeviceList.data, currentSelectedWhisperComputeDevice.data); + const target_index = findKeyByDeviceValue(currentSelectableTranscriptionComputeDeviceList.data, currentSelectedTranscriptionComputeDevice.data); const { currentComputeMode } = useComputeMode(); if (currentComputeMode.data === "cpu") { return ( ) } return ( ); }; diff --git a/src-ui/logics/configs/transcription/useTranscription.js b/src-ui/logics/configs/transcription/useTranscription.js index 294b0473..4af6a28c 100644 --- a/src-ui/logics/configs/transcription/useTranscription.js +++ b/src-ui/logics/configs/transcription/useTranscription.js @@ -8,12 +8,14 @@ import { useStore_SpeakerPhraseTimeout, useStore_SpeakerRecordTimeout, - useStore_SelectableWhisperComputeDeviceList, + useStore_SelectableTranscriptionComputeDeviceList, useStore_SelectedTranscriptionEngine, - useStore_SelectedWhisperComputeDevice, - useStore_SelectedWhisperWeightType, + useStore_SelectedTranscriptionComputeDevice, useStore_WhisperWeightTypeStatus, + useStore_SelectedWhisperWeightType, + useStore_SelectedWhisperComputeType, + useStore_SelectableWhisperComputeTypeList, useStore_MicAvgLogprob, useStore_MicNoSpeechProb, @@ -21,7 +23,7 @@ import { useStore_SpeakerNoSpeechProb, } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; -import { transformToIndexedArray } from "@utils"; +import { transformToIndexedArray, arrayToObject } from "@utils"; import { useNotificationStatus } from "@logics_common"; export const useTranscription = () => { @@ -41,10 +43,16 @@ export const useTranscription = () => { // Transcription Engines const { currentSelectedTranscriptionEngine, updateSelectedTranscriptionEngine, pendingSelectedTranscriptionEngine } = useStore_SelectedTranscriptionEngine(); + const { currentWhisperWeightTypeStatus, updateWhisperWeightTypeStatus, pendingWhisperWeightTypeStatus } = useStore_WhisperWeightTypeStatus(); const { currentSelectedWhisperWeightType, updateSelectedWhisperWeightType, pendingSelectedWhisperWeightType } = useStore_SelectedWhisperWeightType(); - const { currentSelectableWhisperComputeDeviceList, updateSelectableWhisperComputeDeviceList, pendingSelectableWhisperComputeDeviceList } = useStore_SelectableWhisperComputeDeviceList(); - const { currentSelectedWhisperComputeDevice, updateSelectedWhisperComputeDevice, pendingSelectedWhisperComputeDevice } = useStore_SelectedWhisperComputeDevice(); + + + const { currentSelectableWhisperComputeTypeList, updateSelectableWhisperComputeTypeList, pendingSelectableWhisperComputeTypeList } = useStore_SelectableWhisperComputeTypeList(); + const { currentSelectedWhisperComputeType, updateSelectedWhisperComputeType, pendingSelectedWhisperComputeType } = useStore_SelectedWhisperComputeType(); + + const { currentSelectableTranscriptionComputeDeviceList, updateSelectableTranscriptionComputeDeviceList, pendingSelectableTranscriptionComputeDeviceList } = useStore_SelectableTranscriptionComputeDeviceList(); + const { currentSelectedTranscriptionComputeDevice, updateSelectedTranscriptionComputeDevice, pendingSelectedTranscriptionComputeDevice } = useStore_SelectedTranscriptionComputeDevice(); // Advanced Settings const { currentMicAvgLogprob, updateMicAvgLogprob, pendingMicAvgLogprob } = useStore_MicAvgLogprob(); @@ -246,6 +254,33 @@ export const useTranscription = () => { asyncStdoutToPython("/run/download_whisper_weight", weight_type); }; + + const getSelectableWhisperComputeTypeList = () => { + pendingSelectableWhisperComputeTypeList(); + asyncStdoutToPython("/get/data/whisper_compute_type_list"); + }; + + const updateSelectableWhisperComputeTypeList_FromBackend = (payload) => { + updateSelectableWhisperComputeTypeList(arrayToObject(payload)); + }; + + + const getSelectedWhisperComputeType = () => { + pendingSelectedWhisperComputeType(); + asyncStdoutToPython("/get/data/whisper_compute_type"); + }; + + const setSelectedWhisperComputeType = (selected_whisper_compute_type) => { + pendingSelectedWhisperComputeType(); + asyncStdoutToPython("/set/data/whisper_compute_type", selected_whisper_compute_type); + }; + + const setSuccessSelectedWhisperComputeType = (selected_whisper_compute_type) => { + updateSelectedWhisperComputeType(selected_whisper_compute_type); + showNotification_SaveSuccess(); + }; + + // Transcription Engines (Selected Weight Type) const getSelectedWhisperWeightType = () => { pendingSelectedWhisperWeightType(); @@ -263,28 +298,28 @@ export const useTranscription = () => { }; // Transcription Engines (Compute Device List) - const getSelectableWhisperComputeDeviceList = () => { - pendingSelectableWhisperComputeDeviceList(); + const getSelectableTranscriptionComputeDeviceList = () => { + pendingSelectableTranscriptionComputeDeviceList(); asyncStdoutToPython("/get/data/transcription_compute_device_list"); }; - const updateSelectableWhisperComputeDeviceList_FromBackend = (payload) => { - updateSelectableWhisperComputeDeviceList(transformToIndexedArray(payload)); + const updateSelectableTranscriptionComputeDeviceList_FromBackend = (payload) => { + updateSelectableTranscriptionComputeDeviceList(transformToIndexedArray(payload)); }; // Transcription Engines (Selected Compute Device) - const getSelectedWhisperComputeDevice = () => { - pendingSelectedWhisperComputeDevice(); + const getSelectedTranscriptionComputeDevice = () => { + pendingSelectedTranscriptionComputeDevice(); asyncStdoutToPython("/get/data/selected_transcription_compute_device"); }; - const setSelectedWhisperComputeDevice = (selected_transcription_compute_device) => { - pendingSelectedWhisperComputeDevice(); + const setSelectedTranscriptionComputeDevice = (selected_transcription_compute_device) => { + pendingSelectedTranscriptionComputeDevice(); asyncStdoutToPython("/set/data/selected_transcription_compute_device", selected_transcription_compute_device); }; - const setSuccessSelectedWhisperComputeDevice = (dev) => { - updateSelectedWhisperComputeDevice(dev); + const setSuccessSelectedTranscriptionComputeDevice = (dev) => { + updateSelectedTranscriptionComputeDevice(dev); showNotification_SaveSuccess(); }; @@ -416,16 +451,29 @@ export const useTranscription = () => { setSelectedWhisperWeightType, setSuccessSelectedWhisperWeightType, - currentSelectableWhisperComputeDeviceList, - getSelectableWhisperComputeDeviceList, - updateSelectableWhisperComputeDeviceList, - updateSelectableWhisperComputeDeviceList_FromBackend, - currentSelectedWhisperComputeDevice, - getSelectedWhisperComputeDevice, - updateSelectedWhisperComputeDevice, - setSelectedWhisperComputeDevice, - setSuccessSelectedWhisperComputeDevice, + currentSelectableWhisperComputeTypeList, + getSelectableWhisperComputeTypeList, + updateSelectableWhisperComputeTypeList, + updateSelectableWhisperComputeTypeList_FromBackend, + + currentSelectedWhisperComputeType, + getSelectedWhisperComputeType, + updateSelectedWhisperComputeType, + setSelectedWhisperComputeType, + setSuccessSelectedWhisperComputeType, + + + currentSelectableTranscriptionComputeDeviceList, + getSelectableTranscriptionComputeDeviceList, + updateSelectableTranscriptionComputeDeviceList, + updateSelectableTranscriptionComputeDeviceList_FromBackend, + + currentSelectedTranscriptionComputeDevice, + getSelectedTranscriptionComputeDevice, + updateSelectedTranscriptionComputeDevice, + setSelectedTranscriptionComputeDevice, + setSuccessSelectedTranscriptionComputeDevice, // Advanced // Mic Avg Logprob diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index d3452721..a4b92e6e 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -214,18 +214,22 @@ export const ROUTE_META_LIST = [ { endpoint: "/get/data/selected_transcription_engine", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionEngine" }, { endpoint: "/set/data/selected_transcription_engine", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionEngine" }, + { endpoint: "/get/data/selectable_whisper_weight_type_dict", ns: configs, hook_name: "useTranscription", method_name: "updateDownloadedWhisperWeightTypeStatus" }, { endpoint: "/get/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperWeightType" }, { endpoint: "/set/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperWeightType" }, - { endpoint: "/get/data/selectable_whisper_weight_type_dict", ns: configs, hook_name: "useTranscription", method_name: "updateDownloadedWhisperWeightTypeStatus" }, + { endpoint: "/get/data/whisper_compute_type_list", ns: configs, hook_name: "useTranscription", method_name: "updateSelectableWhisperComputeTypeList_FromBackend" }, + { endpoint: "/get/data/whisper_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperComputeType" }, + { endpoint: "/set/data/whisper_compute_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperComputeType" }, + { endpoint: "/run/downloaded_whisper_weight", ns: configs, hook_name: "useTranscription", method_name: "downloadedWhisperWeightType" }, { endpoint: "/run/download_whisper_weight", ns: null, hook_name: null, method_name: null }, { endpoint: "/run/download_progress_whisper_weight", ns: configs, hook_name: "useTranscription", method_name: "updateDownloadProgressWhisperWeightTypeStatus" }, - { endpoint: "/get/data/transcription_compute_device_list", ns: configs, hook_name: "useTranscription", method_name: "updateSelectableWhisperComputeDeviceList_FromBackend" }, - { endpoint: "/get/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperComputeDevice" }, - { endpoint: "/set/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperComputeDevice" }, + { endpoint: "/get/data/transcription_compute_device_list", ns: configs, hook_name: "useTranscription", method_name: "updateSelectableTranscriptionComputeDeviceList_FromBackend" }, + { endpoint: "/get/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeDevice" }, + { endpoint: "/set/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeDevice" }, // Transcription (Advanced) { endpoint: "/get/data/mic_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "updateMicAvgLogprob" }, diff --git a/src-ui/store.js b/src-ui/store.js index ba00127b..6d110bce 100644 --- a/src-ui/store.js +++ b/src-ui/store.js @@ -240,8 +240,12 @@ export const { atomInstance: Atom_SelectedWhisperWeightType, useHook: useStore_S export const { atomInstance: Atom_WhisperWeightTypeStatus, useHook: useStore_WhisperWeightTypeStatus } = createAtomWithHook(whisper_weight_type_status, "WhisperWeightTypeStatus"); export const { atomInstance: Atom_SelectedTranscriptionEngine, useHook: useStore_SelectedTranscriptionEngine } = createAtomWithHook(whisper_weight_type_status, "SelectedTranscriptionEngine"); -export const { atomInstance: Atom_SelectableWhisperComputeDeviceList, useHook: useStore_SelectableWhisperComputeDeviceList } = createAtomWithHook({}, "SelectableWhisperComputeDeviceList"); -export const { atomInstance: Atom_SelectedWhisperComputeDevice, useHook: useStore_SelectedWhisperComputeDevice } = createAtomWithHook("", "SelectedWhisperComputeDevice"); +export const { atomInstance: Atom_SelectableWhisperComputeTypeList, useHook: useStore_SelectableWhisperComputeTypeList } = createAtomWithHook({}, "SelectableWhisperComputeTypeList"); +export const { atomInstance: Atom_SelectedWhisperComputeType, useHook: useStore_SelectedWhisperComputeType } = createAtomWithHook("", "SelectedWhisperComputeType"); + + +export const { atomInstance: Atom_SelectableTranscriptionComputeDeviceList, useHook: useStore_SelectableTranscriptionComputeDeviceList } = createAtomWithHook({}, "SelectableTranscriptionComputeDeviceList"); +export const { atomInstance: Atom_SelectedTranscriptionComputeDevice, useHook: useStore_SelectedTranscriptionComputeDevice } = createAtomWithHook("", "SelectedTranscriptionComputeDevice"); export const { atomInstance: Atom_MicAvgLogprob, useHook: useStore_MicAvgLogprob } = createAtomWithHook(-0.8, "MicAvgLogprob"); export const { atomInstance: Atom_MicNoSpeechProb, useHook: useStore_MicNoSpeechProb } = createAtomWithHook(0.6, "MicNoSpeechProb"); From 9d94fd6a5e23ca35a50d55330fb2173e51489989 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Fri, 19 Sep 2025 18:09:39 +0900 Subject: [PATCH 05/11] [Update] Refactor compute type management: unify device list retrieval and remove deprecated methods --- src-python/config.py | 22 +++--------- src-python/controller.py | 12 ------- src-python/mainloop.py | 4 --- src-python/utils.py | 74 ++++++++++++++++++++++++++++++++++------ 4 files changed, 68 insertions(+), 44 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index 1a605701..bd3af244 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -11,7 +11,7 @@ from models.translation.translation_languages import translation_lang from models.translation.translation_utils import ctranslate2_weights from models.transcription.transcription_languages import transcription_lang from models.transcription.transcription_whisper import _MODELS as whisper_models -from utils import errorLogging, validateDictStructure, getComputeTypeList +from utils import errorLogging, validateDictStructure, getComputeDeviceList json_serializable_vars = {} def json_serializable(var_name): @@ -135,14 +135,6 @@ class Config: def SELECTABLE_COMPUTE_DEVICE_LIST(self): return self._SELECTABLE_COMPUTE_DEVICE_LIST - @property - def SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST(self): - return self._SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST - - @property - def SELECTABLE_WHISPER_COMPUTE_TYPE_LIST(self): - return self._SELECTABLE_WHISPER_COMPUTE_TYPE_LIST - @property def SEND_MESSAGE_BUTTON_TYPE_LIST(self): return self._SEND_MESSAGE_BUTTON_TYPE_LIST @@ -830,7 +822,7 @@ class Config: @CTRANSLATE2_COMPUTE_TYPE.setter def CTRANSLATE2_COMPUTE_TYPE(self, value): if isinstance(value, str): - if value in self.SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST: + if value in self.SELECTED_TRANSLATION_COMPUTE_DEVICE["compute_type"]: self._CTRANSLATE2_COMPUTE_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) @@ -854,7 +846,7 @@ class Config: @WHISPER_COMPUTE_TYPE.setter def WHISPER_COMPUTE_TYPE(self, value): if isinstance(value, str): - if value in self.SELECTABLE_WHISPER_COMPUTE_TYPE_LIST: + if value in self.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["compute_type"]: self._WHISPER_COMPUTE_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) @@ -1078,13 +1070,7 @@ class Config: self._SELECTABLE_TRANSCRIPTION_ENGINE_LIST = list(transcription_lang[list(transcription_lang.keys())[0]].values())[0].keys() self._SELECTABLE_UI_LANGUAGE_LIST = ["en", "ja", "ko", "zh-Hant", "zh-Hans"] self._COMPUTE_MODE = "cuda" if torch.cuda.is_available() else "cpu" - self._SELECTABLE_COMPUTE_DEVICE_LIST = [] - if torch.cuda.is_available(): - for i in range(torch.cuda.device_count()): - self._SELECTABLE_COMPUTE_DEVICE_LIST.append({"device":"cuda", "device_index": i, "device_name": torch.cuda.get_device_name(i)}) - self._SELECTABLE_COMPUTE_DEVICE_LIST.append({"device":"cpu", "device_index": 0, "device_name": "cpu"}) - self._SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST = ["auto"] + getComputeTypeList() - self._SELECTABLE_WHISPER_COMPUTE_TYPE_LIST = ["auto"] + getComputeTypeList() + self._SELECTABLE_COMPUTE_DEVICE_LIST = getComputeDeviceList() self._SEND_MESSAGE_BUTTON_TYPE_LIST = ["show", "hide", "show_and_disable_enter_key"] self._SEND_MESSAGE_FORMAT_PARTS = { "message": { diff --git a/src-python/controller.py b/src-python/controller.py index 77717918..5ea86430 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -652,14 +652,6 @@ class Controller: def getComputeDeviceList(*args, **kwargs) -> dict: return {"status":200, "result":config.SELECTABLE_COMPUTE_DEVICE_LIST} - @staticmethod - def getCTranslate2ComputeTypeList(*args, **kwargs) -> dict: - return {"status":200, "result":config.SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST} - - @staticmethod - def getWhisperComputeTypeList(*args, **kwargs) -> dict: - return {"status":200, "result":config.SELECTABLE_WHISPER_COMPUTE_TYPE_LIST} - @staticmethod def getSelectedTranslationComputeDevice(*args, **kwargs) -> dict: return {"status":200, "result":config.SELECTED_TRANSLATION_COMPUTE_DEVICE} @@ -1455,10 +1447,6 @@ class Controller: th_callback.join() return {"status":200, "result":config.CTRANSLATE2_WEIGHT_TYPE} - @staticmethod - def getCtranslate2ComputeTypeList(*args, **kwargs) -> dict: - return {"status":200, "result":config.SELECTABLE_CTRANSLATE2_COMPUTE_TYPE_LIST} - @staticmethod def getCtranslate2ComputeType(*args, **kwargs) -> dict: return {"status":200, "result":config.CTRANSLATE2_COMPUTE_TYPE} diff --git a/src-python/mainloop.py b/src-python/mainloop.py index c7b03ea6..73e75594 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -162,8 +162,6 @@ mapping = { "/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType}, "/set/data/ctranslate2_weight_type": {"status": True, "variable":controller.setCtranslate2WeightType}, - "/get/data/ctranslate2_compute_type_list": {"status": True, "variable":controller.getCtranslate2ComputeTypeList}, - "/get/data/ctranslate2_compute_type": {"status": True, "variable":controller.getCtranslate2ComputeType}, "/set/data/ctranslate2_compute_type": {"status": True, "variable":controller.setCtranslate2ComputeType}, @@ -270,8 +268,6 @@ mapping = { "/get/data/whisper_weight_type": {"status": True, "variable":controller.getWhisperWeightType}, "/set/data/whisper_weight_type": {"status": True, "variable":controller.setWhisperWeightType}, - "/get/data/whisper_compute_type_list": {"status": True, "variable":controller.getWhisperComputeTypeList}, - "/get/data/whisper_compute_type": {"status": True, "variable":controller.getWhisperComputeType}, "/set/data/whisper_compute_type": {"status": True, "variable":controller.setWhisperComputeType}, diff --git a/src-python/utils.py b/src-python/utils.py index 1b28fcf6..fab62d51 100644 --- a/src-python/utils.py +++ b/src-python/utils.py @@ -5,6 +5,7 @@ import traceback import logging from logging.handlers import RotatingFileHandler +import torch from ctranslate2 import get_supported_compute_types import requests import ipaddress @@ -78,17 +79,67 @@ def isValidIpAddress(ip_address: str) -> bool: except ValueError: return False -def getComputeTypeList() -> list: - return ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"] +def getComputeDeviceList() -> dict: + compute_types = [ + { + "device": "cpu", + "device_index": 0, + "device_name": "cpu", + "compute_types": ["auto"] + list(get_supported_compute_types("cpu", 0)), + } + ] -def getBestComputeType(device, device_index) -> str: - compute_types = get_supported_compute_types(device, device_index) - compute_types = set(compute_types) - preferred_types = getComputeTypeList() + if torch.cuda.is_available(): + for device_index in range(torch.cuda.device_count()): + gpu_device_name = torch.cuda.get_device_name(device_index) + gpu_compute_types = ["auto"] + list(get_supported_compute_types("cuda", device_index)) - for preferred_type in preferred_types: - if preferred_type in compute_types: - return preferred_type + # デバイスごとの計算タイプの制限 + if "GTX" in gpu_device_name: + unsupported_types = {"int8_bfloat16", "bfloat16", "float16", "int8"} + gpu_compute_types = [t for t in gpu_compute_types if t not in unsupported_types] + elif not any(keyword in gpu_device_name for keyword in ["RTX", "Tesla", "A100", "Quadro"]): + gpu_compute_types = ["float32"] + + compute_types.append( + { + "device": "cuda", + "device_index": device_index, + "device_name": gpu_device_name, + "compute_types": gpu_compute_types, + } + ) + + return compute_types + +def getBestComputeType(device: str, device_index: int) -> str: + compute_types = set(get_supported_compute_types(device, device_index)) + device_name = "cpu" if device == "cpu" else torch.cuda.get_device_name(device_index) + + # デバイスごとの優先計算タイプ + preferred_types = { + "default": ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"], + "GTX": ["float32"], + "RTX": ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"], + "Tesla": ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"], + "A100": ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"], + "Quadro": ["int8_bfloat16", "int8_float16", "int8", "bfloat16", "float16", "int8_float32", "float32"], + } + + # デバイス名に基づいて優先タイプを選択 + for key in preferred_types: + if key in device_name: + selected_types = preferred_types[key] + break + else: + selected_types = preferred_types["default"] + + # 利用可能な計算タイプを返す + for compute_type in selected_types: + if compute_type in compute_types: + return compute_type + + return "float32" def encodeBase64(data:str) -> dict: return json.loads(base64.b64decode(data).decode('utf-8')) @@ -178,4 +229,7 @@ def errorLogging() -> None: if error_logger is None: error_logger = setupLogger("error", "error.log", logging.ERROR) - error_logger.error(traceback.format_exc()) \ No newline at end of file + error_logger.error(traceback.format_exc()) + +if __name__ == "__main__": + print(getComputeDeviceList()) \ No newline at end of file From 92f9d645f86fa0d1b38ea940a5bc09619a380fad Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Thu, 25 Sep 2025 22:56:16 +0900 Subject: [PATCH 06/11] [Update] Refactor compute type management: rename CTranslate2 and Whisper compute types to Translation and Transcription --- src-python/config.py | 32 ++++++++++++++++---------------- src-python/controller.py | 26 ++++++++++++++++---------- src-python/mainloop.py | 8 ++++---- src-python/model.py | 6 +++--- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index bd3af244..07926324 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -815,15 +815,15 @@ class Config: self.saveConfig(inspect.currentframe().f_code.co_name, value) @property - @json_serializable('CTRANSLATE2_COMPUTE_TYPE') - def CTRANSLATE2_COMPUTE_TYPE(self): - return self._CTRANSLATE2_COMPUTE_TYPE + @json_serializable('TRANSLATION_COMPUTE_TYPE') + def TRANSLATION_COMPUTE_TYPE(self): + return self._TRANSLATION_COMPUTE_TYPE - @CTRANSLATE2_COMPUTE_TYPE.setter - def CTRANSLATE2_COMPUTE_TYPE(self, value): + @TRANSLATION_COMPUTE_TYPE.setter + def TRANSLATION_COMPUTE_TYPE(self, value): if isinstance(value, str): - if value in self.SELECTED_TRANSLATION_COMPUTE_DEVICE["compute_type"]: - self._CTRANSLATE2_COMPUTE_TYPE = value + if value in self.SELECTED_TRANSLATION_COMPUTE_DEVICE["compute_types"]: + self._TRANSLATION_COMPUTE_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) @property @@ -839,15 +839,15 @@ class Config: self.saveConfig(inspect.currentframe().f_code.co_name, value) @property - @json_serializable('WHISPER_COMPUTE_TYPE') - def WHISPER_COMPUTE_TYPE(self): - return self._WHISPER_COMPUTE_TYPE + @json_serializable('TRANSCRIPTION_COMPUTE_TYPE') + def TRANSCRIPTION_COMPUTE_TYPE(self): + return self._TRANSCRIPTION_COMPUTE_TYPE - @WHISPER_COMPUTE_TYPE.setter - def WHISPER_COMPUTE_TYPE(self, value): + @TRANSCRIPTION_COMPUTE_TYPE.setter + def TRANSCRIPTION_COMPUTE_TYPE(self, value): if isinstance(value, str): - if value in self.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["compute_type"]: - self._WHISPER_COMPUTE_TYPE = value + if value in self.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["compute_types"]: + self._TRANSCRIPTION_COMPUTE_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) @property @@ -1209,9 +1209,9 @@ class Config: self._SELECTED_TRANSLATION_COMPUTE_DEVICE = copy.deepcopy(self.SELECTABLE_COMPUTE_DEVICE_LIST[0]) self._SELECTED_TRANSCRIPTION_COMPUTE_DEVICE = copy.deepcopy(self.SELECTABLE_COMPUTE_DEVICE_LIST[0]) self._CTRANSLATE2_WEIGHT_TYPE = "small" - self._CTRANSLATE2_COMPUTE_TYPE = "auto" + self._TRANSLATION_COMPUTE_TYPE = "auto" self._WHISPER_WEIGHT_TYPE = "base" - self._WHISPER_COMPUTE_TYPE = "auto" + self._TRANSCRIPTION_COMPUTE_TYPE = "auto" self._AUTO_CLEAR_MESSAGE_BOX = True self._SEND_ONLY_TRANSLATED_MESSAGES = False self._OVERLAY_SMALL_LOG = False diff --git a/src-python/controller.py b/src-python/controller.py index 5ea86430..a746ecee 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -1437,6 +1437,7 @@ class Controller: @staticmethod def setCtranslate2WeightType(data, *args, **kwargs) -> dict: + pre_weight_type = config.CTRANSLATE2_WEIGHT_TYPE config.CTRANSLATE2_WEIGHT_TYPE = str(data) if model.checkTranslatorCTranslate2ModelWeight(config.CTRANSLATE2_WEIGHT_TYPE): def callback(): @@ -1445,15 +1446,18 @@ class Controller: th_callback.daemon = True th_callback.start() th_callback.join() + else: + config.CTRANSLATE2_WEIGHT_TYPE = pre_weight_type return {"status":200, "result":config.CTRANSLATE2_WEIGHT_TYPE} @staticmethod - def getCtranslate2ComputeType(*args, **kwargs) -> dict: - return {"status":200, "result":config.CTRANSLATE2_COMPUTE_TYPE} + def getTranslationComputeType(*args, **kwargs) -> dict: + return {"status":200, "result":config.TRANSLATION_COMPUTE_TYPE} @staticmethod - def setCtranslate2ComputeType(data, *args, **kwargs) -> dict: - config.CTRANSLATE2_COMPUTE_TYPE = str(data) + def setTranslationComputeType(data, *args, **kwargs) -> dict: + pre_compute_type = config.TRANSLATION_COMPUTE_TYPE + config.TRANSLATION_COMPUTE_TYPE = str(data) if model.checkTranslatorCTranslate2ModelWeight(config.CTRANSLATE2_WEIGHT_TYPE): def callback(): model.changeTranslatorCTranslate2Model() @@ -1461,7 +1465,9 @@ class Controller: th_callback.daemon = True th_callback.start() th_callback.join() - return {"status":200, "result":config.CTRANSLATE2_COMPUTE_TYPE} + else: + config.TRANSLATION_COMPUTE_TYPE = pre_compute_type + return {"status":200, "result":config.TRANSLATION_COMPUTE_TYPE} @staticmethod def getWhisperWeightType(*args, **kwargs) -> dict: @@ -1473,13 +1479,13 @@ class Controller: return {"status":200, "result": config.WHISPER_WEIGHT_TYPE} @staticmethod - def getWhisperComputeType(*args, **kwargs) -> dict: - return {"status":200, "result":config.WHISPER_COMPUTE_TYPE} + def getTranscriptionComputeType(*args, **kwargs) -> dict: + return {"status":200, "result":config.TRANSCRIPTION_COMPUTE_TYPE} @staticmethod - def setWhisperComputeType(data, *args, **kwargs) -> dict: - config.WHISPER_COMPUTE_TYPE = str(data) - return {"status":200, "result":config.WHISPER_COMPUTE_TYPE} + def setTranscriptionComputeType(data, *args, **kwargs) -> dict: + config.TRANSCRIPTION_COMPUTE_TYPE = str(data) + return {"status":200, "result":config.TRANSCRIPTION_COMPUTE_TYPE} @staticmethod def getSendMessageFormatParts(*args, **kwargs) -> dict: diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 73e75594..a32fef8a 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -162,8 +162,8 @@ mapping = { "/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType}, "/set/data/ctranslate2_weight_type": {"status": True, "variable":controller.setCtranslate2WeightType}, - "/get/data/ctranslate2_compute_type": {"status": True, "variable":controller.getCtranslate2ComputeType}, - "/set/data/ctranslate2_compute_type": {"status": True, "variable":controller.setCtranslate2ComputeType}, + "/get/data/translation_compute_type": {"status": True, "variable":controller.getTranslationComputeType}, + "/set/data/translation_compute_type": {"status": True, "variable":controller.setTranslationComputeType}, "/run/download_ctranslate2_weight": {"status": True, "variable":controller.downloadCtranslate2Weight}, @@ -268,8 +268,8 @@ mapping = { "/get/data/whisper_weight_type": {"status": True, "variable":controller.getWhisperWeightType}, "/set/data/whisper_weight_type": {"status": True, "variable":controller.setWhisperWeightType}, - "/get/data/whisper_compute_type": {"status": True, "variable":controller.getWhisperComputeType}, - "/set/data/whisper_compute_type": {"status": True, "variable":controller.setWhisperComputeType}, + "/get/data/transcription_compute_type": {"status": True, "variable":controller.getTranscriptionComputeType}, + "/set/data/transcription_compute_type": {"status": True, "variable":controller.setTranscriptionComputeType}, "/run/download_whisper_weight": {"status": True, "variable":controller.downloadWhisperWeight}, diff --git a/src-python/model.py b/src-python/model.py index 445b0a5e..639d375f 100644 --- a/src-python/model.py +++ b/src-python/model.py @@ -116,7 +116,7 @@ class Model: model_type=config.CTRANSLATE2_WEIGHT_TYPE, device=config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device_index"], - compute_type=config.CTRANSLATE2_COMPUTE_TYPE + compute_type=config.TRANSLATION_COMPUTE_TYPE ) def downloadCTranslate2ModelWeight(self, weight_type, callback=None, end_callback=None): @@ -440,7 +440,7 @@ class Model: whisper_weight_type=config.WHISPER_WEIGHT_TYPE, device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], - compute_type=config.WHISPER_COMPUTE_TYPE, + compute_type=config.TRANSCRIPTION_COMPUTE_TYPE, ) def sendMicTranscript(): try: @@ -624,7 +624,7 @@ class Model: whisper_weight_type=config.WHISPER_WEIGHT_TYPE, device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], - compute_type=config.WHISPER_COMPUTE_TYPE, + compute_type=config.TRANSCRIPTION_COMPUTE_TYPE, ) def sendSpeakerTranscript(): try: From 8c5f1b5db2eb04c0b211d5014b3c6fb78877d277 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 26 Sep 2025 17:07:19 +0900 Subject: [PATCH 07/11] [Update/Chore] Config Page: Put the selectors 'Compute Device' and 'Compute Type' to the same section. Rename: UI: CTranslate2/Whisper Compute Type to Translation/Transcription Compute Type. --- locales/en.yml | 4 +- locales/ja.yml | 4 +- locales/ko.yml | 4 +- locales/zh-Hans.yml | 4 +- locales/zh-Hant.yml | 4 +- .../setting_box/device/Device.jsx | 1 + .../transcription/Transcription.jsx | 124 +++++++++-------- .../transcription/Transcription.module.scss | 116 ++++++++++++++++ .../setting_box/translation/Translation.jsx | 127 +++++++++--------- .../translation/Translation.module.scss | 106 +++++++++++++++ .../configs/transcription/useTranscription.js | 48 +++---- .../configs/translation/useTranslation.js | 48 +++---- src-ui/logics/useReceiveRoutes.js | 10 +- src-ui/store.js | 10 +- 14 files changed, 402 insertions(+), 208 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 25b04e62..76cfd208 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -133,7 +133,7 @@ config_page: desc: "You can choose the translation model when using the {{ctranslate2}} translation engine." small: "Basic Model ({{capacity}})" large: "High Accuracy Model ({{capacity}})" - ctranslate2_compute_type: + translation_compute_type: label: "Processing type for AI translation {{ctranslate2}}" translation_compute_device: label: "Processing device for AI translation" @@ -179,7 +179,7 @@ config_page: desc: "Larger models have higher accuracy, but they also consume more CPU or GPU resources.\nEspecially for models larger than medium, it may be difficult or even impossible to use them depending on the performance of your CPU/GPU." model_template: "{{model_name}} model ({{capacity}})" recommended_model_template: "{{model_name}} model ({{capacity}}) (Recommended)" - whisper_compute_type: + transcription_compute_type: label: "Processing type for AI transcription {{whisper}}" transcription_compute_device: label: "Processing Device Used For AI transcription" diff --git a/locales/ja.yml b/locales/ja.yml index 39542767..ab47d45c 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -133,7 +133,7 @@ config_page: desc: "翻訳エンジン「{{ctranslate2}}」で翻訳する際に、使用する翻訳モデルを選択できます。" small: "通常モデル ({{capacity}})" large: "高精度モデル ({{capacity}})" - ctranslate2_compute_type: + translation_compute_type: label: "AI翻訳 {{ctranslate2}} の処理タイプ" translation_compute_device: label: "AI翻訳の処理デバイス" @@ -179,7 +179,7 @@ config_page: desc: "容量が大きいモデルほど精度は高いですが、その分CPUやGPUを占有します。\n※特にmediumより容量の大きいモデルは、CPU/GPUの性能によっては使用すらも困難です。" model_template: "{{model_name}} モデル ({{capacity}})" recommended_model_template: "{{model_name}} モデル ({{capacity}}) [推奨]" - whisper_compute_type: + transcription_compute_type: label: "AI音声認識 {{whisper}} の処理タイプ" transcription_compute_device: label: "AI音声認識で使用する処理デバイス" diff --git a/locales/ko.yml b/locales/ko.yml index 288c63e3..af169b93 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -133,7 +133,7 @@ config_page: desc: "오프라인 번역 시의 번역 모델을 변경합니다." small: "일반 모델 ({{capacity}})" large: "정밀 모델 ({{capacity}})" - ctranslate2_compute_type: + translation_compute_type: label: translation_compute_device: label: "AI 번역 처리 장치" @@ -179,7 +179,7 @@ config_page: desc: "용량이 큰 모델일수록 정확도는 높지만, 그만큼 CPU나 GPU를 많이 차지합니다. * 특히 medium보다 용량이 큰 모델은 CPU/GPU 성능에 따라 사용 자체가 어려울 수 있습니다." model_template: "{{model_name}} 모델 ({{capacity}})" recommended_model_template: "{{model_name}} 모델 ({{capacity}}) (권장)" - whisper_compute_type: + transcription_compute_type: label: transcription_compute_device: label: diff --git a/locales/zh-Hans.yml b/locales/zh-Hans.yml index 7cfc594e..8322c96f 100644 --- a/locales/zh-Hans.yml +++ b/locales/zh-Hans.yml @@ -133,7 +133,7 @@ config_page: desc: "可以选择用于离线翻译的翻译模型" small: "普通模型 ({{capacity}})" large: "高精度模型 ({{capacity}})" - ctranslate2_compute_type: + translation_compute_type: label: translation_compute_device: label: @@ -179,7 +179,7 @@ config_page: desc: model_template: "{{model_name}} 模型 ({{capacity}})" recommended_model_template: "{{model_name}} 模型 ({{capacity}}) (推荐)" - whisper_compute_type: + transcription_compute_type: label: transcription_compute_device: label: diff --git a/locales/zh-Hant.yml b/locales/zh-Hant.yml index 039b60ba..07b79b51 100644 --- a/locales/zh-Hant.yml +++ b/locales/zh-Hant.yml @@ -133,7 +133,7 @@ config_page: desc: "你可以選擇用於離線翻譯引擎的翻譯模型。" small: "基本模型({{capacity}})" large: "高準確率模型({{capacity}})" - ctranslate2_compute_type: + translation_compute_type: label: translation_compute_device: label: @@ -179,7 +179,7 @@ config_page: desc: model_template: "{{model_name}}模型({{capacity}})" recommended_model_template: "{{model_name}}模型({{capacity}})(推薦)" - whisper_compute_type: + transcription_compute_type: label: transcription_compute_device: label: diff --git a/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx b/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx index 28240452..ab5bff02 100644 --- a/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx @@ -53,6 +53,7 @@ const Mic_Container = () => { setSelectedMicDevice(selected_data.selected_id); }; + // [Fix me] currentEnableAutoMicSelect.data === "pending"; ? not currentEnableAutoMicSelect.state === "pending"; ??(.state) const is_disabled_selector = currentEnableAutoMicSelect.data === true || currentEnableAutoMicSelect.data === "pending"; const getLabels = () => { diff --git a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx index 2e0daf92..48639292 100644 --- a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx @@ -1,7 +1,8 @@ import { useEffect, useState } from "react"; import { useI18n } from "@useI18n"; import styles from "./Transcription.module.scss"; -import { updateLabelsById, genNumObjArray } from "@utils"; +import { updateLabelsById, genNumObjArray, arrayToObject } from "@utils"; +import { useStore_IsBreakPoint } from "@store"; import { useTranscription, @@ -12,11 +13,14 @@ import { DownloadModelsContainer, RadioButtonContainer, DropdownMenuContainer, - ComputeDeviceContainer, SliderContainer, + + useOnMouseLeaveDropdownMenu, } from "../_templates/Templates"; import { + DropdownMenu, + LabelComponent, SectionLabelComponent, } from "../_components/"; @@ -201,7 +205,6 @@ const TranscriptionEngine_Container = () => { - ); @@ -275,71 +278,76 @@ const WhisperWeightType_Box = () => { ); }; -const WhisperComputeType_Box = () => { - const { t } = useI18n(); - const { currentSelectableWhisperComputeTypeList } = useTranscription(); - const { currentSelectedWhisperComputeType, setSelectedWhisperComputeType } = useTranscription(); - const selectFunction = (selected_data) => { - setSelectedWhisperComputeType(selected_data.selected_id); - }; - - const whisper_compute_type_label = t("config_page.transcription.whisper_compute_type.label", { - whisper: "Whisper" - }); - - return ( - - ); -}; - -// Duplicate -import { useComputeMode } from "@logics_common"; const TranscriptionComputeDevice_Box = () => { const { t } = useI18n(); - const { currentSelectedTranscriptionComputeDevice, setSelectedTranscriptionComputeDevice } = useTranscription(); - const { currentSelectableTranscriptionComputeDeviceList } = useTranscription(); - - const selectFunction = (selected_data) => { - const target_obj = currentSelectableTranscriptionComputeDeviceList.data[selected_data.selected_id]; - setSelectedTranscriptionComputeDevice(target_obj); - }; + const { + currentSelectableTranscriptionComputeDeviceList, + currentSelectedTranscriptionComputeDevice, + setSelectedTranscriptionComputeDevice, + currentSelectedTranscriptionComputeType, + setSelectedTranscriptionComputeType, + } = useTranscription(); + const { onMouseLeaveFunction } = useOnMouseLeaveDropdownMenu(); + const { currentIsBreakPoint } = useStore_IsBreakPoint(); const list_for_ui = transformDeviceArray(currentSelectableTranscriptionComputeDeviceList.data); const target_index = findKeyByDeviceValue(currentSelectableTranscriptionComputeDeviceList.data, currentSelectedTranscriptionComputeDevice.data); + const selectable_compute_types = arrayToObject(currentSelectableTranscriptionComputeDeviceList.data[target_index].compute_types); - const { currentComputeMode } = useComputeMode(); - if (currentComputeMode.data === "cpu") { - return ( - - ) - } + + const selectFunction_ComputeDevice = (selected_data) => { + const target_obj = currentSelectableTranscriptionComputeDeviceList.data[selected_data.selected_id]; + setSelectedTranscriptionComputeDevice(target_obj); + }; + + const selectFunction_ComputeType = (selected_data) => { + setSelectedTranscriptionComputeType(selected_data.selected_id); + }; + + const device_container_class = clsx(styles.device_container, { + [styles.is_break_point]: currentIsBreakPoint.data, + }); + + const is_disabled_selector = currentSelectedTranscriptionComputeDevice.state === "pending" || currentSelectedTranscriptionComputeType.state === "pending"; return ( - +
+
+ +
+ +
+
+

{t("config_page.transcription.transcription_compute_device.label")}

+ +
+ +
+

{t("config_page.transcription.transcription_compute_type.label")}

+ +
+
+
+
+
); }; @@ -399,8 +407,6 @@ const Advanced_Container = () => { ); - - }; export const MicAvgLogprobContainer = () => { diff --git a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.module.scss b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.module.scss index 1170a41c..8eed1df9 100644 --- a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.module.scss +++ b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.module.scss @@ -2,4 +2,120 @@ display: flex; flex-direction: column; gap: 6.4rem; +} + + + + + + + + + + +// [Fix me] Need refactor. +.mic_container { + display: flex; + flex-direction: column; + border-bottom: solid 0.1rem var(--dark_800_color); + padding-bottom: 1rem; +} + +.speaker_container { + padding-top: 0rem; +} + +.device_container { + display: flex; + width: 100%; + justify-content: space-between; + align-items: center; + padding: 2rem; + margin-bottom: 0rem; + &.is_break_point { + flex-direction: column; + gap: 2rem; + align-items: start; + & .device_contents { + display: flex; + width: 100%; + justify-content: space-between; + padding-left: 0rem; + } + } +} + +.threshold_container { + padding: 2rem; +} + + + +.threshold_container { + display: flex; + width: 100%; + flex-direction: column; + justify-content: space-between; + align-items: center; + gap: 2rem; +} + +.threshold_switch_section { + display: flex; + width: 100%; + justify-content: space-between; + align-items: center; + flex-shrink: 0; +} + +.threshold_section { + width: 100%; +} + + + + +.device_label { + font-size: 1.8rem; +} + +.device_contents { + display: flex; + width: 100%; + justify-content: end; + padding-left: 2rem; + gap: 2rem; +} + +.device_auto_select_wrapper { + display: flex; + flex-direction: column; + gap: 1.2rem; + justify-content: center; + align-items: center; +} + +.device_dropdown_wrapper { + display: flex; + flex-direction: row; + gap: 2.8rem; +} + +.device_dropdown { + display: flex; + flex-direction: column; + gap: 0.6rem; + white-space: nowrap; + max-width: 24rem; + &.is_disabled { + pointer-events: none; + } +} + +.device_secondary_label { + padding-left: 0.2rem; + padding-right: 0.4rem; + font-size: 1.4rem; + color: var(--dark_500_color); + white-space: nowrap; } \ No newline at end of file diff --git a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx index cdb8d351..a69da769 100644 --- a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx @@ -1,7 +1,8 @@ import { useEffect, useState } from "react"; import { useI18n } from "@useI18n"; import styles from "./Translation.module.scss"; -import { updateLabelsById } from "@utils"; +import { updateLabelsById, arrayToObject } from "@utils"; +import { useStore_IsBreakPoint } from "@store"; import { useTranslation, @@ -10,15 +11,19 @@ import { import { DownloadModelsContainer, DeeplAuthKeyContainer, - DropdownMenuContainer, - ComputeDeviceContainer, + + useOnMouseLeaveDropdownMenu, } from "../_templates/Templates"; +import { + DropdownMenu, + LabelComponent, +} from "../_components/"; + export const Translation = () => { return ( <> - @@ -73,73 +78,75 @@ const CTranslate2WeightType_Box = () => { ); }; -const CTranslate2ComputeType_Box = () => { - const { t } = useI18n(); - const { currentSelectableCTranslate2ComputeTypeList } = useTranslation(); - const { currentSelectedCTranslate2ComputeType, setSelectedCTranslate2ComputeType } = useTranslation(); - - const selectFunction = (selected_data) => { - setSelectedCTranslate2ComputeType(selected_data.selected_id); - }; - - const ctranslate2_compute_type_label = t("config_page.translation.ctranslate2_compute_type.label", { - ctranslate2: "CTranslate2" - }); - - return ( - - ); -}; - -// Duplicate -import { useComputeMode } from "@logics_common"; const TranslationComputeDevice_Box = () => { const { t } = useI18n(); - const { currentSelectedTranslationComputeDevice, setSelectedTranslationComputeDevice } = useTranslation(); - const { currentSelectableTranslationComputeDeviceList } = useTranslation(); - - const selectFunction = (selected_data) => { - const target_obj = currentSelectableTranslationComputeDeviceList.data[selected_data.selected_id]; - setSelectedTranslationComputeDevice(target_obj); - }; + const { + currentSelectableTranslationComputeDeviceList, + currentSelectedTranslationComputeDevice, + setSelectedTranslationComputeDevice, + currentSelectedTranslationComputeType, + setSelectedTranslationComputeType, + } = useTranslation(); + const { onMouseLeaveFunction } = useOnMouseLeaveDropdownMenu(); + const { currentIsBreakPoint } = useStore_IsBreakPoint(); const list_for_ui = transformDeviceArray(currentSelectableTranslationComputeDeviceList.data); const target_index = findKeyByDeviceValue(currentSelectableTranslationComputeDeviceList.data, currentSelectedTranslationComputeDevice.data); + const selectable_compute_types = arrayToObject(currentSelectableTranslationComputeDeviceList.data[target_index].compute_types); - const { currentComputeMode } = useComputeMode(); - const translation_compute_device_label = t("config_page.translation.translation_compute_device.label", { - ctranslate2: "CTranslate2" + + const selectFunction_ComputeDevice = (selected_data) => { + const target_obj = currentSelectableTranslationComputeDeviceList.data[selected_data.selected_id]; + setSelectedTranslationComputeDevice(target_obj); + }; + + const selectFunction_ComputeType = (selected_data) => { + setSelectedTranslationComputeType(selected_data.selected_id); + }; + + const device_container_class = clsx(styles.device_container, { + [styles.is_break_point]: currentIsBreakPoint.data, }); - if (currentComputeMode.data === "cpu") { - return ( - - ) - } + + const is_disabled_selector = currentSelectedTranslationComputeDevice.state === "pending" || currentSelectedTranslationComputeType.state === "pending"; return ( - +
+
+ +
+ +
+
+

{t("config_page.translation.translation_compute_device.label")}

+ +
+ +
+

{t("config_page.translation.translation_compute_type.label")}

+ +
+
+
+
+
); }; diff --git a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.module.scss b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.module.scss index e69de29b..7486c466 100644 --- a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.module.scss +++ b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.module.scss @@ -0,0 +1,106 @@ +// [Fix me] Need refactor. +.mic_container { + display: flex; + flex-direction: column; + border-bottom: solid 0.1rem var(--dark_800_color); + padding-bottom: 1rem; +} + +.speaker_container { + padding-top: 0rem; +} + +.device_container { + display: flex; + width: 100%; + justify-content: space-between; + align-items: center; + padding: 2rem; + margin-bottom: 0rem; + &.is_break_point { + flex-direction: column; + gap: 2rem; + align-items: start; + & .device_contents { + display: flex; + width: 100%; + justify-content: space-between; + padding-left: 0rem; + } + } +} + +.threshold_container { + padding: 2rem; +} + + + +.threshold_container { + display: flex; + width: 100%; + flex-direction: column; + justify-content: space-between; + align-items: center; + gap: 2rem; +} + +.threshold_switch_section { + display: flex; + width: 100%; + justify-content: space-between; + align-items: center; + flex-shrink: 0; +} + +.threshold_section { + width: 100%; +} + + + + +.device_label { + font-size: 1.8rem; +} + +.device_contents { + display: flex; + width: 100%; + justify-content: end; + padding-left: 2rem; + gap: 2rem; +} + +.device_auto_select_wrapper { + display: flex; + flex-direction: column; + gap: 1.2rem; + justify-content: center; + align-items: center; +} + +.device_dropdown_wrapper { + display: flex; + flex-direction: row; + gap: 2.8rem; +} + +.device_dropdown { + display: flex; + flex-direction: column; + gap: 0.6rem; + white-space: nowrap; + max-width: 24rem; + &.is_disabled { + pointer-events: none; + } +} + +.device_secondary_label { + padding-left: 0.2rem; + padding-right: 0.4rem; + font-size: 1.4rem; + color: var(--dark_500_color); + white-space: nowrap; +} \ No newline at end of file diff --git a/src-ui/logics/configs/transcription/useTranscription.js b/src-ui/logics/configs/transcription/useTranscription.js index 4af6a28c..1511d77a 100644 --- a/src-ui/logics/configs/transcription/useTranscription.js +++ b/src-ui/logics/configs/transcription/useTranscription.js @@ -14,8 +14,7 @@ import { useStore_WhisperWeightTypeStatus, useStore_SelectedWhisperWeightType, - useStore_SelectedWhisperComputeType, - useStore_SelectableWhisperComputeTypeList, + useStore_SelectedTranscriptionComputeType, useStore_MicAvgLogprob, useStore_MicNoSpeechProb, @@ -48,8 +47,7 @@ export const useTranscription = () => { const { currentSelectedWhisperWeightType, updateSelectedWhisperWeightType, pendingSelectedWhisperWeightType } = useStore_SelectedWhisperWeightType(); - const { currentSelectableWhisperComputeTypeList, updateSelectableWhisperComputeTypeList, pendingSelectableWhisperComputeTypeList } = useStore_SelectableWhisperComputeTypeList(); - const { currentSelectedWhisperComputeType, updateSelectedWhisperComputeType, pendingSelectedWhisperComputeType } = useStore_SelectedWhisperComputeType(); + const { currentSelectedTranscriptionComputeType, updateSelectedTranscriptionComputeType, pendingSelectedTranscriptionComputeType } = useStore_SelectedTranscriptionComputeType(); const { currentSelectableTranscriptionComputeDeviceList, updateSelectableTranscriptionComputeDeviceList, pendingSelectableTranscriptionComputeDeviceList } = useStore_SelectableTranscriptionComputeDeviceList(); const { currentSelectedTranscriptionComputeDevice, updateSelectedTranscriptionComputeDevice, pendingSelectedTranscriptionComputeDevice } = useStore_SelectedTranscriptionComputeDevice(); @@ -255,28 +253,19 @@ export const useTranscription = () => { }; - const getSelectableWhisperComputeTypeList = () => { - pendingSelectableWhisperComputeTypeList(); - asyncStdoutToPython("/get/data/whisper_compute_type_list"); + + const getSelectedTranscriptionComputeType = () => { + pendingSelectedTranscriptionComputeType(); + asyncStdoutToPython("/get/data/transcription_compute_type"); }; - const updateSelectableWhisperComputeTypeList_FromBackend = (payload) => { - updateSelectableWhisperComputeTypeList(arrayToObject(payload)); + const setSelectedTranscriptionComputeType = (selected_transcription_compute_type) => { + pendingSelectedTranscriptionComputeType(); + asyncStdoutToPython("/set/data/transcription_compute_type", selected_transcription_compute_type); }; - - const getSelectedWhisperComputeType = () => { - pendingSelectedWhisperComputeType(); - asyncStdoutToPython("/get/data/whisper_compute_type"); - }; - - const setSelectedWhisperComputeType = (selected_whisper_compute_type) => { - pendingSelectedWhisperComputeType(); - asyncStdoutToPython("/set/data/whisper_compute_type", selected_whisper_compute_type); - }; - - const setSuccessSelectedWhisperComputeType = (selected_whisper_compute_type) => { - updateSelectedWhisperComputeType(selected_whisper_compute_type); + const setSuccessSelectedTranscriptionComputeType = (selected_transcription_compute_type) => { + updateSelectedTranscriptionComputeType(selected_transcription_compute_type); showNotification_SaveSuccess(); }; @@ -452,16 +441,11 @@ export const useTranscription = () => { setSuccessSelectedWhisperWeightType, - currentSelectableWhisperComputeTypeList, - getSelectableWhisperComputeTypeList, - updateSelectableWhisperComputeTypeList, - updateSelectableWhisperComputeTypeList_FromBackend, - - currentSelectedWhisperComputeType, - getSelectedWhisperComputeType, - updateSelectedWhisperComputeType, - setSelectedWhisperComputeType, - setSuccessSelectedWhisperComputeType, + currentSelectedTranscriptionComputeType, + getSelectedTranscriptionComputeType, + updateSelectedTranscriptionComputeType, + setSelectedTranscriptionComputeType, + setSuccessSelectedTranscriptionComputeType, currentSelectableTranscriptionComputeDeviceList, diff --git a/src-ui/logics/configs/translation/useTranslation.js b/src-ui/logics/configs/translation/useTranslation.js index 28ab10a4..5c3bb83e 100644 --- a/src-ui/logics/configs/translation/useTranslation.js +++ b/src-ui/logics/configs/translation/useTranslation.js @@ -1,8 +1,7 @@ import { useStore_CTranslate2WeightTypeStatus, useStore_SelectedCTranslate2WeightType, - useStore_SelectableCTranslate2ComputeTypeList, - useStore_SelectedCTranslate2ComputeType, + useStore_SelectedTranslationComputeType, useStore_SelectableTranslationComputeDeviceList, useStore_SelectedTranslationComputeDevice, useStore_DeepLAuthKey, @@ -20,8 +19,7 @@ export const useTranslation = () => { const { currentCTranslate2WeightTypeStatus, updateCTranslate2WeightTypeStatus, pendingCTranslate2WeightTypeStatus } = useStore_CTranslate2WeightTypeStatus(); const { currentSelectedCTranslate2WeightType, updateSelectedCTranslate2WeightType, pendingSelectedCTranslate2WeightType } = useStore_SelectedCTranslate2WeightType(); - const { currentSelectableCTranslate2ComputeTypeList, updateSelectableCTranslate2ComputeTypeList, pendingSelectableCTranslate2ComputeTypeList } = useStore_SelectableCTranslate2ComputeTypeList(); - const { currentSelectedCTranslate2ComputeType, updateSelectedCTranslate2ComputeType, pendingSelectedCTranslate2ComputeType } = useStore_SelectedCTranslate2ComputeType(); + const { currentSelectedTranslationComputeType, updateSelectedTranslationComputeType, pendingSelectedTranslationComputeType } = useStore_SelectedTranslationComputeType(); const { currentSelectableTranslationComputeDeviceList, updateSelectableTranslationComputeDeviceList, pendingSelectableTranslationComputeDeviceList } = useStore_SelectableTranslationComputeDeviceList(); const { currentSelectedTranslationComputeDevice, updateSelectedTranslationComputeDevice, pendingSelectedTranslationComputeDevice } = useStore_SelectedTranslationComputeDevice(); @@ -87,29 +85,18 @@ export const useTranslation = () => { }; - - const getSelectableCTranslate2ComputeTypeList = () => { - pendingSelectableCTranslate2ComputeTypeList(); - asyncStdoutToPython("/get/data/ctranslate2_compute_type_list"); + const getSelectedTranslationComputeType = () => { + pendingSelectedTranslationComputeType(); + asyncStdoutToPython("/get/data/translation_compute_type"); }; - const updateSelectableCTranslate2ComputeTypeList_FromBackend = (payload) => { - updateSelectableCTranslate2ComputeTypeList(arrayToObject(payload)); + const setSelectedTranslationComputeType = (selected_translation_compute_type) => { + pendingSelectedTranslationComputeType(); + asyncStdoutToPython("/set/data/translation_compute_type", selected_translation_compute_type); }; - - const getSelectedCTranslate2ComputeType = () => { - pendingSelectedCTranslate2ComputeType(); - asyncStdoutToPython("/get/data/ctranslate2_compute_type"); - }; - - const setSelectedCTranslate2ComputeType = (selected_ctranslate2_compute_type) => { - pendingSelectedCTranslate2ComputeType(); - asyncStdoutToPython("/set/data/ctranslate2_compute_type", selected_ctranslate2_compute_type); - }; - - const setSuccessSelectedCTranslate2ComputeType = (selected_ctranslate2_compute_type) => { - updateSelectedCTranslate2ComputeType(selected_ctranslate2_compute_type); + const setSuccessSelectedTranslationComputeType = (selected_translation_compute_type) => { + updateSelectedTranslationComputeType(selected_translation_compute_type); showNotification_SaveSuccess(); }; @@ -182,16 +169,11 @@ export const useTranslation = () => { setSuccessSelectedCTranslate2WeightType, - currentSelectableCTranslate2ComputeTypeList, - getSelectableCTranslate2ComputeTypeList, - updateSelectableCTranslate2ComputeTypeList, - updateSelectableCTranslate2ComputeTypeList_FromBackend, - - currentSelectedCTranslate2ComputeType, - getSelectedCTranslate2ComputeType, - updateSelectedCTranslate2ComputeType, - setSelectedCTranslate2ComputeType, - setSuccessSelectedCTranslate2ComputeType, + currentSelectedTranslationComputeType, + getSelectedTranslationComputeType, + updateSelectedTranslationComputeType, + setSelectedTranslationComputeType, + setSuccessSelectedTranslationComputeType, currentSelectableTranslationComputeDeviceList, diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index a4b92e6e..049697a3 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -172,9 +172,8 @@ export const ROUTE_META_LIST = [ { endpoint: "/get/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2WeightType" }, { endpoint: "/set/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2WeightType" }, - { endpoint: "/get/data/ctranslate2_compute_type_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableCTranslate2ComputeTypeList_FromBackend" }, - { endpoint: "/get/data/ctranslate2_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2ComputeType" }, - { endpoint: "/set/data/ctranslate2_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2ComputeType" }, + { endpoint: "/get/data/translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, + { endpoint: "/set/data/translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeType" }, { endpoint: "/run/downloaded_ctranslate2_weight", ns: configs, hook_name: "useTranslation", method_name: "downloadedCTranslate2WeightType" }, { endpoint: "/run/download_ctranslate2_weight", ns: null, hook_name: null, method_name: null }, @@ -218,9 +217,8 @@ export const ROUTE_META_LIST = [ { endpoint: "/get/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperWeightType" }, { endpoint: "/set/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperWeightType" }, - { endpoint: "/get/data/whisper_compute_type_list", ns: configs, hook_name: "useTranscription", method_name: "updateSelectableWhisperComputeTypeList_FromBackend" }, - { endpoint: "/get/data/whisper_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperComputeType" }, - { endpoint: "/set/data/whisper_compute_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperComputeType" }, + { endpoint: "/get/data/transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, + { endpoint: "/set/data/transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeType" }, { endpoint: "/run/downloaded_whisper_weight", ns: configs, hook_name: "useTranscription", method_name: "downloadedWhisperWeightType" }, diff --git a/src-ui/store.js b/src-ui/store.js index 6d110bce..3286b165 100644 --- a/src-ui/store.js +++ b/src-ui/store.js @@ -220,12 +220,9 @@ export const { atomInstance: Atom_DeepLAuthKey, useHook: useStore_DeepLAuthKey } export const { atomInstance: Atom_SelectedCTranslate2WeightType, useHook: useStore_SelectedCTranslate2WeightType } = createAtomWithHook("", "SelectedCTranslate2WeightType"); export const { atomInstance: Atom_CTranslate2WeightTypeStatus, useHook: useStore_CTranslate2WeightTypeStatus } = createAtomWithHook(ctranslate2_weight_type_status, "CTranslate2WeightTypeStatus"); -export const { atomInstance: Atom_SelectableCTranslate2ComputeTypeList, useHook: useStore_SelectableCTranslate2ComputeTypeList } = createAtomWithHook({}, "SelectableCTranslate2ComputeTypeList"); -export const { atomInstance: Atom_SelectedCTranslate2ComputeType, useHook: useStore_SelectedCTranslate2ComputeType } = createAtomWithHook("", "SelectedCTranslate2ComputeType"); - - export const { atomInstance: Atom_SelectableTranslationComputeDeviceList, useHook: useStore_SelectableTranslationComputeDeviceList } = createAtomWithHook({}, "SelectableTranslationComputeDeviceList"); export const { atomInstance: Atom_SelectedTranslationComputeDevice, useHook: useStore_SelectedTranslationComputeDevice } = createAtomWithHook("", "SelectedTranslationComputeDevice"); +export const { atomInstance: Atom_SelectedTranslationComputeType, useHook: useStore_SelectedTranslationComputeType } = createAtomWithHook("", "SelectedTranslationComputeType"); // Transcription export const { atomInstance: Atom_MicRecordTimeout, useHook: useStore_MicRecordTimeout } = createAtomWithHook(0, "MicRecordTimeout"); @@ -240,12 +237,9 @@ export const { atomInstance: Atom_SelectedWhisperWeightType, useHook: useStore_S export const { atomInstance: Atom_WhisperWeightTypeStatus, useHook: useStore_WhisperWeightTypeStatus } = createAtomWithHook(whisper_weight_type_status, "WhisperWeightTypeStatus"); export const { atomInstance: Atom_SelectedTranscriptionEngine, useHook: useStore_SelectedTranscriptionEngine } = createAtomWithHook(whisper_weight_type_status, "SelectedTranscriptionEngine"); -export const { atomInstance: Atom_SelectableWhisperComputeTypeList, useHook: useStore_SelectableWhisperComputeTypeList } = createAtomWithHook({}, "SelectableWhisperComputeTypeList"); -export const { atomInstance: Atom_SelectedWhisperComputeType, useHook: useStore_SelectedWhisperComputeType } = createAtomWithHook("", "SelectedWhisperComputeType"); - - export const { atomInstance: Atom_SelectableTranscriptionComputeDeviceList, useHook: useStore_SelectableTranscriptionComputeDeviceList } = createAtomWithHook({}, "SelectableTranscriptionComputeDeviceList"); export const { atomInstance: Atom_SelectedTranscriptionComputeDevice, useHook: useStore_SelectedTranscriptionComputeDevice } = createAtomWithHook("", "SelectedTranscriptionComputeDevice"); +export const { atomInstance: Atom_SelectedTranscriptionComputeType, useHook: useStore_SelectedTranscriptionComputeType } = createAtomWithHook("", "SelectedTranscriptionComputeType"); export const { atomInstance: Atom_MicAvgLogprob, useHook: useStore_MicAvgLogprob } = createAtomWithHook(-0.8, "MicAvgLogprob"); export const { atomInstance: Atom_MicNoSpeechProb, useHook: useStore_MicNoSpeechProb } = createAtomWithHook(0.6, "MicNoSpeechProb"); From 5366622fca924099609e07e7bbf4a9731cec53f3 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Fri, 26 Sep 2025 23:30:39 +0900 Subject: [PATCH 08/11] [Update] Refactor compute device management: change methods to instance methods and set compute types to "auto" --- src-python/controller.py | 12 ++++++++---- src-python/mainloop.py | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src-python/controller.py b/src-python/controller.py index a746ecee..20bfbe88 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -656,13 +656,15 @@ class Controller: def getSelectedTranslationComputeDevice(*args, **kwargs) -> dict: return {"status":200, "result":config.SELECTED_TRANSLATION_COMPUTE_DEVICE} - @staticmethod - def setSelectedTranslationComputeDevice(device:str, *args, **kwargs) -> dict: + def setSelectedTranslationComputeDevice(self, device:str, *args, **kwargs) -> dict: printLog("setSelectedTranslationComputeDevice", device) pre_device = config.SELECTED_TRANSLATION_COMPUTE_DEVICE + pre_compute_type = config.TRANSLATION_COMPUTE_TYPE config.SELECTED_TRANSLATION_COMPUTE_DEVICE = device + config.TRANSLATION_COMPUTE_TYPE = "auto" try: model.changeTranslatorCTranslate2Model() + self.run(200, self.run_mapping["translation_compute_type"], config.TRANSLATION_COMPUTE_TYPE) except Exception as e: # VRAM不足エラーの検出(デバイス切り替え時) is_vram_error, error_message = model.detectVRAMError(e) @@ -670,6 +672,7 @@ class Controller: # 前のデバイス設定に戻す printLog("VRAM error detected, reverting device setting") config.SELECTED_TRANSLATION_COMPUTE_DEVICE = pre_device + config.TRANSLATION_COMPUTE_TYPE = pre_compute_type model.changeTranslatorCTranslate2Model() else: # その他のエラーは通常通り処理 @@ -684,10 +687,11 @@ class Controller: def getSelectedTranscriptionComputeDevice(*args, **kwargs) -> dict: return {"status":200, "result":config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE} - @staticmethod - def setSelectedTranscriptionComputeDevice(device:str, *args, **kwargs) -> dict: + def setSelectedTranscriptionComputeDevice(self, device:str, *args, **kwargs) -> dict: printLog("setSelectedTranscriptionComputeDevice", device) config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE = device + config.TRANSCRIPTION_COMPUTE_TYPE = "auto" + self.run(200, self.run_mapping["transcription_compute_type"], config.TRANSCRIPTION_COMPUTE_TYPE) return {"status":200,"result":config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE} @staticmethod diff --git a/src-python/mainloop.py b/src-python/mainloop.py index a32fef8a..2df4d53e 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -48,6 +48,9 @@ run_mapping = { "selected_translation_engines":"/run/selected_translation_engines", "translation_engines":"/run/translation_engines", + "translation_compute_type":"/run/translation_compute_type", + "transcription_compute_type":"/run/transcription_compute_type", + "mic_host_list":"/run/mic_host_list", "mic_device_list":"/run/mic_device_list", "speaker_device_list":"/run/speaker_device_list", From 6effedcce2c2f349ef06b7dbb31fbed043ccac13 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Sat, 27 Sep 2025 07:07:54 +0900 Subject: [PATCH 09/11] [Update] Refactor compute type management: rename properties to 'SELECTED_TRANSLATION_COMPUTE_TYPE' and 'SELECTED_TRANSCRIPTION_COMPUTE_TYPE' --- src-python/config.py | 28 ++++++++++++++-------------- src-python/controller.py | 36 ++++++++++++++++++------------------ src-python/mainloop.py | 12 ++++++------ src-python/model.py | 6 +++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index 07926324..71e97af7 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -815,15 +815,15 @@ class Config: self.saveConfig(inspect.currentframe().f_code.co_name, value) @property - @json_serializable('TRANSLATION_COMPUTE_TYPE') - def TRANSLATION_COMPUTE_TYPE(self): - return self._TRANSLATION_COMPUTE_TYPE + @json_serializable('SELECTED_TRANSLATION_COMPUTE_TYPE') + def SELECTED_TRANSLATION_COMPUTE_TYPE(self): + return self._SELECTED_TRANSLATION_COMPUTE_TYPE - @TRANSLATION_COMPUTE_TYPE.setter - def TRANSLATION_COMPUTE_TYPE(self, value): + @SELECTED_TRANSLATION_COMPUTE_TYPE.setter + def SELECTED_TRANSLATION_COMPUTE_TYPE(self, value): if isinstance(value, str): if value in self.SELECTED_TRANSLATION_COMPUTE_DEVICE["compute_types"]: - self._TRANSLATION_COMPUTE_TYPE = value + self._SELECTED_TRANSLATION_COMPUTE_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) @property @@ -839,15 +839,15 @@ class Config: self.saveConfig(inspect.currentframe().f_code.co_name, value) @property - @json_serializable('TRANSCRIPTION_COMPUTE_TYPE') - def TRANSCRIPTION_COMPUTE_TYPE(self): - return self._TRANSCRIPTION_COMPUTE_TYPE + @json_serializable('SELECTED_TRANSCRIPTION_COMPUTE_TYPE') + def SELECTED_TRANSCRIPTION_COMPUTE_TYPE(self): + return self._SELECTED_TRANSCRIPTION_COMPUTE_TYPE - @TRANSCRIPTION_COMPUTE_TYPE.setter - def TRANSCRIPTION_COMPUTE_TYPE(self, value): + @SELECTED_TRANSCRIPTION_COMPUTE_TYPE.setter + def SELECTED_TRANSCRIPTION_COMPUTE_TYPE(self, value): if isinstance(value, str): if value in self.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["compute_types"]: - self._TRANSCRIPTION_COMPUTE_TYPE = value + self._SELECTED_TRANSCRIPTION_COMPUTE_TYPE = value self.saveConfig(inspect.currentframe().f_code.co_name, value) @property @@ -1209,9 +1209,9 @@ class Config: self._SELECTED_TRANSLATION_COMPUTE_DEVICE = copy.deepcopy(self.SELECTABLE_COMPUTE_DEVICE_LIST[0]) self._SELECTED_TRANSCRIPTION_COMPUTE_DEVICE = copy.deepcopy(self.SELECTABLE_COMPUTE_DEVICE_LIST[0]) self._CTRANSLATE2_WEIGHT_TYPE = "small" - self._TRANSLATION_COMPUTE_TYPE = "auto" + self._SELECTED_TRANSLATION_COMPUTE_TYPE = "auto" self._WHISPER_WEIGHT_TYPE = "base" - self._TRANSCRIPTION_COMPUTE_TYPE = "auto" + self._SELECTED_TRANSCRIPTION_COMPUTE_TYPE = "auto" self._AUTO_CLEAR_MESSAGE_BOX = True self._SEND_ONLY_TRANSLATED_MESSAGES = False self._OVERLAY_SMALL_LOG = False diff --git a/src-python/controller.py b/src-python/controller.py index 20bfbe88..d03ae106 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -659,12 +659,12 @@ class Controller: def setSelectedTranslationComputeDevice(self, device:str, *args, **kwargs) -> dict: printLog("setSelectedTranslationComputeDevice", device) pre_device = config.SELECTED_TRANSLATION_COMPUTE_DEVICE - pre_compute_type = config.TRANSLATION_COMPUTE_TYPE + pre_compute_type = config.SELECTED_TRANSLATION_COMPUTE_TYPE config.SELECTED_TRANSLATION_COMPUTE_DEVICE = device - config.TRANSLATION_COMPUTE_TYPE = "auto" + config.SELECTED_TRANSLATION_COMPUTE_TYPE = "auto" try: model.changeTranslatorCTranslate2Model() - self.run(200, self.run_mapping["translation_compute_type"], config.TRANSLATION_COMPUTE_TYPE) + self.run(200, self.run_mapping["selected_translation_compute_type"], config.SELECTED_TRANSLATION_COMPUTE_TYPE) except Exception as e: # VRAM不足エラーの検出(デバイス切り替え時) is_vram_error, error_message = model.detectVRAMError(e) @@ -672,7 +672,7 @@ class Controller: # 前のデバイス設定に戻す printLog("VRAM error detected, reverting device setting") config.SELECTED_TRANSLATION_COMPUTE_DEVICE = pre_device - config.TRANSLATION_COMPUTE_TYPE = pre_compute_type + config.SELECTED_TRANSLATION_COMPUTE_TYPE = pre_compute_type model.changeTranslatorCTranslate2Model() else: # その他のエラーは通常通り処理 @@ -690,8 +690,8 @@ class Controller: def setSelectedTranscriptionComputeDevice(self, device:str, *args, **kwargs) -> dict: printLog("setSelectedTranscriptionComputeDevice", device) config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE = device - config.TRANSCRIPTION_COMPUTE_TYPE = "auto" - self.run(200, self.run_mapping["transcription_compute_type"], config.TRANSCRIPTION_COMPUTE_TYPE) + config.SELECTED_TRANSCRIPTION_COMPUTE_TYPE = "auto" + self.run(200, self.run_mapping["selected_transcription_compute_type"], config.SELECTED_TRANSCRIPTION_COMPUTE_TYPE) return {"status":200,"result":config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE} @staticmethod @@ -1455,13 +1455,13 @@ class Controller: return {"status":200, "result":config.CTRANSLATE2_WEIGHT_TYPE} @staticmethod - def getTranslationComputeType(*args, **kwargs) -> dict: - return {"status":200, "result":config.TRANSLATION_COMPUTE_TYPE} + def getSelectedTranslationComputeType(*args, **kwargs) -> dict: + return {"status":200, "result":config.SELECTED_TRANSLATION_COMPUTE_TYPE} @staticmethod - def setTranslationComputeType(data, *args, **kwargs) -> dict: - pre_compute_type = config.TRANSLATION_COMPUTE_TYPE - config.TRANSLATION_COMPUTE_TYPE = str(data) + def setSelectedTranslationComputeType(data, *args, **kwargs) -> dict: + pre_compute_type = config.SELECTED_TRANSLATION_COMPUTE_TYPE + config.SELECTED_TRANSLATION_COMPUTE_TYPE = str(data) if model.checkTranslatorCTranslate2ModelWeight(config.CTRANSLATE2_WEIGHT_TYPE): def callback(): model.changeTranslatorCTranslate2Model() @@ -1470,8 +1470,8 @@ class Controller: th_callback.start() th_callback.join() else: - config.TRANSLATION_COMPUTE_TYPE = pre_compute_type - return {"status":200, "result":config.TRANSLATION_COMPUTE_TYPE} + config.SELECTED_TRANSLATION_COMPUTE_TYPE = pre_compute_type + return {"status":200, "result":config.SELECTED_TRANSLATION_COMPUTE_TYPE} @staticmethod def getWhisperWeightType(*args, **kwargs) -> dict: @@ -1483,13 +1483,13 @@ class Controller: return {"status":200, "result": config.WHISPER_WEIGHT_TYPE} @staticmethod - def getTranscriptionComputeType(*args, **kwargs) -> dict: - return {"status":200, "result":config.TRANSCRIPTION_COMPUTE_TYPE} + def getSelectedTranscriptionComputeType(*args, **kwargs) -> dict: + return {"status":200, "result":config.SELECTED_TRANSCRIPTION_COMPUTE_TYPE} @staticmethod - def setTranscriptionComputeType(data, *args, **kwargs) -> dict: - config.TRANSCRIPTION_COMPUTE_TYPE = str(data) - return {"status":200, "result":config.TRANSCRIPTION_COMPUTE_TYPE} + def setSelectedTranscriptionComputeType(data, *args, **kwargs) -> dict: + config.SELECTED_TRANSCRIPTION_COMPUTE_TYPE = str(data) + return {"status":200, "result":config.SELECTED_TRANSCRIPTION_COMPUTE_TYPE} @staticmethod def getSendMessageFormatParts(*args, **kwargs) -> dict: diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 2df4d53e..bcb808b1 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -48,8 +48,8 @@ run_mapping = { "selected_translation_engines":"/run/selected_translation_engines", "translation_engines":"/run/translation_engines", - "translation_compute_type":"/run/translation_compute_type", - "transcription_compute_type":"/run/transcription_compute_type", + "selected_translation_compute_type":"/run/selected_translation_compute_type", + "selected_transcription_compute_type":"/run/selected_transcription_compute_type", "mic_host_list":"/run/mic_host_list", "mic_device_list":"/run/mic_device_list", @@ -165,8 +165,8 @@ mapping = { "/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType}, "/set/data/ctranslate2_weight_type": {"status": True, "variable":controller.setCtranslate2WeightType}, - "/get/data/translation_compute_type": {"status": True, "variable":controller.getTranslationComputeType}, - "/set/data/translation_compute_type": {"status": True, "variable":controller.setTranslationComputeType}, + "/get/data/selected_translation_compute_type": {"status": True, "variable":controller.getSelectedTranslationComputeType}, + "/set/data/selected_translation_compute_type": {"status": True, "variable":controller.setSelectedTranslationComputeType}, "/run/download_ctranslate2_weight": {"status": True, "variable":controller.downloadCtranslate2Weight}, @@ -271,8 +271,8 @@ mapping = { "/get/data/whisper_weight_type": {"status": True, "variable":controller.getWhisperWeightType}, "/set/data/whisper_weight_type": {"status": True, "variable":controller.setWhisperWeightType}, - "/get/data/transcription_compute_type": {"status": True, "variable":controller.getTranscriptionComputeType}, - "/set/data/transcription_compute_type": {"status": True, "variable":controller.setTranscriptionComputeType}, + "/get/data/selected_transcription_compute_type": {"status": True, "variable":controller.getSelectedTranscriptionComputeType}, + "/set/data/selected_transcription_compute_type": {"status": True, "variable":controller.setSelectedTranscriptionComputeType}, "/run/download_whisper_weight": {"status": True, "variable":controller.downloadWhisperWeight}, diff --git a/src-python/model.py b/src-python/model.py index 639d375f..70687119 100644 --- a/src-python/model.py +++ b/src-python/model.py @@ -116,7 +116,7 @@ class Model: model_type=config.CTRANSLATE2_WEIGHT_TYPE, device=config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSLATION_COMPUTE_DEVICE["device_index"], - compute_type=config.TRANSLATION_COMPUTE_TYPE + compute_type=config.SELECTED_TRANSLATION_COMPUTE_TYPE ) def downloadCTranslate2ModelWeight(self, weight_type, callback=None, end_callback=None): @@ -440,7 +440,7 @@ class Model: whisper_weight_type=config.WHISPER_WEIGHT_TYPE, device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], - compute_type=config.TRANSCRIPTION_COMPUTE_TYPE, + compute_type=config.SELECTED_TRANSCRIPTION_COMPUTE_TYPE, ) def sendMicTranscript(): try: @@ -624,7 +624,7 @@ class Model: whisper_weight_type=config.WHISPER_WEIGHT_TYPE, device=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device"], device_index=config.SELECTED_TRANSCRIPTION_COMPUTE_DEVICE["device_index"], - compute_type=config.TRANSCRIPTION_COMPUTE_TYPE, + compute_type=config.SELECTED_TRANSCRIPTION_COMPUTE_TYPE, ) def sendSpeakerTranscript(): try: From e9067c05c641f41e463ce9c9c2f2047c1f39b90c Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 27 Sep 2025 07:55:45 +0900 Subject: [PATCH 10/11] [Update/Chore] UI: Compute Type: Rename and add endpoint '/run/'. --- .../logics/configs/transcription/useTranscription.js | 4 ++-- src-ui/logics/configs/translation/useTranslation.js | 4 ++-- src-ui/logics/useReceiveRoutes.js | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src-ui/logics/configs/transcription/useTranscription.js b/src-ui/logics/configs/transcription/useTranscription.js index 1511d77a..008e4b10 100644 --- a/src-ui/logics/configs/transcription/useTranscription.js +++ b/src-ui/logics/configs/transcription/useTranscription.js @@ -256,12 +256,12 @@ export const useTranscription = () => { const getSelectedTranscriptionComputeType = () => { pendingSelectedTranscriptionComputeType(); - asyncStdoutToPython("/get/data/transcription_compute_type"); + asyncStdoutToPython("/get/data/selected_transcription_compute_type"); }; const setSelectedTranscriptionComputeType = (selected_transcription_compute_type) => { pendingSelectedTranscriptionComputeType(); - asyncStdoutToPython("/set/data/transcription_compute_type", selected_transcription_compute_type); + asyncStdoutToPython("/set/data/selected_transcription_compute_type", selected_transcription_compute_type); }; const setSuccessSelectedTranscriptionComputeType = (selected_transcription_compute_type) => { diff --git a/src-ui/logics/configs/translation/useTranslation.js b/src-ui/logics/configs/translation/useTranslation.js index 5c3bb83e..ea288a02 100644 --- a/src-ui/logics/configs/translation/useTranslation.js +++ b/src-ui/logics/configs/translation/useTranslation.js @@ -87,12 +87,12 @@ export const useTranslation = () => { const getSelectedTranslationComputeType = () => { pendingSelectedTranslationComputeType(); - asyncStdoutToPython("/get/data/translation_compute_type"); + asyncStdoutToPython("/get/data/selected_translation_compute_type"); }; const setSelectedTranslationComputeType = (selected_translation_compute_type) => { pendingSelectedTranslationComputeType(); - asyncStdoutToPython("/set/data/translation_compute_type", selected_translation_compute_type); + asyncStdoutToPython("/set/data/selected_translation_compute_type", selected_translation_compute_type); }; const setSuccessSelectedTranslationComputeType = (selected_translation_compute_type) => { diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index 049697a3..bb21acfd 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -172,8 +172,9 @@ export const ROUTE_META_LIST = [ { endpoint: "/get/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2WeightType" }, { endpoint: "/set/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2WeightType" }, - { endpoint: "/get/data/translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, - { endpoint: "/set/data/translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeType" }, + { endpoint: "/run/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, + { endpoint: "/get/data/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, + { endpoint: "/set/data/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeType" }, { endpoint: "/run/downloaded_ctranslate2_weight", ns: configs, hook_name: "useTranslation", method_name: "downloadedCTranslate2WeightType" }, { endpoint: "/run/download_ctranslate2_weight", ns: null, hook_name: null, method_name: null }, @@ -217,8 +218,9 @@ export const ROUTE_META_LIST = [ { endpoint: "/get/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperWeightType" }, { endpoint: "/set/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperWeightType" }, - { endpoint: "/get/data/transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, - { endpoint: "/set/data/transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeType" }, + { endpoint: "/run/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, + { endpoint: "/get/data/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, + { endpoint: "/set/data/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeType" }, { endpoint: "/run/downloaded_whisper_weight", ns: configs, hook_name: "useTranscription", method_name: "downloadedWhisperWeightType" }, From 9a11c6ff9fdc76dd4f1876e4a1e31ef72e83481d Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 28 Sep 2025 02:07:47 +0900 Subject: [PATCH 11/11] [Update] Config Page: Compute Device/Type: Add localization and make compute types order properly. --- locales/en.yml | 17 ++-- locales/ja.yml | 17 ++-- locales/ko.yml | 17 ++-- locales/zh-Hans.yml | 17 ++-- locales/zh-Hant.yml | 17 ++-- .../_download_button/_DownloadButton.jsx | 2 +- .../transcription/Transcription.jsx | 79 +++++++++++++++++-- .../setting_box/translation/Translation.jsx | 79 +++++++++++++++++-- .../version_label/VersionLabel.jsx | 6 +- 9 files changed, 205 insertions(+), 46 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 76cfd208..dfcc1d43 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -73,8 +73,17 @@ update_modal: is_current_compute_device: "The version currently in use" config_page: - version: "Version {{version}}" - model_download_button_label: "Download" + common: + version: "Version {{version}}" + model_download_button_label: "Download" + compute_device: + desc: "The accuracy and speed of each processing type may vary depending on your machine specs, and the compatibility with calculation methods may differ from the displayed order. Please use this as a general guideline." + label_device: "Processing Device" + label_type: "Processing Type" + type_template_auto: "Automatic" + type_template_low: "{{type_name}} (Lower accuracy, faster processing)" + type_template_high: "{{type_name}} (Higher accuracy, slower processing)" + side_menu_labels: device: "Device" appearance: "Appearance" @@ -133,8 +142,6 @@ config_page: desc: "You can choose the translation model when using the {{ctranslate2}} translation engine." small: "Basic Model ({{capacity}})" large: "High Accuracy Model ({{capacity}})" - translation_compute_type: - label: "Processing type for AI translation {{ctranslate2}}" translation_compute_device: label: "Processing device for AI translation" deepl_auth_key: @@ -179,8 +186,6 @@ config_page: desc: "Larger models have higher accuracy, but they also consume more CPU or GPU resources.\nEspecially for models larger than medium, it may be difficult or even impossible to use them depending on the performance of your CPU/GPU." model_template: "{{model_name}} model ({{capacity}})" recommended_model_template: "{{model_name}} model ({{capacity}}) (Recommended)" - transcription_compute_type: - label: "Processing type for AI transcription {{whisper}}" transcription_compute_device: label: "Processing Device Used For AI transcription" diff --git a/locales/ja.yml b/locales/ja.yml index ab47d45c..46cd24aa 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -73,8 +73,17 @@ update_modal: is_current_compute_device: "現在使用中のバージョン" config_page: - version: "バージョン {{version}}" - model_download_button_label: "ダウンロード" + common: + version: "バージョン {{version}}" + model_download_button_label: "ダウンロード" + compute_device: + desc: "各処理タイプの精度・速度は、マシンスペックによって計算方法に相性があり、表示順とは異なる事があるため、大まかな目安としてください。" + label_device: "処理デバイス" + label_type: "処理タイプ" + type_template_auto: "自動" + type_template_low: "{{type_name}} (精度が悪く、処理は早い)" + type_template_high: "{{type_name}} (精度が良く、処理は遅い)" + side_menu_labels: device: "デバイス" appearance: "デザイン" @@ -133,8 +142,6 @@ config_page: desc: "翻訳エンジン「{{ctranslate2}}」で翻訳する際に、使用する翻訳モデルを選択できます。" small: "通常モデル ({{capacity}})" large: "高精度モデル ({{capacity}})" - translation_compute_type: - label: "AI翻訳 {{ctranslate2}} の処理タイプ" translation_compute_device: label: "AI翻訳の処理デバイス" deepl_auth_key: @@ -179,8 +186,6 @@ config_page: desc: "容量が大きいモデルほど精度は高いですが、その分CPUやGPUを占有します。\n※特にmediumより容量の大きいモデルは、CPU/GPUの性能によっては使用すらも困難です。" model_template: "{{model_name}} モデル ({{capacity}})" recommended_model_template: "{{model_name}} モデル ({{capacity}}) [推奨]" - transcription_compute_type: - label: "AI音声認識 {{whisper}} の処理タイプ" transcription_compute_device: label: "AI音声認識で使用する処理デバイス" diff --git a/locales/ko.yml b/locales/ko.yml index af169b93..e24cf6cb 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -73,8 +73,17 @@ update_modal: is_current_compute_device: "현재 사용 중인 버전" config_page: - version: "버전 {{version}}" - model_download_button_label: "다운로드" + common: + version: "버전 {{version}}" + model_download_button_label: "다운로드" + compute_device: + desc: + label_device: + label_type: + type_template_auto: + type_template_low: + type_template_high: + side_menu_labels: device: "장치" appearance: "모양" @@ -133,8 +142,6 @@ config_page: desc: "오프라인 번역 시의 번역 모델을 변경합니다." small: "일반 모델 ({{capacity}})" large: "정밀 모델 ({{capacity}})" - translation_compute_type: - label: translation_compute_device: label: "AI 번역 처리 장치" deepl_auth_key: @@ -179,8 +186,6 @@ config_page: desc: "용량이 큰 모델일수록 정확도는 높지만, 그만큼 CPU나 GPU를 많이 차지합니다. * 특히 medium보다 용량이 큰 모델은 CPU/GPU 성능에 따라 사용 자체가 어려울 수 있습니다." model_template: "{{model_name}} 모델 ({{capacity}})" recommended_model_template: "{{model_name}} 모델 ({{capacity}}) (권장)" - transcription_compute_type: - label: transcription_compute_device: label: diff --git a/locales/zh-Hans.yml b/locales/zh-Hans.yml index 8322c96f..1c76d6ad 100644 --- a/locales/zh-Hans.yml +++ b/locales/zh-Hans.yml @@ -73,8 +73,17 @@ update_modal: is_current_compute_device: config_page: - version: "版本 {{version}}" - model_download_button_label: + common: + version: "版本 {{version}}" + model_download_button_label: + compute_device: + desc: + label_device: + label_type: + type_template_auto: + type_template_low: + type_template_high: + side_menu_labels: device: appearance: "外观" @@ -133,8 +142,6 @@ config_page: desc: "可以选择用于离线翻译的翻译模型" small: "普通模型 ({{capacity}})" large: "高精度模型 ({{capacity}})" - translation_compute_type: - label: translation_compute_device: label: deepl_auth_key: @@ -179,8 +186,6 @@ config_page: desc: model_template: "{{model_name}} 模型 ({{capacity}})" recommended_model_template: "{{model_name}} 模型 ({{capacity}}) (推荐)" - transcription_compute_type: - label: transcription_compute_device: label: diff --git a/locales/zh-Hant.yml b/locales/zh-Hant.yml index 07b79b51..f1c59e5e 100644 --- a/locales/zh-Hant.yml +++ b/locales/zh-Hant.yml @@ -73,8 +73,17 @@ update_modal: is_current_compute_device: config_page: - version: "版本 {{version}}" - model_download_button_label: + common: + version: "版本 {{version}}" + model_download_button_label: + compute_device: + desc: + label_device: + label_type: + type_template_auto: + type_template_low: + type_template_high: + side_menu_labels: device: appearance: "外觀" @@ -133,8 +142,6 @@ config_page: desc: "你可以選擇用於離線翻譯引擎的翻譯模型。" small: "基本模型({{capacity}})" large: "高準確率模型({{capacity}})" - translation_compute_type: - label: translation_compute_device: label: deepl_auth_key: @@ -179,8 +186,6 @@ config_page: desc: model_template: "{{model_name}}模型({{capacity}})" recommended_model_template: "{{model_name}}模型({{capacity}})(推薦)" - transcription_compute_type: - label: transcription_compute_device: label: diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_download_button/_DownloadButton.jsx b/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_download_button/_DownloadButton.jsx index ac17b759..1cad4958 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_download_button/_DownloadButton.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/_components/_atoms/_download_button/_DownloadButton.jsx @@ -29,7 +29,7 @@ export const _DownloadButton = ({option, ...props}) => { className={styles.download_button} onClick={() => props.downloadStartFunction(option.id)} > -

{t("config_page.model_download_button_label")}

+

{t("config_page.common.model_download_button_label")}

); case option.update_button: diff --git a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx index 48639292..1bc5cd07 100644 --- a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx @@ -278,7 +278,7 @@ const WhisperWeightType_Box = () => { ); }; - +// Duplicate const TranscriptionComputeDevice_Box = () => { const { t } = useI18n(); const { @@ -295,8 +295,72 @@ const TranscriptionComputeDevice_Box = () => { const target_index = findKeyByDeviceValue(currentSelectableTranscriptionComputeDeviceList.data, currentSelectedTranscriptionComputeDevice.data); - const selectable_compute_types = arrayToObject(currentSelectableTranscriptionComputeDeviceList.data[target_index].compute_types); + const DEFAULT_ORDER = [ + "auto", + "int8", + "int8_bfloat16", + "int8_float16", + "int8_float32", + "bfloat16", + "float16", + "int16", + "float32" + ]; + const sortComputeTypesArray = (compute_types_array = [], order) => { + const src_set = new Set(compute_types_array); + + const from_order = order.filter((id) => src_set.has(id)); + + const invalid_ids = compute_types_array.filter((id) => !order.includes(id)); + if (invalid_ids.length > 0) { + console.error("[sortComputeTypesArray] Unsupported compute types ignored:", invalid_ids); + } + + return from_order; + }; + + + const buildSimpleLabels = (ordered_array = []) => { + const n = ordered_array.length; + if (n === 0) return {}; + + const labels = {}; + + ordered_array.forEach((id, idx) => { + if (idx === 0 && id === "auto") { + labels[id] = t("config_page.common.compute_device.type_template_auto"); + return; + } + + if (idx === 1) { + labels[id] = t( + "config_page.common.compute_device.type_template_low", + { type_name: id } + ); + return; + } + + if (idx === n - 1) { + labels[id] = t( + "config_page.common.compute_device.type_template_high", + { type_name: id } + ); + return; + } + + labels[id] = id; + }); + + return labels; + }; + + + const computeTypesArray = currentSelectableTranscriptionComputeDeviceList.data[target_index].compute_types; + + const ordered_array = sortComputeTypesArray(computeTypesArray, DEFAULT_ORDER); + + const new_compute_types_labels = buildSimpleLabels(ordered_array); const selectFunction_ComputeDevice = (selected_data) => { const target_obj = currentSelectableTranscriptionComputeDeviceList.data[selected_data.selected_id]; @@ -316,12 +380,15 @@ const TranscriptionComputeDevice_Box = () => { return (
- +
-

{t("config_page.transcription.transcription_compute_device.label")}

+

{t("config_page.common.compute_device.label_device")}

{
-

{t("config_page.transcription.transcription_compute_type.label")}

+

{t("config_page.common.compute_device.label_type")}

{ ); }; - +// Duplicate const TranslationComputeDevice_Box = () => { const { t } = useI18n(); const { @@ -94,8 +94,72 @@ const TranslationComputeDevice_Box = () => { const target_index = findKeyByDeviceValue(currentSelectableTranslationComputeDeviceList.data, currentSelectedTranslationComputeDevice.data); - const selectable_compute_types = arrayToObject(currentSelectableTranslationComputeDeviceList.data[target_index].compute_types); + const DEFAULT_ORDER = [ + "auto", + "int8", + "int8_bfloat16", + "int8_float16", + "int8_float32", + "bfloat16", + "float16", + "int16", + "float32" + ]; + const sortComputeTypesArray = (compute_types_array = [], order) => { + const src_set = new Set(compute_types_array); + + const from_order = order.filter((id) => src_set.has(id)); + + const invalid_ids = compute_types_array.filter((id) => !order.includes(id)); + if (invalid_ids.length > 0) { + console.error("[sortComputeTypesArray] Unsupported compute types ignored:", invalid_ids); + } + + return from_order; + }; + + + const buildSimpleLabels = (ordered_array = []) => { + const n = ordered_array.length; + if (n === 0) return {}; + + const labels = {}; + + ordered_array.forEach((id, idx) => { + if (idx === 0 && id === "auto") { + labels[id] = t("config_page.common.compute_device.type_template_auto"); + return; + } + + if (idx === 1) { + labels[id] = t( + "config_page.common.compute_device.type_template_low", + { type_name: id } + ); + return; + } + + if (idx === n - 1) { + labels[id] = t( + "config_page.common.compute_device.type_template_high", + { type_name: id } + ); + return; + } + + labels[id] = id; + }); + + return labels; + }; + + + const computeTypesArray = currentSelectableTranslationComputeDeviceList.data[target_index].compute_types; + + const ordered_array = sortComputeTypesArray(computeTypesArray, DEFAULT_ORDER); + + const new_compute_types_labels = buildSimpleLabels(ordered_array); const selectFunction_ComputeDevice = (selected_data) => { const target_obj = currentSelectableTranslationComputeDeviceList.data[selected_data.selected_id]; @@ -115,12 +179,15 @@ const TranslationComputeDevice_Box = () => { return (
- +
-

{t("config_page.translation.translation_compute_device.label")}

+

{t("config_page.common.compute_device.label_device")}

{
-

{t("config_page.translation.translation_compute_type.label")}

+

{t("config_page.common.compute_device.label_type")}

{ const { currentComputeMode } = useComputeMode(); const version_label = currentComputeMode.data === "cpu" - ? t("config_page.version", { version: currentSoftwareVersion.data }) + ? t("config_page.common.version", { version: currentSoftwareVersion.data }) : currentComputeMode.data === "cuda" - ? t("config_page.version", { version: currentSoftwareVersion.data }) + " CUDA" - : t("config_page.version", { version: currentSoftwareVersion.data }); + ? t("config_page.common.version", { version: currentSoftwareVersion.data }) + " CUDA" + : t("config_page.common.version", { version: currentSoftwareVersion.data }); const is_cpu = currentComputeMode.data === "cpu";