Merge branch 'bugfix_compute_type' into develop

This commit is contained in:
Sakamoto Shiina
2025-09-28 02:10:23 +09:00
24 changed files with 861 additions and 192 deletions

View File

@@ -29,7 +29,7 @@ export const _DownloadButton = ({option, ...props}) => {
className={styles.download_button}
onClick={() => props.downloadStartFunction(option.id)}
>
<p className={styles.download_button_label}>{t("config_page.model_download_button_label")}</p>
<p className={styles.download_button_label}>{t("config_page.common.model_download_button_label")}</p>
</button>
);
case option.update_button:

View File

@@ -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 = () => {

View File

@@ -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,7 @@ const TranscriptionEngine_Container = () => {
<SectionLabelComponent label={t("config_page.transcription.section_label_transcription_engines")} />
<TranscriptionEngine_Box />
<WhisperWeightType_Box />
<WhisperComputeDevice_Box />
<TranscriptionComputeDevice_Box />
</div>
);
};
@@ -274,47 +278,143 @@ const WhisperWeightType_Box = () => {
);
};
// Duplicate
import { useComputeMode } from "@logics_common";
const WhisperComputeDevice_Box = () => {
const TranscriptionComputeDevice_Box = () => {
const { t } = useI18n();
const { currentSelectedWhisperComputeDevice, setSelectedWhisperComputeDevice } = useTranscription();
const { currentSelectableWhisperComputeDeviceList } = useTranscription();
const {
currentSelectableTranscriptionComputeDeviceList,
currentSelectedTranscriptionComputeDevice,
setSelectedTranscriptionComputeDevice,
currentSelectedTranscriptionComputeType,
setSelectedTranscriptionComputeType,
} = useTranscription();
const { onMouseLeaveFunction } = useOnMouseLeaveDropdownMenu();
const { currentIsBreakPoint } = useStore_IsBreakPoint();
const selectFunction = (selected_data) => {
const target_obj = currentSelectableWhisperComputeDeviceList.data[selected_data.selected_id];
setSelectedWhisperComputeDevice(target_obj);
const list_for_ui = transformDeviceArray(currentSelectableTranscriptionComputeDeviceList.data);
const target_index = findKeyByDeviceValue(currentSelectableTranscriptionComputeDeviceList.data, currentSelectedTranscriptionComputeDevice.data);
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 list_for_ui = transformDeviceArray(currentSelectableWhisperComputeDeviceList.data);
const target_index = findKeyByDeviceValue(currentSelectableWhisperComputeDeviceList.data, currentSelectedWhisperComputeDevice.data);
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 { currentComputeMode } = useComputeMode();
if (currentComputeMode.data === "cpu") {
return (
<ComputeDeviceContainer
label={t("config_page.transcription.whisper_compute_device.label")}
selected_id={target_index}
list={list_for_ui}
selectFunction={selectFunction}
state={currentSelectedWhisperComputeDevice.state}
/>
)
}
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];
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 (
<DropdownMenuContainer
dropdown_id="whisper_compute_device"
label={t("config_page.transcription.whisper_compute_device.label")}
// desc={t("config_page.transcription.whisper_compute_device.label")}
selected_id={target_index}
list={list_for_ui}
selectFunction={selectFunction}
state={currentSelectedWhisperComputeDevice.state}
/>
<div className={styles.mic_container}>
<div className={device_container_class} onMouseLeave={onMouseLeaveFunction}>
<LabelComponent
label={t("config_page.transcription.transcription_compute_device.label")}
desc={t("config_page.common.compute_device.desc")}
/>
<div className={styles.device_contents}>
<div className={styles.device_dropdown_wrapper}>
<div className={styles.device_dropdown}>
<p className={styles.device_secondary_label}>{t("config_page.common.compute_device.label_device")}</p>
<DropdownMenu
dropdown_id="transcription_compute_device"
selected_id={target_index}
list={list_for_ui}
selectFunction={selectFunction_ComputeDevice}
state={currentSelectedTranscriptionComputeDevice.state}
style={{ maxWidth: "20rem", minWidth: "10rem" }}
is_disabled={is_disabled_selector}
/>
</div>
<div className={styles.device_dropdown}>
<p className={styles.device_secondary_label}>{t("config_page.common.compute_device.label_type")}</p>
<DropdownMenu
dropdown_id="transcription_compute_type"
selected_id={currentSelectedTranscriptionComputeType.data}
list={new_compute_types_labels}
selectFunction={selectFunction_ComputeType}
state={currentSelectedTranscriptionComputeType.state}
is_disabled={is_disabled_selector}
/>
</div>
</div>
</div>
</div>
</div>
);
};
@@ -374,8 +474,6 @@ const Advanced_Container = () => {
<SpeakerNoSpeechProbContainer />
</div>
);
};
export const MicAvgLogprobContainer = () => {

View File

@@ -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;
}

