[Update] Config Page: Translation, Transcription Tab. Add Select CTranslate2/Whisper Compute Device section.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export { useComputeMode } from "./useComputeMode";
|
||||
export { useInitProgress } from "./useInitProgress";
|
||||
export { useIsBackendReady } from "./useIsBackendReady";
|
||||
export { useWindow } from "./useWindow";
|
||||
|
||||
10
src-ui/logics/common/useComputeMode.js
Normal file
10
src-ui/logics/common/useComputeMode.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useStore_ComputeMode } from "@store";
|
||||
|
||||
export const useComputeMode = () => {
|
||||
const { currentComputeMode, updateComputeMode } = useStore_ComputeMode();
|
||||
|
||||
return {
|
||||
currentComputeMode,
|
||||
updateComputeMode,
|
||||
};
|
||||
};
|
||||
@@ -35,9 +35,13 @@ export { useSpeakerMaxWords } from "./transcription/useSpeakerMaxWords";
|
||||
export { useSelectedTranscriptionEngine } from "./transcription/useSelectedTranscriptionEngine";
|
||||
export { useWhisperWeightTypeStatus } from "./transcription/useWhisperWeightTypeStatus";
|
||||
export { useSelectedWhisperWeightType } from "./transcription/useSelectedWhisperWeightType";
|
||||
export { useSelectableWhisperComputeDeviceList } from "./transcription/useSelectableWhisperComputeDeviceList";
|
||||
export { useSelectedWhisperComputeDevice } from "./transcription/useSelectedWhisperComputeDevice";
|
||||
|
||||
export { useDeepLAuthKey } from "./translation/useDeepLAuthKey";
|
||||
export { useCTranslate2WeightTypeStatus } from "./translation/useCTranslate2WeightTypeStatus";
|
||||
export { useSelectableCTranslate2ComputeDeviceList } from "./translation/useSelectableCTranslate2ComputeDeviceList";
|
||||
export { useSelectedCTranslate2ComputeDevice } from "./translation/useSelectedCTranslate2ComputeDevice";
|
||||
export { useSelectedCTranslate2WeightType } from "./translation/useSelectedCTranslate2WeightType";
|
||||
|
||||
export { useIsEnabledOverlaySmallLog } from "./vr/useIsEnabledOverlaySmallLog";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useStore_SelectableWhisperComputeDeviceList } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSelectableWhisperComputeDeviceList = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentSelectableWhisperComputeDeviceList, updateSelectableWhisperComputeDeviceList, pendingSelectableWhisperComputeDeviceList } = useStore_SelectableWhisperComputeDeviceList();
|
||||
|
||||
const getSelectableWhisperComputeDeviceList = () => {
|
||||
pendingSelectableWhisperComputeDeviceList();
|
||||
asyncStdoutToPython("/get/data/transcription_compute_device_list");
|
||||
};
|
||||
|
||||
return {
|
||||
currentSelectableWhisperComputeDeviceList,
|
||||
getSelectableWhisperComputeDeviceList,
|
||||
updateSelectableWhisperComputeDeviceList,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useStore_SelectedWhisperComputeDevice } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSelectedWhisperComputeDevice = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentSelectedWhisperComputeDevice, updateSelectedWhisperComputeDevice, pendingSelectedWhisperComputeDevice } = useStore_SelectedWhisperComputeDevice();
|
||||
|
||||
const getSelectedWhisperComputeDevice = () => {
|
||||
pendingSelectedWhisperComputeDevice();
|
||||
asyncStdoutToPython("/get/data/selected_transcription_compute_device");
|
||||
};
|
||||
|
||||
const setSelectedWhisperComputeDevice = (selected_transcription_compute_device) => {
|
||||
pendingSelectedWhisperComputeDevice();
|
||||
asyncStdoutToPython("/set/data/selected_transcription_compute_device", selected_transcription_compute_device);
|
||||
};
|
||||
|
||||
return {
|
||||
currentSelectedWhisperComputeDevice,
|
||||
getSelectedWhisperComputeDevice,
|
||||
updateSelectedWhisperComputeDevice,
|
||||
setSelectedWhisperComputeDevice,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useStore_SelectableCTranslate2ComputeDeviceList } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSelectableCTranslate2ComputeDeviceList = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentSelectableCTranslate2ComputeDeviceList, updateSelectableCTranslate2ComputeDeviceList, pendingSelectableCTranslate2ComputeDeviceList } = useStore_SelectableCTranslate2ComputeDeviceList();
|
||||
|
||||
const getSelectableCTranslate2ComputeDeviceList = () => {
|
||||
pendingSelectableCTranslate2ComputeDeviceList();
|
||||
asyncStdoutToPython("/get/data/translation_compute_device_list");
|
||||
};
|
||||
|
||||
return {
|
||||
currentSelectableCTranslate2ComputeDeviceList,
|
||||
getSelectableCTranslate2ComputeDeviceList,
|
||||
updateSelectableCTranslate2ComputeDeviceList,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useStore_SelectedCTranslate2ComputeDevice } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSelectedCTranslate2ComputeDevice = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentSelectedCTranslate2ComputeDevice, updateSelectedCTranslate2ComputeDevice, pendingSelectedCTranslate2ComputeDevice } = useStore_SelectedCTranslate2ComputeDevice();
|
||||
|
||||
const getSelectedCTranslate2ComputeDevice = () => {
|
||||
pendingSelectedCTranslate2ComputeDevice();
|
||||
asyncStdoutToPython("/get/data/selected_translation_compute_device");
|
||||
};
|
||||
|
||||
const setSelectedCTranslate2ComputeDevice = (selected_translation_compute_device) => {
|
||||
pendingSelectedCTranslate2ComputeDevice();
|
||||
asyncStdoutToPython("/set/data/selected_translation_compute_device", selected_translation_compute_device);
|
||||
};
|
||||
|
||||
return {
|
||||
currentSelectedCTranslate2ComputeDevice,
|
||||
getSelectedCTranslate2ComputeDevice,
|
||||
updateSelectedCTranslate2ComputeDevice,
|
||||
setSelectedCTranslate2ComputeDevice,
|
||||
};
|
||||
};
|
||||
@@ -2,6 +2,7 @@ import { translator_status } from "@ui_configs";
|
||||
import { arrayToObject } from "@utils";
|
||||
|
||||
import {
|
||||
useComputeMode,
|
||||
useInitProgress,
|
||||
useIsBackendReady,
|
||||
useWindow,
|
||||
@@ -51,6 +52,10 @@ import {
|
||||
useSpeakerMaxWords,
|
||||
useDeepLAuthKey,
|
||||
useCTranslate2WeightTypeStatus,
|
||||
useSelectableCTranslate2ComputeDeviceList,
|
||||
useSelectedCTranslate2ComputeDevice,
|
||||
useSelectableWhisperComputeDeviceList,
|
||||
useSelectedWhisperComputeDevice,
|
||||
useSelectedCTranslate2WeightType,
|
||||
useSelectedTranscriptionEngine,
|
||||
useSelectedWhisperWeightType,
|
||||
@@ -64,6 +69,7 @@ import {
|
||||
} from "@logics_configs";
|
||||
|
||||
export const useReceiveRoutes = () => {
|
||||
const { updateComputeMode } = useComputeMode();
|
||||
const { updateInitProgress } = useInitProgress();
|
||||
const { updateIsBackendReady } = useIsBackendReady();
|
||||
const { restoreWindowGeometry } = useWindow();
|
||||
@@ -138,6 +144,10 @@ export const useReceiveRoutes = () => {
|
||||
updateDownloadProgressCTranslate2WeightTypeStatus,
|
||||
downloadedCTranslate2WeightType,
|
||||
} = useCTranslate2WeightTypeStatus();
|
||||
const { updateSelectableCTranslate2ComputeDeviceList } = useSelectableCTranslate2ComputeDeviceList();
|
||||
const { updateSelectedCTranslate2ComputeDevice } = useSelectedCTranslate2ComputeDevice();
|
||||
const { updateSelectableWhisperComputeDeviceList } = useSelectableWhisperComputeDeviceList();
|
||||
const { updateSelectedWhisperComputeDevice } = useSelectedWhisperComputeDevice();
|
||||
|
||||
const { updateSelectedTranscriptionEngine } = useSelectedTranscriptionEngine();
|
||||
const { updateSelectedWhisperWeightType } = useSelectedWhisperWeightType();
|
||||
@@ -159,6 +169,7 @@ export const useReceiveRoutes = () => {
|
||||
// Common
|
||||
"/run/feed_watchdog": () => {},
|
||||
"/run/initialization_progress": updateInitProgress,
|
||||
"/get/data/compute_mode": updateComputeMode,
|
||||
"/get/data/main_window_geometry": restoreWindowGeometry,
|
||||
"/set/data/main_window_geometry": () => {},
|
||||
"/run/open_filepath_logs": () => console.log("Opened Directory, Message Logs"),
|
||||
@@ -316,6 +327,10 @@ export const useReceiveRoutes = () => {
|
||||
|
||||
"/get/data/selectable_ctranslate2_weight_type_dict": updateDownloadedCTranslate2WeightTypeStatus,
|
||||
|
||||
"/get/data/translation_compute_device_list": (payload) => updateSelectableCTranslate2ComputeDeviceList(transformToIndexedArray(payload)),
|
||||
"/get/data/selected_translation_compute_device": updateSelectedCTranslate2ComputeDevice,
|
||||
"/set/data/selected_translation_compute_device": updateSelectedCTranslate2ComputeDevice,
|
||||
|
||||
"/run/downloaded_ctranslate2_weight": downloadedCTranslate2WeightType,
|
||||
"/run/download_ctranslate2_weight": () => {},
|
||||
"/run/download_progress_ctranslate2_weight": updateDownloadProgressCTranslate2WeightTypeStatus,
|
||||
@@ -380,6 +395,10 @@ export const useReceiveRoutes = () => {
|
||||
"/run/download_whisper_weight": () => {},
|
||||
"/run/download_progress_whisper_weight": updateDownloadProgressWhisperWeightTypeStatus,
|
||||
|
||||
"/get/data/transcription_compute_device_list": (payload) => updateSelectableWhisperComputeDeviceList(transformToIndexedArray(payload)),
|
||||
"/get/data/selected_transcription_compute_device": updateSelectedWhisperComputeDevice,
|
||||
"/set/data/selected_transcription_compute_device": updateSelectedWhisperComputeDevice,
|
||||
|
||||
// VR
|
||||
"/get/data/overlay_small_log": updateIsEnabledOverlaySmallLog,
|
||||
"/set/enable/overlay_small_log": updateIsEnabledOverlaySmallLog,
|
||||
@@ -486,4 +505,12 @@ export const useReceiveRoutes = () => {
|
||||
|
||||
const style_348 = [
|
||||
"color: gray",
|
||||
].join(";");
|
||||
].join(";");
|
||||
|
||||
|
||||
const transformToIndexedArray = (devices) => {
|
||||
return devices.reduce((result, device, index) => {
|
||||
result[index] = device;
|
||||
return result;
|
||||
}, {});
|
||||
};
|
||||
Reference in New Issue
Block a user