[Refactor] Config Window: Transcription tab. whisper関係の文言をi18nを使って呼び出す部分、重複した部分が多いのでリファクタリング。

This commit is contained in:
Sakamoto Shiina
2024-02-08 04:31:27 +09:00
parent ea10573a3d
commit c459b97ca3
3 changed files with 18 additions and 22 deletions

View File

@@ -195,14 +195,8 @@ config_window:
whisper_weight_type:
label: Select Whisper Model
desc: Generally, models with larger capacity tend to have higher accuracy, but this also results in longer transcription times and increased CPU usage. Please refer to the documentation for explanations of each model.
tiny: "tiny model (%{capacity})"
base: "base model (%{capacity}) (Recommended)"
small: "small model (%{capacity})"
medium: "medium model (%{capacity})"
large_v1: "large_v1 model (%{capacity})"
large_v2: "large_v2 model (%{capacity})"
large_v3: "large_v3 model (%{capacity})"
model_template: "%{model_name} model (%{capacity})"
recommended_model_template: "%{model_name} model (%{capacity}) (Recommended)"
auto_clear_the_message_box:
label: Auto Clear The Message Box

View File

@@ -192,13 +192,8 @@ config_window:
whisper_weight_type:
label: Whisperモデルのタイプ
desc: 基本的に、容量が多いモデルほど精度は高いですが、文字起こしまでの時間が伸び、CPU使用率も増加します。各モデルの説明はドキュメントをご覧ください。
tiny: "tiny モデル (%{capacity})"
base: "base モデル (%{capacity}) (推奨)"
small: "small モデル (%{capacity})"
medium: "medium モデル (%{capacity})"
large_v1: "large_v1 モデル (%{capacity})"
large_v2: "large_v2 モデル (%{capacity})"
large_v3: "large_v3 モデル (%{capacity})"
model_template: "%{model_name} モデル (%{capacity})"
recommended_model_template: "%{model_name} モデル (%{capacity}) (推奨)"
auto_clear_the_message_box:

21
view.py
View File

@@ -952,14 +952,21 @@ class View():
@staticmethod
def getSelectableWhisperWeightTypeDict():
def callI18n(model_name, capacity, is_recommended=False):
if is_recommended is True:
return i18n.t("config_window.whisper_weight_type.recommended_model_template", model_name=model_name, capacity=capacity)
else:
return i18n.t("config_window.whisper_weight_type.model_template", model_name=model_name, capacity=capacity)
DICT_DATA = config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT
return {
config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT["tiny"]: i18n.t("config_window.whisper_weight_type.tiny", capacity="74.5MB"),
config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT["base"]: i18n.t("config_window.whisper_weight_type.base", capacity="141MB"),
config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT["small"]: i18n.t("config_window.whisper_weight_type.small", capacity="463MB"),
config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT["medium"]: i18n.t("config_window.whisper_weight_type.medium", capacity="1.42GB"),
config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT["large-v1"]: i18n.t("config_window.whisper_weight_type.large_v1", capacity="2.87GB"),
config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT["large-v2"]: i18n.t("config_window.whisper_weight_type.large_v2", capacity="2.87GB"),
config.SELECTABLE_WHISPER_WEIGHT_TYPE_DICT["large-v3"]: i18n.t("config_window.whisper_weight_type.large_v3", capacity="2.87GB"),
DICT_DATA["tiny"]: callI18n("tiny", "74.5MB"),
DICT_DATA["base"]: callI18n("base", "141MB", True),
DICT_DATA["small"]: callI18n("small", "463MB"),
DICT_DATA["medium"]: callI18n("medium", "1.42GB"),
DICT_DATA["large-v1"]: callI18n("large-v1", "2.87GB"),
DICT_DATA["large-v2"]: callI18n("large-v2", "2.87GB"),
DICT_DATA["large-v3"]: callI18n("large-v3", "2.87GB"),
}
# Open Webpage Functions