View File

@@ -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,20 @@ import {
import {
DownloadModelsContainer,
DeeplAuthKeyContainer,
DropdownMenuContainer,
ComputeDeviceContainer,
useOnMouseLeaveDropdownMenu,
} from "../_templates/Templates";
import {
DropdownMenu,
LabelComponent,
} from "../_components/";
export const Translation = () => {
return (
<>
<CTranslate2WeightType_Box />
<CTranslation2ComputeDevice_Box />
<TranslationComputeDevice_Box />
<DeeplAuthKey_Box />
</>
);
@@ -62,7 +68,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}
@@ -71,49 +77,143 @@ const CTranslate2WeightType_Box = () => {
</>
);
};
// Duplicate
import { useComputeMode } from "@logics_common";
const CTranslation2ComputeDevice_Box = () => {
const TranslationComputeDevice_Box = () => {
const { t } = useI18n();
const { currentSelectedCTranslate2ComputeDevice, setSelectedCTranslate2ComputeDevice } = useTranslation();
const { currentSelectableCTranslate2ComputeDeviceList } = useTranslation();
const {
currentSelectableTranslationComputeDeviceList,
currentSelectedTranslationComputeDevice,
setSelectedTranslationComputeDevice,
currentSelectedTranslationComputeType,
setSelectedTranslationComputeType,
} = useTranslation();
const { onMouseLeaveFunction } = useOnMouseLeaveDropdownMenu();
const { currentIsBreakPoint } = useStore_IsBreakPoint();
const selectFunction = (selected_data) => {
const target_obj = currentSelectableCTranslate2ComputeDeviceList.data[selected_data.selected_id];
setSelectedCTranslate2ComputeDevice(target_obj);
const list_for_ui = transformDeviceArray(currentSelectableTranslationComputeDeviceList.data);
const target_index = findKeyByDeviceValue(currentSelectableTranslationComputeDeviceList.data, currentSelectedTranslationComputeDevice.data);
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 list_for_ui = transformDeviceArray(currentSelectableCTranslate2ComputeDeviceList.data);
const target_index = findKeyByDeviceValue(currentSelectableCTranslate2ComputeDeviceList.data, currentSelectedCTranslate2ComputeDevice.data);
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 { currentComputeMode } = useComputeMode();
const ctranslate2_compute_device_label = t("config_page.translation.ctranslate2_compute_device.label", {
ctranslate2: "Ctranslate2"
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];
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 (
<ComputeDeviceContainer
label={ctranslate2_compute_device_label}
selected_id={target_index}
list={list_for_ui}
selectFunction={selectFunction}
state={currentSelectedCTranslate2ComputeDevice.state}
/>
)
}
const is_disabled_selector = currentSelectedTranslationComputeDevice.state === "pending" || currentSelectedTranslationComputeType.state === "pending";
return (
<DropdownMenuContainer
dropdown_id="ctranslate2_compute_device"
label={ctranslate2_compute_device_label}
selected_id={target_index}
list={list_for_ui}
selectFunction={selectFunction}
state={currentSelectedCTranslate2ComputeDevice.state}
/>
<div className={styles.mic_container}>
<div className={device_container_class} onMouseLeave={onMouseLeaveFunction}>
<LabelComponent
label={t("config_page.translation.translation_compute_device.label")}
desc={t("config_page.common.compute_device.desc")}
/>
<div className={styles.device_contents}>
<div className={styles.device_dropdown_wrapper}>
<div className={styles.device_dropdown}>
<p className={styles.device_secondary_label}>{t("config_page.common.compute_device.label_device")}</p>
<DropdownMenu
dropdown_id="translation_compute_device"
selected_id={target_index}
list={list_for_ui}
selectFunction={selectFunction_ComputeDevice}
state={currentSelectedTranslationComputeDevice.state}
style={{ maxWidth: "20rem", minWidth: "10rem" }}
is_disabled={is_disabled_selector}
/>
</div>
<div className={styles.device_dropdown}>
<p className={styles.device_secondary_label}>{t("config_page.common.compute_device.label_type")}</p>
<DropdownMenu
dropdown_id="translation_compute_type"
selected_id={currentSelectedTranslationComputeType.data}
list={new_compute_types_labels}
selectFunction={selectFunction_ComputeType}
state={currentSelectedTranslationComputeType.state}
is_disabled={is_disabled_selector}
/>
</div>
</div>
</div>
</div>
</div>
);
};

View File

@@ -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;
}

View File

@@ -15,10 +15,10 @@ export const VersionLabel = () => {
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";

View File

@@ -8,12 +8,13 @@ import {
useStore_SpeakerPhraseTimeout,
useStore_SpeakerRecordTimeout,
useStore_SelectableWhisperComputeDeviceList,
useStore_SelectableTranscriptionComputeDeviceList,
useStore_SelectedTranscriptionEngine,
useStore_SelectedWhisperComputeDevice,
useStore_SelectedWhisperWeightType,
useStore_SelectedTranscriptionComputeDevice,
useStore_WhisperWeightTypeStatus,
useStore_SelectedWhisperWeightType,
useStore_SelectedTranscriptionComputeType,
useStore_MicAvgLogprob,
useStore_MicNoSpeechProb,
@@ -21,7 +22,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 +42,15 @@ 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 { currentSelectedTranscriptionComputeType, updateSelectedTranscriptionComputeType, pendingSelectedTranscriptionComputeType } = useStore_SelectedTranscriptionComputeType();
const { currentSelectableTranscriptionComputeDeviceList, updateSelectableTranscriptionComputeDeviceList, pendingSelectableTranscriptionComputeDeviceList } = useStore_SelectableTranscriptionComputeDeviceList();
const { currentSelectedTranscriptionComputeDevice, updateSelectedTranscriptionComputeDevice, pendingSelectedTranscriptionComputeDevice } = useStore_SelectedTranscriptionComputeDevice();
// Advanced Settings
const { currentMicAvgLogprob, updateMicAvgLogprob, pendingMicAvgLogprob } = useStore_MicAvgLogprob();
@@ -246,6 +252,24 @@ export const useTranscription = () => {
asyncStdoutToPython("/run/download_whisper_weight", weight_type);
};
const getSelectedTranscriptionComputeType = () => {
pendingSelectedTranscriptionComputeType();
asyncStdoutToPython("/get/data/selected_transcription_compute_type");
};
const setSelectedTranscriptionComputeType = (selected_transcription_compute_type) => {
pendingSelectedTranscriptionComputeType();
asyncStdoutToPython("/set/data/selected_transcription_compute_type", selected_transcription_compute_type);
};
const setSuccessSelectedTranscriptionComputeType = (selected_transcription_compute_type) => {
updateSelectedTranscriptionComputeType(selected_transcription_compute_type);
showNotification_SaveSuccess();
};
// Transcription Engines (Selected Weight Type)
const getSelectedWhisperWeightType = () => {
pendingSelectedWhisperWeightType();
@@ -263,28 +287,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 +440,24 @@ export const useTranscription = () => {
setSelectedWhisperWeightType,
setSuccessSelectedWhisperWeightType,
currentSelectableWhisperComputeDeviceList,
getSelectableWhisperComputeDeviceList,
updateSelectableWhisperComputeDeviceList,
updateSelectableWhisperComputeDeviceList_FromBackend,
currentSelectedWhisperComputeDevice,
getSelectedWhisperComputeDevice,
updateSelectedWhisperComputeDevice,
setSelectedWhisperComputeDevice,
setSuccessSelectedWhisperComputeDevice,
currentSelectedTranscriptionComputeType,
getSelectedTranscriptionComputeType,
updateSelectedTranscriptionComputeType,
setSelectedTranscriptionComputeType,
setSuccessSelectedTranscriptionComputeType,
currentSelectableTranscriptionComputeDeviceList,
getSelectableTranscriptionComputeDeviceList,
updateSelectableTranscriptionComputeDeviceList,
updateSelectableTranscriptionComputeDeviceList_FromBackend,
currentSelectedTranscriptionComputeDevice,
getSelectedTranscriptionComputeDevice,
updateSelectedTranscriptionComputeDevice,
setSelectedTranscriptionComputeDevice,
setSuccessSelectedTranscriptionComputeDevice,
// Advanced
// Mic Avg Logprob

View File

@@ -1,13 +1,14 @@
import {
useStore_CTranslate2WeightTypeStatus,
useStore_SelectedCTranslate2WeightType,
useStore_SelectableCTranslate2ComputeDeviceList,
useStore_SelectedCTranslate2ComputeDevice,
useStore_SelectedTranslationComputeType,
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 +18,12 @@ 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 { currentSelectedTranslationComputeType, updateSelectedTranslationComputeType, pendingSelectedTranslationComputeType } = useStore_SelectedTranslationComputeType();
const { currentSelectableTranslationComputeDeviceList, updateSelectableTranslationComputeDeviceList, pendingSelectableTranslationComputeDeviceList } = useStore_SelectableTranslationComputeDeviceList();
const { currentSelectedTranslationComputeDevice, updateSelectedTranslationComputeDevice, pendingSelectedTranslationComputeDevice } = useStore_SelectedTranslationComputeDevice();
const { currentDeepLAuthKey, updateDeepLAuthKey, pendingDeepLAuthKey } = useStore_DeepLAuthKey();
@@ -80,28 +85,45 @@ export const useTranslation = () => {
};
const getSelectableCTranslate2ComputeDeviceList = () => {
pendingSelectableCTranslate2ComputeDeviceList();
const getSelectedTranslationComputeType = () => {
pendingSelectedTranslationComputeType();
asyncStdoutToPython("/get/data/selected_translation_compute_type");
};
const setSelectedTranslationComputeType = (selected_translation_compute_type) => {
pendingSelectedTranslationComputeType();
asyncStdoutToPython("/set/data/selected_translation_compute_type", selected_translation_compute_type);
};
const setSuccessSelectedTranslationComputeType = (selected_translation_compute_type) => {
updateSelectedTranslationComputeType(selected_translation_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 +168,24 @@ export const useTranslation = () => {
setSelectedCTranslate2WeightType,
setSuccessSelectedCTranslate2WeightType,
currentSelectableCTranslate2ComputeDeviceList,
getSelectableCTranslate2ComputeDeviceList,
updateSelectableCTranslate2ComputeDeviceList,
updateSelectableCTranslate2ComputeDeviceList_FromBackend,
currentSelectedCTranslate2ComputeDevice,
getSelectedCTranslate2ComputeDevice,
updateSelectedCTranslate2ComputeDevice,
setSelectedCTranslate2ComputeDevice,
setSuccessSelectedCTranslate2ComputeDevice,
currentSelectedTranslationComputeType,
getSelectedTranslationComputeType,
updateSelectedTranslationComputeType,
setSelectedTranslationComputeType,
setSuccessSelectedTranslationComputeType,
currentSelectableTranslationComputeDeviceList,
getSelectableTranslationComputeDeviceList,
updateSelectableTranslationComputeDeviceList,
updateSelectableTranslationComputeDeviceList_FromBackend,
currentSelectedTranslationComputeDevice,
getSelectedTranslationComputeDevice,
updateSelectedTranslationComputeDevice,
setSelectedTranslationComputeDevice,
setSuccessSelectedTranslationComputeDevice,
currentDeepLAuthKey,
getDeepLAuthKey,

View File

@@ -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: "/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 },
{ 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
@@ -211,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: "/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" },
{ 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" },

View File

@@ -218,10 +218,12 @@ 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_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");
export const { atomInstance: Atom_MicPhraseTimeout, useHook: useStore_MicPhraseTimeout } = createAtomWithHook(0, "MicPhraseTimeout");
@@ -235,8 +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_SelectableWhisperComputeDeviceList, useHook: useStore_SelectableWhisperComputeDeviceList } = createAtomWithHook({}, "SelectableWhisperComputeDeviceList");
export const { atomInstance: Atom_SelectedWhisperComputeDevice, useHook: useStore_SelectedWhisperComputeDevice } = createAtomWithHook("", "SelectedWhisperComputeDevice");
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");