From dfb08a96bbf143b5208863928d41e3db238c0ade Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 22 Oct 2025 12:04:05 +0900 Subject: [PATCH] [Refactor/TMP2] Refactor UI components and connect to backend APIs. (Translation, Transcription models) --- .../transcription/Transcription.jsx | 19 ++++--------- .../setting_box/translation/Translation.jsx | 14 ++++++---- .../DownloadModelsContainer.jsx | 6 ++-- src-ui/ui_configs.js | 28 ++++++++++--------- 4 files changed, 32 insertions(+), 35 deletions(-) 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 11eb9818..e4a7aea2 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 @@ -246,19 +246,12 @@ const WhisperWeightType_Box = () => { downloadWhisperWeightTypeStatus(id); }; - const new_labels = [ - { id: "tiny", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "tiny", capacity: "74.5MB"}) }, - { id: "base", label: t("config_page.transcription.whisper_weight_type.recommended_model_template", {model_name: "base", capacity: "141MB"}) }, - { id: "small", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "small", capacity: "463MB"}) }, - { id: "medium", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "medium", capacity: "1.42GB"}) }, - { id: "large-v1", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v1", capacity: "2.87GB"}) }, - { id: "large-v2", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v2", capacity: "2.87GB"}) }, - { id: "large-v3", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v3", capacity: "2.87GB"}) }, - { id: "large-v3-turbo-int8", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v3-turbo-int8", capacity: "794MB"}) }, - { id: "large-v3-turbo", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v3-turbo", capacity: "1.58GB"}) }, - ]; - - const whisper_weight_types = updateLabelsById(currentWhisperWeightTypeStatus.data, new_labels); + const whisper_weight_types = currentWhisperWeightTypeStatus.data.map(item => { + return { + ...item, + label: `${item.id} (${item.capacity})`, + }; + }); return ( <> 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 3b142b6a..ead351d6 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 @@ -50,12 +50,14 @@ const CTranslate2WeightType_Box = () => { downloadCTranslate2WeightTypeStatus(id); }; - const new_labels = [ - { id: "small", label: t("config_page.translation.ctranslate2_weight_type.small", {capacity: "418MB"}) }, - { id: "large", label: t("config_page.translation.ctranslate2_weight_type.large", {capacity: "1.2GB"}) }, - ]; - const c_translate2_weight_types = updateLabelsById(currentCTranslate2WeightTypeStatus.data, new_labels); + const c_translate2_weight_types_object = currentCTranslate2WeightTypeStatus.data.map(item => { + return { + ...item, + label: `${item.id} (${item.capacity})`, + }; + }); + return ( <> @@ -69,7 +71,7 @@ const CTranslate2WeightType_Box = () => { {ctranslate2: "CTranslate2"} )} name="ctranslate2_weight_type" - options={c_translate2_weight_types} + options={c_translate2_weight_types_object} checked_variable={currentSelectedCTranslate2WeightType} selectFunction={selectFunction} downloadStartFunction={downloadStartFunction} diff --git a/src-ui/app/others/splash_component/download_models_container/DownloadModelsContainer.jsx b/src-ui/app/others/splash_component/download_models_container/DownloadModelsContainer.jsx index 9f1768f1..312d7399 100644 --- a/src-ui/app/others/splash_component/download_models_container/DownloadModelsContainer.jsx +++ b/src-ui/app/others/splash_component/download_models_container/DownloadModelsContainer.jsx @@ -11,7 +11,7 @@ export const DownloadModelsContainer = () => { const { currentCTranslate2WeightTypeStatus } = useTranslation(); const { currentWhisperWeightTypeStatus } = useTranscription(); - const c_translate_2 = currentCTranslate2WeightTypeStatus.data.find(d => d.id === "small"); + const c_translate_2 = currentCTranslate2WeightTypeStatus.data.find(d => d.id === "m2m100_418M-ct2-int8"); const whisper = currentWhisperWeightTypeStatus.data.find(d => d.id === "base"); if (c_translate_2.progress === null && whisper.progress === null) return null; @@ -19,8 +19,8 @@ export const DownloadModelsContainer = () => { return (