[Update] Config Page: Transcription Tab. Add Whisper Weight Type Selector. Downloadable.

This commit is contained in:
Sakamoto Shiina
2024-11-12 14:52:15 +09:00
parent 36c53c49a2
commit 96ed2a9afc
7 changed files with 162 additions and 1 deletions

View File

@@ -31,8 +31,11 @@ export { useSpeakerRecordTimeout } from "./transcription/useSpeakerRecordTimeout
export { useSpeakerPhraseTimeout } from "./transcription/useSpeakerPhraseTimeout";
export { useSpeakerMaxWords } from "./transcription/useSpeakerMaxWords";
export { useCTranslate2WeightTypeStatus } from "./translation/useCTranslate2WeightTypeStatus";
export { useWhisperWeightTypeStatus } from "./transcription/useWhisperWeightTypeStatus";
export { useSelectedWhisperWeightType } from "./transcription/useSelectedWhisperWeightType";
export { useDeepLAuthKey } from "./translation/useDeepLAuthKey";
export { useCTranslate2WeightTypeStatus } from "./translation/useCTranslate2WeightTypeStatus";
export { useSelectedCTranslate2WeightType } from "./translation/useSelectedCTranslate2WeightType";
export { useIsEnabledOverlaySmallLog } from "./vr/useIsEnabledOverlaySmallLog";

View File

@@ -0,0 +1,24 @@
import { useStore_SelectedWhisperWeightType } from "@store";
import { useStdoutToPython } from "@logics/useStdoutToPython";
export const useSelectedWhisperWeightType = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { currentSelectedWhisperWeightType, updateSelectedWhisperWeightType, pendingSelectedWhisperWeightType } = useStore_SelectedWhisperWeightType();
const getSelectedWhisperWeightType = () => {
pendingSelectedWhisperWeightType();
asyncStdoutToPython("/get/data/whisper_weight_type");
};
const setSelectedWhisperWeightType = (selected_whisper_weight_type) => {
pendingSelectedWhisperWeightType();
asyncStdoutToPython("/set/data/whisper_weight_type", selected_whisper_weight_type);
};
return {
currentSelectedWhisperWeightType,
getSelectedWhisperWeightType,
updateSelectedWhisperWeightType,
setSelectedWhisperWeightType,
};
};

View File

@@ -0,0 +1,60 @@
import { useStore_WhisperWeightTypeStatus } from "@store";
import { useStdoutToPython } from "@logics/useStdoutToPython";
export const useWhisperWeightTypeStatus = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { currentWhisperWeightTypeStatus, updateWhisperWeightTypeStatus, pendingWhisperWeightTypeStatus } = useStore_WhisperWeightTypeStatus();
const updateDownloadedWhisperWeightTypeStatus = (downloaded_weight_type_status) => {
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) => ({
...item,
is_downloaded: downloaded_weight_type_status[item.id] ?? item.is_downloaded,
}))
);
};
const updateDownloadProgressWhisperWeightTypeStatus = (payload) => {
if (payload === true) return console.error("fix me.");
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) =>
payload.weight_type === item.id
? { ...item, progress: payload.progress * 100 }
: item
)
);
};
const pendingWhisperWeightType = (id) => {
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_pending: true }
: item
)
);
};
const downloadedWhisperWeightType = (id) => {
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_downloaded: true, is_pending: false, progress: null }
: item
)
);
};
const downloadWhisperWeight = (weight_type) => {
asyncStdoutToPython("/run/download_whisper_weight", weight_type);
};
return {
currentWhisperWeightTypeStatus,
updateWhisperWeightTypeStatus,
updateDownloadedWhisperWeightTypeStatus,
updateDownloadProgressWhisperWeightTypeStatus,
pendingWhisperWeightType,
downloadedWhisperWeightType,
downloadWhisperWeight,
};
};

View File

@@ -48,6 +48,8 @@ import {
useDeepLAuthKey,
useCTranslate2WeightTypeStatus,
useSelectedCTranslate2WeightType,
useSelectedWhisperWeightType,
useWhisperWeightTypeStatus,
useOverlaySettings,
useIsEnabledOverlaySmallLog,
useOverlaySmallLogSettings,
@@ -127,6 +129,13 @@ export const useReceiveRoutes = () => {
downloadedCTranslate2WeightType,
} = useCTranslate2WeightTypeStatus();
const { updateSelectedWhisperWeightType } = useSelectedWhisperWeightType();
const {
updateDownloadedWhisperWeightTypeStatus,
updateDownloadProgressWhisperWeightTypeStatus,
downloadedWhisperWeightType,
} = useWhisperWeightTypeStatus();
const { updateOverlaySettings } = useOverlaySettings();
const { updateOverlaySmallLogSettings } = useOverlaySmallLogSettings();
const { updateIsEnabledOverlaySmallLog } = useIsEnabledOverlaySmallLog();
@@ -342,6 +351,14 @@ export const useReceiveRoutes = () => {
"/get/data/speaker_max_phrases": updateSpeakerMaxWords,
"/set/data/speaker_max_phrases": updateSpeakerMaxWords,
"/get/data/whisper_weight_type": updateSelectedWhisperWeightType,
"/set/data/whisper_weight_type": updateSelectedWhisperWeightType,
"/get/data/selectable_whisper_weight_type_dict": updateDownloadedWhisperWeightTypeStatus,
"/run/download_whisper_weight": updateDownloadProgressWhisperWeightTypeStatus,
"/run/downloaded_whisper_weight": downloadedWhisperWeightType,
// VR
"/get/data/overlay_settings": updateOverlaySettings,
"/set/data/overlay_settings": updateOverlaySettings,