[Refactor] Remove the commented code that is no longer needed.

This commit is contained in:
Sakamoto Shiina
2025-10-23 11:20:05 +09:00
parent d3ef567ef2
commit 4fdaf6611f
9 changed files with 2 additions and 2247 deletions

View File

@@ -1,150 +0,0 @@
import {
useStore_OscIpAddress,
useStore_OscPort,
useStore_EnableWebsocket,
useStore_WebsocketHost,
useStore_WebsocketPort,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useNotificationStatus } from "@logics_common";
export const useAdvancedSettings = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_Error, showNotification_SaveSuccess } = useNotificationStatus();
// OSC IP Address
const { currentOscIpAddress, updateOscIpAddress, pendingOscIpAddress } = useStore_OscIpAddress();
// OSC Port
const { currentOscPort, updateOscPort, pendingOscPort } = useStore_OscPort();
// WebSocket
const { currentEnableWebsocket, updateEnableWebsocket, pendingEnableWebsocket } = useStore_EnableWebsocket();
const { currentWebsocketHost, updateWebsocketHost, pendingWebsocketHost } = useStore_WebsocketHost();
const { currentWebsocketPort, updateWebsocketPort, pendingWebsocketPort } = useStore_WebsocketPort();
// OSC IP Address
const getOscIpAddress = () => {
pendingOscIpAddress();
asyncStdoutToPython("/get/data/osc_ip_address");
};
const setOscIpAddress = (osc_ip_address) => {
pendingOscIpAddress();
asyncStdoutToPython("/set/data/osc_ip_address", osc_ip_address);
};
const setSuccessOscIpAddress = (osc_ip_address) => {
updateOscIpAddress(osc_ip_address);
showNotification_SaveSuccess();
};
// OSC Port
const getOscPort = () => {
pendingOscPort();
asyncStdoutToPython("/get/data/osc_port");
};
const setOscPort = (osc_port) => {
pendingOscPort();
asyncStdoutToPython("/set/data/osc_port", osc_port);
};
const setSuccessOscPort = (osc_port) => {
updateOscPort(osc_port);
showNotification_SaveSuccess();
};
const saveErrorOscPort = ({ data, message, _result }) => {
updateOscPort(d => d.data);
showNotification_Error(_result);
};
// WebSocket Enable
const getEnableWebsocket = () => {
pendingEnableWebsocket();
asyncStdoutToPython("/get/data/websocket_server");
};
const toggleEnableWebsocket = () => {
pendingEnableWebsocket();
if (currentEnableWebsocket.data) {
asyncStdoutToPython("/set/disable/websocket_server");
} else {
asyncStdoutToPython("/set/enable/websocket_server");
}
};
const setSuccessEnableWebsocket = (is_enabled) => {
updateEnableWebsocket(is_enabled);
showNotification_SaveSuccess();
};
// WebSocket Host
const getWebsocketHost = () => {
pendingWebsocketHost();
asyncStdoutToPython("/get/data/websocket_host");
};
const setWebsocketHost = (websocket_host) => {
pendingWebsocketHost();
asyncStdoutToPython("/set/data/websocket_host", websocket_host);
};
const setSuccessWebsocketHost = (websocket_host) => {
updateWebsocketHost(websocket_host);
showNotification_SaveSuccess();
};
// WebSocket Port
const getWebsocketPort = () => {
pendingWebsocketPort();
asyncStdoutToPython("/get/data/websocket_port");
};
const setWebsocketPort = (websocket_port) => {
pendingWebsocketPort();
asyncStdoutToPython("/set/data/websocket_port", websocket_port);
};
const setSuccessWebsocketPort = (websocket_port) => {
updateWebsocketPort(websocket_port);
showNotification_SaveSuccess();
};
return {
// OSC IP Address
currentOscIpAddress,
getOscIpAddress,
updateOscIpAddress,
setOscIpAddress,
setSuccessOscIpAddress,
// OSC Port
currentOscPort,
getOscPort,
updateOscPort,
setOscPort,
setSuccessOscPort,
saveErrorOscPort,
// WebSocket Enable
currentEnableWebsocket,
getEnableWebsocket,
updateEnableWebsocket,
toggleEnableWebsocket,
setSuccessEnableWebsocket,
// WebSocket Host
currentWebsocketHost,
getWebsocketHost,
updateWebsocketHost,
setWebsocketHost,
setSuccessWebsocketHost,
// WebSocket Port
currentWebsocketPort,
getWebsocketPort,
updateWebsocketPort,
setWebsocketPort,
setSuccessWebsocketPort,
};
};

View File

@@ -1,207 +0,0 @@
import { useAppearance_S } from "../../../ui_config_setter";
export const useAppearance = () => {
return {...useAppearance_S()};
}
// import {
// useStore_UiLanguage,
// useStore_UiScaling,
// useStore_MessageLogUiScaling,
// useStore_SendMessageButtonType,
// useStore_ShowResendButton,
// useStore_SelectedFontFamily,
// useStore_Transparency,
// } from "@store";
// import { useStdoutToPython } from "@useStdoutToPython";
// import { useI18n } from "@useI18n";
// import { useNotificationStatus } from "@logics_common";
// export const useAppearance = () => {
// const { t } = useI18n();
// const { asyncStdoutToPython } = useStdoutToPython();
// const { showNotification_SaveSuccess } = useNotificationStatus();
// // UI Language
// const { currentUiLanguage, updateUiLanguage, pendingUiLanguage } = useStore_UiLanguage();
// // UI Scaling
// const { currentUiScaling, updateUiScaling, pendingUiScaling } = useStore_UiScaling();
// // Message Log Ui Scaling
// const { currentMessageLogUiScaling, updateMessageLogUiScaling, pendingMessageLogUiScaling } = useStore_MessageLogUiScaling();
// // Send Message Button Type
// const { currentSendMessageButtonType, updateSendMessageButtonType, pendingSendMessageButtonType } = useStore_SendMessageButtonType();
// // Show Resend Button
// const { currentShowResendButton, updateShowResendButton, pendingShowResendButton } = useStore_ShowResendButton();
// // Selected Font Family
// const { currentSelectedFontFamily, updateSelectedFontFamily, pendingSelectedFontFamily } = useStore_SelectedFontFamily();
// // Transparency
// const { currentTransparency, updateTransparency, pendingTransparency } = useStore_Transparency();
// // UI Language
// const getUiLanguage = () => {
// pendingUiLanguage();
// asyncStdoutToPython("/get/data/ui_language");
// };
// const setUiLanguage = (selected_ui_language) => {
// pendingUiLanguage();
// asyncStdoutToPython("/set/data/ui_language", selected_ui_language);
// };
// const setSuccessUiLanguage = (selected_ui_language) => {
// updateUiLanguage(selected_ui_language);
// showNotification_SaveSuccess();
// };
// // UI Scaling
// const getUiScaling = () => {
// pendingUiScaling();
// asyncStdoutToPython("/get/data/ui_scaling");
// };
// const setUiScaling = (selected_ui_scaling) => {
// pendingUiScaling();
// asyncStdoutToPython("/set/data/ui_scaling", selected_ui_scaling);
// };
// const setSuccessUiScaling = (selected_ui_scaling) => {
// updateUiScaling(selected_ui_scaling);
// showNotification_SaveSuccess();
// };
// // Message Log Ui Scaling
// const getMessageLogUiScaling = () => {
// pendingMessageLogUiScaling();
// asyncStdoutToPython("/get/data/textbox_ui_scaling");
// };
// const setMessageLogUiScaling = (selected_ui_scaling) => {
// pendingMessageLogUiScaling();
// asyncStdoutToPython("/set/data/textbox_ui_scaling", selected_ui_scaling);
// };
// const setSuccessMessageLogUiScaling = (selected_ui_scaling) => {
// updateMessageLogUiScaling(selected_ui_scaling);
// showNotification_SaveSuccess();
// };
// // Send Message Button Type
// const getSendMessageButtonType = () => {
// pendingSendMessageButtonType();
// asyncStdoutToPython("/get/data/send_message_button_type");
// };
// const setSendMessageButtonType = (send_message_button_type) => {
// pendingSendMessageButtonType();
// asyncStdoutToPython("/set/data/send_message_button_type", send_message_button_type);
// };
// const setSuccessSendMessageButtonType = (send_message_button_type) => {
// updateSendMessageButtonType(send_message_button_type);
// showNotification_SaveSuccess();
// };
// // Show Resend Button
// const getShowResendButton = () => {
// pendingShowResendButton();
// asyncStdoutToPython("/get/data/show_resend_button");
// };
// const toggleShowResendButton = () => {
// pendingShowResendButton();
// if (currentShowResendButton.data) {
// asyncStdoutToPython("/set/disable/show_resend_button");
// } else {
// asyncStdoutToPython("/set/enable/show_resend_button");
// }
// };
// const setSuccessShowResendButton = (to_show) => {
// updateShowResendButton(to_show);
// showNotification_SaveSuccess();
// };
// // Selected Font Family
// const getSelectedFontFamily = () => {
// pendingSelectedFontFamily();
// asyncStdoutToPython("/get/data/font_family");
// };
// const setSelectedFontFamily = (selected_font_family) => {
// pendingSelectedFontFamily();
// asyncStdoutToPython("/set/data/font_family", selected_font_family);
// };
// const setSuccessSelectedFontFamily = (selected_font_family) => {
// updateSelectedFontFamily(selected_font_family);
// showNotification_SaveSuccess();
// };
// // Transparency
// const getTransparency = () => {
// pendingTransparency();
// asyncStdoutToPython("/get/data/transparency");
// };
// const setTransparency = (selected_transparency) => {
// pendingTransparency();
// asyncStdoutToPython("/set/data/transparency", selected_transparency);
// };
// const setSuccessTransparency = (selected_transparency) => {
// updateTransparency(selected_transparency);
// showNotification_SaveSuccess();
// };
// return {
// // UI Language
// currentUiLanguage,
// getUiLanguage,
// updateUiLanguage,
// setUiLanguage,
// setSuccessUiLanguage,
// // UI Scaling
// currentUiScaling,
// getUiScaling,
// updateUiScaling,
// setUiScaling,
// setSuccessUiScaling,
// // Message Log Ui Scaling
// currentMessageLogUiScaling,
// getMessageLogUiScaling,
// updateMessageLogUiScaling,
// setMessageLogUiScaling,
// setSuccessMessageLogUiScaling,
// // Send Message Button Type
// currentSendMessageButtonType,
// getSendMessageButtonType,
// setSendMessageButtonType,
// setSuccessSendMessageButtonType,
// updateSendMessageButtonType,
// // Show Resend Button
// currentShowResendButton,
// getShowResendButton,
// updateShowResendButton,
// toggleShowResendButton,
// setSuccessShowResendButton,
// // Selected Font Family
// currentSelectedFontFamily,
// getSelectedFontFamily,
// updateSelectedFontFamily,
// setSelectedFontFamily,
// setSuccessSelectedFontFamily,
// // Transparency
// currentTransparency,
// getTransparency,
// updateTransparency,
// setTransparency,
// setSuccessTransparency,
// };
// };

View File

@@ -1,306 +0,0 @@
import {
useStore_EnableAutoMicSelect,
useStore_EnableAutoSpeakerSelect,
useStore_MicDeviceList,
useStore_MicHostList,
useStore_SpeakerDeviceList,
useStore_SelectedMicHost,
useStore_SelectedMicDevice,
useStore_SelectedSpeakerDevice,
useStore_MicThreshold,
useStore_EnableAutomaticMicThreshold,
useStore_SpeakerThreshold,
useStore_EnableAutomaticSpeakerThreshold,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { arrayToObject } from "@utils";
import { useNotificationStatus } from "@logics_common";
export const useDevice = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
const { currentEnableAutoMicSelect, updateEnableAutoMicSelect, pendingEnableAutoMicSelect } = useStore_EnableAutoMicSelect();
const { currentEnableAutoSpeakerSelect, updateEnableAutoSpeakerSelect, pendingEnableAutoSpeakerSelect } = useStore_EnableAutoSpeakerSelect();
const { currentMicDeviceList, updateMicDeviceList, pendingMicDeviceList } = useStore_MicDeviceList();
const { currentMicHostList, updateMicHostList, pendingMicHostList } = useStore_MicHostList();
const { currentSpeakerDeviceList, updateSpeakerDeviceList, pendingSpeakerDeviceList } = useStore_SpeakerDeviceList();
const { currentSelectedMicHost, updateSelectedMicHost, pendingSelectedMicHost } = useStore_SelectedMicHost();
const { currentSelectedMicDevice, updateSelectedMicDevice, pendingSelectedMicDevice } = useStore_SelectedMicDevice();
const { currentSelectedSpeakerDevice, updateSelectedSpeakerDevice, pendingSelectedSpeakerDevice } = useStore_SelectedSpeakerDevice();
const { currentMicThreshold, updateMicThreshold } = useStore_MicThreshold();
const { currentEnableAutomaticMicThreshold, updateEnableAutomaticMicThreshold, pendingEnableAutomaticMicThreshold } = useStore_EnableAutomaticMicThreshold();
const { currentSpeakerThreshold, updateSpeakerThreshold } = useStore_SpeakerThreshold();
const { currentEnableAutomaticSpeakerThreshold, updateEnableAutomaticSpeakerThreshold, pendingEnableAutomaticSpeakerThreshold } = useStore_EnableAutomaticSpeakerThreshold();
// Auto Select (Mic)
const getEnableAutoMicSelect = () => {
pendingEnableAutoMicSelect();
asyncStdoutToPython("/get/data/auto_mic_select");
};
const toggleEnableAutoMicSelect = () => {
pendingEnableAutoMicSelect();
if (currentEnableAutoMicSelect.data) {
asyncStdoutToPython("/set/disable/auto_mic_select");
} else {
asyncStdoutToPython("/set/enable/auto_mic_select");
}
};
const setSuccessEnableAutoMicSelect = (enabled) => {
updateEnableAutoMicSelect(enabled);
showNotification_SaveSuccess();
};
// Auto Select (Speaker)
const getEnableAutoSpeakerSelect = () => {
pendingEnableAutoSpeakerSelect();
asyncStdoutToPython("/get/data/auto_speaker_select");
};
const toggleEnableAutoSpeakerSelect = () => {
pendingEnableAutoSpeakerSelect();
if (currentEnableAutoSpeakerSelect.data) {
asyncStdoutToPython("/set/disable/auto_speaker_select");
} else {
asyncStdoutToPython("/set/enable/auto_speaker_select");
}
};
const setSuccessEnableAutoSpeakerSelect = (enabled) => {
updateEnableAutoSpeakerSelect(enabled);
showNotification_SaveSuccess();
};
// List (Mic device)
const getMicDeviceList = () => {
pendingMicDeviceList();
asyncStdoutToPython("/get/data/mic_device_list");
};
const updateMicDeviceList_FromBackend = (payload) => {
updateMicDeviceList(arrayToObject(payload));
};
// List (Mic host)
const getMicHostList = () => {
pendingMicHostList();
asyncStdoutToPython("/get/data/mic_host_list");
};
const updateMicHostList_FromBackend = (payload) => {
updateMicHostList(arrayToObject(payload));
};
// List (Speaker device)
const getSpeakerDeviceList = () => {
pendingSpeakerDeviceList();
asyncStdoutToPython("/get/data/speaker_device_list");
};
const updateSpeakerDeviceList_FromBackend = (payload) => {
updateSpeakerDeviceList(arrayToObject(payload));
};
// Selected (Mic host)
const getSelectedMicHost = () => {
pendingSelectedMicHost();
asyncStdoutToPython("/get/data/selected_mic_host");
};
const setSelectedMicHost = (selected_mic_host) => {
pendingSelectedMicHost();
asyncStdoutToPython("/set/data/selected_mic_host", selected_mic_host);
};
const setSuccessSelectedMicHost = (payload) => {
updateSelectedMicHostAndDevice(payload); // Receive host and device from backend.
showNotification_SaveSuccess();
};
// Selected (Mic device)
const getSelectedMicDevice = () => {
pendingSelectedMicDevice();
asyncStdoutToPython("/get/data/selected_mic_device");
};
const setSelectedMicDevice = (selected_mic_device) => {
pendingSelectedMicDevice();
asyncStdoutToPython("/set/data/selected_mic_device", selected_mic_device);
};
const setSuccessSelectedMicDevice = (selected_mic_device) => {
updateSelectedMicDevice(selected_mic_device);
showNotification_SaveSuccess();
};
// Selected (Mic Device and Host)
const updateSelectedMicHostAndDevice = (payload) => {
updateSelectedMicHost(payload.host);
updateSelectedMicDevice(payload.device);
}
// Selected (Speaker device)
const getSelectedSpeakerDevice = () => {
pendingSelectedSpeakerDevice();
asyncStdoutToPython("/get/data/selected_speaker_device");
};
const setSelectedSpeakerDevice = (selected_speaker_device) => {
pendingSelectedSpeakerDevice();
asyncStdoutToPython("/set/data/selected_speaker_device", selected_speaker_device);
};
const setSuccessSelectedSpeakerDevice = (selected_speaker_device) => {
updateSelectedSpeakerDevice(selected_speaker_device);
showNotification_SaveSuccess();
};
// Threshold (Mic)
const getMicThreshold = () => {
asyncStdoutToPython("/get/data/mic_threshold");
};
const setMicThreshold = (mic_threshold) => {
asyncStdoutToPython("/set/data/mic_threshold", mic_threshold);
};
const setSuccessMicThreshold = (mic_threshold) => {
updateMicThreshold(mic_threshold);
showNotification_SaveSuccess();
};
const getEnableAutomaticMicThreshold = () => {
pendingEnableAutomaticMicThreshold();
asyncStdoutToPython("/get/data/mic_automatic_threshold");
};
const toggleEnableAutomaticMicThreshold = () => {
pendingEnableAutomaticMicThreshold();
if (currentEnableAutomaticMicThreshold.data) {
asyncStdoutToPython("/set/disable/mic_automatic_threshold");
} else {
asyncStdoutToPython("/set/enable/mic_automatic_threshold");
}
};
const setSuccessEnableAutomaticMicThreshold = (enabled) => {
updateEnableAutomaticMicThreshold(enabled);
showNotification_SaveSuccess();
};
// Threshold (Speaker)
const getSpeakerThreshold = () => {
asyncStdoutToPython("/get/data/speaker_threshold");
};
const setSpeakerThreshold = (speaker_threshold) => {
asyncStdoutToPython("/set/data/speaker_threshold", speaker_threshold);
};
const setSuccessSpeakerThreshold = (speaker_threshold) => {
updateSpeakerThreshold(speaker_threshold);
showNotification_SaveSuccess();
};
const getEnableAutomaticSpeakerThreshold = () => {
pendingEnableAutomaticSpeakerThreshold();
asyncStdoutToPython("/get/data/speaker_automatic_threshold");
};
const toggleEnableAutomaticSpeakerThreshold = () => {
pendingEnableAutomaticSpeakerThreshold();
if (currentEnableAutomaticSpeakerThreshold.data) {
asyncStdoutToPython("/set/disable/speaker_automatic_threshold");
} else {
asyncStdoutToPython("/set/enable/speaker_automatic_threshold");
}
};
const setSuccessEnableAutomaticSpeakerThreshold = (enabled) => {
updateEnableAutomaticSpeakerThreshold(enabled);
showNotification_SaveSuccess();
};
return {
currentEnableAutoMicSelect,
getEnableAutoMicSelect,
updateEnableAutoMicSelect,
toggleEnableAutoMicSelect,
setSuccessEnableAutoMicSelect,
currentEnableAutoSpeakerSelect,
getEnableAutoSpeakerSelect,
updateEnableAutoSpeakerSelect,
toggleEnableAutoSpeakerSelect,
setSuccessEnableAutoSpeakerSelect,
currentMicDeviceList,
getMicDeviceList,
updateMicDeviceList,
updateMicDeviceList_FromBackend,
currentMicHostList,
getMicHostList,
updateMicHostList,
updateMicHostList_FromBackend,
currentSpeakerDeviceList,
getSpeakerDeviceList,
updateSpeakerDeviceList,
updateSpeakerDeviceList_FromBackend,
currentSelectedMicHost,
getSelectedMicHost,
updateSelectedMicHost,
setSelectedMicHost,
setSuccessSelectedMicHost,
currentSelectedMicDevice,
getSelectedMicDevice,
updateSelectedMicDevice,
setSelectedMicDevice,
setSuccessSelectedMicDevice,
updateSelectedMicHostAndDevice,
currentSelectedSpeakerDevice,
getSelectedSpeakerDevice,
updateSelectedSpeakerDevice,
setSelectedSpeakerDevice,
setSuccessSelectedSpeakerDevice,
currentMicThreshold,
getMicThreshold,
setMicThreshold,
updateMicThreshold,
setSuccessMicThreshold,
currentEnableAutomaticMicThreshold,
getEnableAutomaticMicThreshold,
toggleEnableAutomaticMicThreshold,
updateEnableAutomaticMicThreshold,
setSuccessEnableAutomaticMicThreshold,
currentSpeakerThreshold,
getSpeakerThreshold,
setSpeakerThreshold,
updateSpeakerThreshold,
setSuccessSpeakerThreshold,
currentEnableAutomaticSpeakerThreshold,
getEnableAutomaticSpeakerThreshold,
toggleEnableAutomaticSpeakerThreshold,
updateEnableAutomaticSpeakerThreshold,
setSuccessEnableAutomaticSpeakerThreshold,
};
};

View File

@@ -1,367 +0,0 @@
import {
useStore_EnableAutoClearMessageInputBox,
useStore_EnableSendOnlyTranslatedMessages,
useStore_EnableAutoExportMessageLogs,
useStore_EnableVrcMicMuteSync,
useStore_EnableSendMessageToVrc,
useStore_EnableNotificationVrcSfx,
useStore_EnableSendReceivedMessageToVrc,
useStore_MessageFormat_ExampleViewFilter,
useStore_SendMessageFormatParts,
useStore_ReceivedMessageFormatParts,
useStore_ConvertMessageToRomaji,
useStore_ConvertMessageToHiragana,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useNotificationStatus } from "@logics_common";
export const useOthers = () => {
const { asyncStdoutToPython } = useStdoutToPython();
// Auto Clear Message Input Box
const { currentEnableAutoClearMessageInputBox, updateEnableAutoClearMessageInputBox, pendingEnableAutoClearMessageInputBox } = useStore_EnableAutoClearMessageInputBox();
// Send Only Translated Messages
const { currentEnableSendOnlyTranslatedMessages, updateEnableSendOnlyTranslatedMessages, pendingEnableSendOnlyTranslatedMessages } = useStore_EnableSendOnlyTranslatedMessages();
// Auto Export Message Logs
const { currentEnableAutoExportMessageLogs, updateEnableAutoExportMessageLogs, pendingEnableAutoExportMessageLogs } = useStore_EnableAutoExportMessageLogs();
// VRC Mic Mute Sync
const { currentEnableVrcMicMuteSync, updateEnableVrcMicMuteSync, pendingEnableVrcMicMuteSync } = useStore_EnableVrcMicMuteSync();
// Send Message To VRCT
const { currentEnableSendMessageToVrc, updateEnableSendMessageToVrc, pendingEnableSendMessageToVrc } = useStore_EnableSendMessageToVrc();
// Sounds
// Notification VRC SFX
const { currentEnableNotificationVrcSfx, updateEnableNotificationVrcSfx, pendingEnableNotificationVrcSfx } = useStore_EnableNotificationVrcSfx();
// Speaker2Chatbox
// Send Received Message To VRC
const { currentEnableSendReceivedMessageToVrc, updateEnableSendReceivedMessageToVrc, pendingEnableSendReceivedMessageToVrc } = useStore_EnableSendReceivedMessageToVrc();
// Message Formats
const { currentMessageFormat_ExampleViewFilter, updateMessageFormat_ExampleViewFilter, pendingMessageFormat_ExampleViewFilter } = useStore_MessageFormat_ExampleViewFilter();
// Send
const { currentSendMessageFormatParts, updateSendMessageFormatParts, pendingSendMessageFormatParts } = useStore_SendMessageFormatParts();
// Received
const { currentReceivedMessageFormatParts, updateReceivedMessageFormatParts, pendingReceivedMessageFormatParts } = useStore_ReceivedMessageFormatParts();
// Convert Message To Romaji
const { currentConvertMessageToRomaji, updateConvertMessageToRomaji, pendingConvertMessageToRomaji } = useStore_ConvertMessageToRomaji();
// Convert Message To Hiragana
const { currentConvertMessageToHiragana, updateConvertMessageToHiragana, pendingConvertMessageToHiragana } = useStore_ConvertMessageToHiragana();
const { showNotification_SaveSuccess } = useNotificationStatus();
// Auto Clear Message Input Box
const getEnableAutoClearMessageInputBox = () => {
pendingEnableAutoClearMessageInputBox();
asyncStdoutToPython("/get/data/auto_clear_message_box");
};
const toggleEnableAutoClearMessageInputBox = () => {
pendingEnableAutoClearMessageInputBox();
if (currentEnableAutoClearMessageInputBox.data) {
asyncStdoutToPython("/set/disable/auto_clear_message_box");
} else {
asyncStdoutToPython("/set/enable/auto_clear_message_box");
}
};
const setSuccessEnableAutoClearMessageInputBox = (enabled) => {
updateEnableAutoClearMessageInputBox(enabled);
showNotification_SaveSuccess();
};
// Send Only Translated Messages
const getEnableSendOnlyTranslatedMessages = () => {
pendingEnableSendOnlyTranslatedMessages();
asyncStdoutToPython("/get/data/send_only_translated_messages");
};
const toggleEnableSendOnlyTranslatedMessages = () => {
pendingEnableSendOnlyTranslatedMessages();
if (currentEnableSendOnlyTranslatedMessages.data) {
asyncStdoutToPython("/set/disable/send_only_translated_messages");
} else {
asyncStdoutToPython("/set/enable/send_only_translated_messages");
}
};
const setSuccessEnableSendOnlyTranslatedMessages = (enabled) => {
updateEnableSendOnlyTranslatedMessages(enabled);
showNotification_SaveSuccess();
};
// Auto Export Message Logs
const getEnableAutoExportMessageLogs = () => {
pendingEnableAutoExportMessageLogs();
asyncStdoutToPython("/get/data/logger_feature");
};
const toggleEnableAutoExportMessageLogs = () => {
pendingEnableAutoExportMessageLogs();
if (currentEnableAutoExportMessageLogs.data) {
asyncStdoutToPython("/set/disable/logger_feature");
} else {
asyncStdoutToPython("/set/enable/logger_feature");
}
};
const setSuccessEnableAutoExportMessageLogs = (enabled) => {
updateEnableAutoExportMessageLogs(enabled);
showNotification_SaveSuccess();
};
// VRC Mic Mute Sync
const getEnableVrcMicMuteSync = () => {
pendingEnableVrcMicMuteSync();
asyncStdoutToPython("/get/data/vrc_mic_mute_sync");
};
const toggleEnableVrcMicMuteSync = () => {
pendingEnableVrcMicMuteSync();
if (currentEnableVrcMicMuteSync.data.is_enabled) {
asyncStdoutToPython("/set/disable/vrc_mic_mute_sync");
} else {
asyncStdoutToPython("/set/enable/vrc_mic_mute_sync");
}
};
const getSuccessEnableVrcMicMuteSync = (is_enabled) => {
updateEnableVrcMicMuteSync(old => ({ ...old.data, is_enabled: is_enabled }));
};
const setSuccessEnableVrcMicMuteSync = (is_enabled) => {
updateEnableVrcMicMuteSync(old => ({ ...old.data, is_enabled: is_enabled }));
showNotification_SaveSuccess();
};
// Send Message To VRCT
const getEnableSendMessageToVrc = () => {
pendingEnableSendMessageToVrc();
asyncStdoutToPython("/get/data/send_message_to_vrc");
};
const toggleEnableSendMessageToVrc = () => {
pendingEnableSendMessageToVrc();
if (currentEnableSendMessageToVrc.data) {
asyncStdoutToPython("/set/disable/send_message_to_vrc");
} else {
asyncStdoutToPython("/set/enable/send_message_to_vrc");
}
};
const setSuccessEnableSendMessageToVrc = (enabled) => {
updateEnableSendMessageToVrc(enabled);
showNotification_SaveSuccess();
};
// Sounds
// Notification VRC SFX
const getEnableNotificationVrcSfx = () => {
pendingEnableNotificationVrcSfx();
asyncStdoutToPython("/get/data/notification_vrc_sfx");
};
const toggleEnableNotificationVrcSfx = () => {
pendingEnableNotificationVrcSfx();
if (currentEnableNotificationVrcSfx.data) {
asyncStdoutToPython("/set/disable/notification_vrc_sfx");
} else {
asyncStdoutToPython("/set/enable/notification_vrc_sfx");
}
};
const setSuccessEnableNotificationVrcSfx = (enabled) => {
updateEnableNotificationVrcSfx(enabled);
showNotification_SaveSuccess();
};
// Speaker2Chatbox
// Send Received Message To VRC
const getEnableSendReceivedMessageToVrc = () => {
pendingEnableSendReceivedMessageToVrc();
asyncStdoutToPython("/get/data/send_received_message_to_vrc");
};
const toggleEnableSendReceivedMessageToVrc = () => {
pendingEnableSendReceivedMessageToVrc();
if (currentEnableSendReceivedMessageToVrc.data) {
asyncStdoutToPython("/set/disable/send_received_message_to_vrc");
} else {
asyncStdoutToPython("/set/enable/send_received_message_to_vrc");
}
};
const setSuccessEnableSendReceivedMessageToVrc = (enabled) => {
updateEnableSendReceivedMessageToVrc(enabled);
showNotification_SaveSuccess();
};
// Message Formats
// Send
const getSendMessageFormatParts = () => {
pendingSendMessageFormatParts();
asyncStdoutToPython("/get/data/send_message_format_parts");
};
const setSendMessageFormatParts = (message_format_parts) => {
pendingSendMessageFormatParts();
asyncStdoutToPython("/set/data/send_message_format_parts", message_format_parts);
};
const setSuccessSendMessageFormatParts = (message_format_parts) => {
updateSendMessageFormatParts(message_format_parts);
showNotification_SaveSuccess();
};
// Received
const getReceivedMessageFormatParts = () => {
pendingReceivedMessageFormatParts();
asyncStdoutToPython("/get/data/received_message_format_parts");
};
const setReceivedMessageFormatParts = (message_format_parts) => {
pendingReceivedMessageFormatParts();
asyncStdoutToPython("/set/data/received_message_format_parts", message_format_parts);
};
const setSuccessReceivedMessageFormatParts = (message_format_parts) => {
updateReceivedMessageFormatParts(message_format_parts);
showNotification_SaveSuccess();
};
const toggleMessageFormat_ExampleViewFilter = (id) => {
pendingMessageFormat_ExampleViewFilter();
if (["send", "received"].includes(id) === false) return console.error(`id should be small case 'send' or 'received'. got id: ${id}`);
updateMessageFormat_ExampleViewFilter({
...currentMessageFormat_ExampleViewFilter.data,
[id]: currentMessageFormat_ExampleViewFilter.data[id] === "Simplified"
? "All"
: "Simplified"
});
};
// Convert Message To Romaji
const getConvertMessageToRomaji = () => {
pendingConvertMessageToRomaji();
asyncStdoutToPython("/get/data/convert_message_to_romaji");
};
const toggleConvertMessageToRomaji = () => {
pendingConvertMessageToRomaji();
if (currentConvertMessageToRomaji.data) {
asyncStdoutToPython("/set/disable/convert_message_to_romaji");
} else {
asyncStdoutToPython("/set/enable/convert_message_to_romaji");
}
};
const setSuccessConvertMessageToRomaji = (enabled) => {
updateConvertMessageToRomaji(enabled);
showNotification_SaveSuccess();
};
// Convert Message To Hiragana
const getConvertMessageToHiragana = () => {
pendingConvertMessageToHiragana();
asyncStdoutToPython("/get/data/convert_message_to_hiragana");
};
const toggleConvertMessageToHiragana = () => {
pendingConvertMessageToHiragana();
if (currentConvertMessageToHiragana.data) {
asyncStdoutToPython("/set/disable/convert_message_to_hiragana");
} else {
asyncStdoutToPython("/set/enable/convert_message_to_hiragana");
}
};
const setSuccessConvertMessageToHiragana = (enabled) => {
updateConvertMessageToHiragana(enabled);
showNotification_SaveSuccess();
};
return {
// Auto Clear Message Input Box
currentEnableAutoClearMessageInputBox,
getEnableAutoClearMessageInputBox,
toggleEnableAutoClearMessageInputBox,
updateEnableAutoClearMessageInputBox,
setSuccessEnableAutoClearMessageInputBox,
// Send Only Translated Messages
currentEnableSendOnlyTranslatedMessages,
getEnableSendOnlyTranslatedMessages,
toggleEnableSendOnlyTranslatedMessages,
updateEnableSendOnlyTranslatedMessages,
setSuccessEnableSendOnlyTranslatedMessages,
// Auto Export Message Logs
currentEnableAutoExportMessageLogs,
getEnableAutoExportMessageLogs,
toggleEnableAutoExportMessageLogs,
updateEnableAutoExportMessageLogs,
setSuccessEnableAutoExportMessageLogs,
// VRC Mic Mute Sync
currentEnableVrcMicMuteSync,
getEnableVrcMicMuteSync,
getSuccessEnableVrcMicMuteSync,
toggleEnableVrcMicMuteSync,
updateEnableVrcMicMuteSync,
setSuccessEnableVrcMicMuteSync,
// Send Message To VRCT
currentEnableSendMessageToVrc,
getEnableSendMessageToVrc,
toggleEnableSendMessageToVrc,
updateEnableSendMessageToVrc,
setSuccessEnableSendMessageToVrc,
// Sounds
// Notification VRC SFX
currentEnableNotificationVrcSfx,
getEnableNotificationVrcSfx,
toggleEnableNotificationVrcSfx,
updateEnableNotificationVrcSfx,
setSuccessEnableNotificationVrcSfx,
// Speaker2Chatbox
// Send Received Message To VRC
currentEnableSendReceivedMessageToVrc,
getEnableSendReceivedMessageToVrc,
toggleEnableSendReceivedMessageToVrc,
updateEnableSendReceivedMessageToVrc,
setSuccessEnableSendReceivedMessageToVrc,
// Message Formats
currentMessageFormat_ExampleViewFilter,
toggleMessageFormat_ExampleViewFilter,
// Send
currentSendMessageFormatParts,
updateSendMessageFormatParts,
getSendMessageFormatParts,
setSendMessageFormatParts,
setSuccessSendMessageFormatParts,
// Received
currentReceivedMessageFormatParts,
updateReceivedMessageFormatParts,
getReceivedMessageFormatParts,
setReceivedMessageFormatParts,
setSuccessReceivedMessageFormatParts,
// Convert Message To Romaji
currentConvertMessageToRomaji,
getConvertMessageToRomaji,
toggleConvertMessageToRomaji,
updateConvertMessageToRomaji,
setSuccessConvertMessageToRomaji,
// Convert Message To Hiragana
currentConvertMessageToHiragana,
getConvertMessageToHiragana,
toggleConvertMessageToHiragana,
updateConvertMessageToHiragana,
setSuccessConvertMessageToHiragana,
};
};

View File

@@ -1,488 +0,0 @@
import {
useStore_MicRecordTimeout,
useStore_MicPhraseTimeout,
useStore_MicMaxWords,
useStore_MicWordFilterList,
useStore_SpeakerMaxWords,
useStore_SpeakerPhraseTimeout,
useStore_SpeakerRecordTimeout,
useStore_SelectableTranscriptionComputeDeviceList,
useStore_SelectedTranscriptionEngine,
useStore_SelectedTranscriptionComputeDevice,
useStore_WhisperWeightTypeStatus,
useStore_SelectedWhisperWeightType,
useStore_SelectedTranscriptionComputeType,
useStore_MicAvgLogprob,
useStore_MicNoSpeechProb,
useStore_SpeakerAvgLogprob,
useStore_SpeakerNoSpeechProb,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { transformToIndexedArray, arrayToObject } from "@utils";
import { useNotificationStatus } from "@logics_common";
export const useTranscription = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
// Mic
const { currentMicRecordTimeout, updateMicRecordTimeout, pendingMicRecordTimeout } = useStore_MicRecordTimeout();
const { currentMicPhraseTimeout, updateMicPhraseTimeout, pendingMicPhraseTimeout } = useStore_MicPhraseTimeout();
const { currentMicMaxWords, updateMicMaxWords, pendingMicMaxWords } = useStore_MicMaxWords();
const { currentMicWordFilterList, updateMicWordFilterList, pendingMicWordFilterList } = useStore_MicWordFilterList();
// Speaker
const { currentSpeakerRecordTimeout, updateSpeakerRecordTimeout, pendingSpeakerRecordTimeout } = useStore_SpeakerRecordTimeout();
const { currentSpeakerPhraseTimeout, updateSpeakerPhraseTimeout, pendingSpeakerPhraseTimeout } = useStore_SpeakerPhraseTimeout();
const { currentSpeakerMaxWords, updateSpeakerMaxWords, pendingSpeakerMaxWords } = useStore_SpeakerMaxWords();
// Transcription Engines
const { currentSelectedTranscriptionEngine, updateSelectedTranscriptionEngine, pendingSelectedTranscriptionEngine } = useStore_SelectedTranscriptionEngine();
const { currentWhisperWeightTypeStatus, updateWhisperWeightTypeStatus, pendingWhisperWeightTypeStatus } = useStore_WhisperWeightTypeStatus();
const { currentSelectedWhisperWeightType, updateSelectedWhisperWeightType, pendingSelectedWhisperWeightType } = useStore_SelectedWhisperWeightType();
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();
const { currentMicNoSpeechProb, updateMicNoSpeechProb, pendingMicNoSpeechProb } = useStore_MicNoSpeechProb();
const { currentSpeakerAvgLogprob, updateSpeakerAvgLogprob, pendingSpeakerAvgLogprob } = useStore_SpeakerAvgLogprob();
const { currentSpeakerNoSpeechProb, updateSpeakerNoSpeechProb, pendingSpeakerNoSpeechProb } = useStore_SpeakerNoSpeechProb();
// Mic
const getMicRecordTimeout = () => {
pendingMicRecordTimeout();
asyncStdoutToPython("/get/data/mic_record_timeout");
};
const setMicRecordTimeout = (selected_mic_record_timeout) => {
pendingMicRecordTimeout();
asyncStdoutToPython("/set/data/mic_record_timeout", selected_mic_record_timeout);
};
const setSuccessMicRecordTimeout = (value) => {
updateMicRecordTimeout(value);
showNotification_SaveSuccess();
};
const getMicPhraseTimeout = () => {
pendingMicPhraseTimeout();
asyncStdoutToPython("/get/data/mic_phrase_timeout");
};
const setMicPhraseTimeout = (selected_mic_phrase_timeout) => {
pendingMicPhraseTimeout();
asyncStdoutToPython("/set/data/mic_phrase_timeout", selected_mic_phrase_timeout);
};
const setSuccessMicPhraseTimeout = (value) => {
updateMicPhraseTimeout(value);
showNotification_SaveSuccess();
};
const getMicMaxWords = () => {
pendingMicMaxWords();
asyncStdoutToPython("/get/data/mic_max_phrases");
};
const setMicMaxWords = (selected_mic_max_phrases) => {
pendingMicMaxWords();
asyncStdoutToPython("/set/data/mic_max_phrases", selected_mic_max_phrases);
};
const setSuccessMicMaxWords = (value) => {
updateMicMaxWords(value);
showNotification_SaveSuccess();
};
const getMicWordFilterList = () => {
pendingMicWordFilterList();
asyncStdoutToPython("/get/data/mic_word_filter");
};
const setMicWordFilterList = (selected_mic_word_filter) => {
pendingMicWordFilterList();
asyncStdoutToPython("/set/data/mic_word_filter", selected_mic_word_filter);
};
const getSuccessMicWordFilterList = (payload) => {
updateMicWordFilterList((prev_list) => {
const updated_list = [...prev_list.data];
for (const value of payload) {
const existing_item = updated_list.find(item => item.value === value);
if (existing_item) {
existing_item.is_redoable = false;
} else {
updated_list.push({ value, is_redoable: false });
}
}
return updated_list;
});
};
const setSuccessMicWordFilterList = (payload) => {
updateMicWordFilterList((prev_list) => {
const updated_list = [...prev_list.data];
for (const value of payload) {
const existing_item = updated_list.find(item => item.value === value);
if (existing_item) {
existing_item.is_redoable = false;
} else {
updated_list.push({ value, is_redoable: false });
}
}
return updated_list;
});
showNotification_SaveSuccess();
};
// Speaker
const getSpeakerRecordTimeout = () => {
pendingSpeakerRecordTimeout();
asyncStdoutToPython("/get/data/speaker_record_timeout");
};
const setSpeakerRecordTimeout = (selected_speaker_record_timeout) => {
pendingSpeakerRecordTimeout();
asyncStdoutToPython("/set/data/speaker_record_timeout", selected_speaker_record_timeout);
};
const setSuccessSpeakerRecordTimeout = (value) => {
updateSpeakerRecordTimeout(value);
showNotification_SaveSuccess();
};
const getSpeakerPhraseTimeout = () => {
pendingSpeakerPhraseTimeout();
asyncStdoutToPython("/get/data/speaker_phrase_timeout");
};
const setSpeakerPhraseTimeout = (selected_speaker_phrase_timeout) => {
pendingSpeakerPhraseTimeout();
asyncStdoutToPython("/set/data/speaker_phrase_timeout", selected_speaker_phrase_timeout);
};
const setSuccessSpeakerPhraseTimeout = (value) => {
updateSpeakerPhraseTimeout(value);
showNotification_SaveSuccess();
};
const getSpeakerMaxWords = () => {
pendingSpeakerMaxWords();
asyncStdoutToPython("/get/data/speaker_max_phrases");
};
const setSpeakerMaxWords = (selected_speaker_max_phrases) => {
pendingSpeakerMaxWords();
asyncStdoutToPython("/set/data/speaker_max_phrases", selected_speaker_max_phrases);
};
const setSuccessSpeakerMaxWords = (value) => {
updateSpeakerMaxWords(value);
showNotification_SaveSuccess();
};
// Transcription Engines
// Transcription Engines (Google / Whisper)
const getSelectedTranscriptionEngine = () => {
pendingSelectedTranscriptionEngine();
asyncStdoutToPython("/get/data/selected_transcription_engine");
};
const setSelectedTranscriptionEngine = (selected_transcription_engine) => {
pendingSelectedTranscriptionEngine();
asyncStdoutToPython("/set/data/selected_transcription_engine", selected_transcription_engine);
};
const setSuccessSelectedTranscriptionEngine = (engine) => {
updateSelectedTranscriptionEngine(engine);
showNotification_SaveSuccess();
};
// Transcription Engines (Weight Type List)
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);
};
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();
asyncStdoutToPython("/get/data/whisper_weight_type");
};
const setSelectedWhisperWeightType = (selected_whisper_weight_type) => {
pendingSelectedWhisperWeightType();
asyncStdoutToPython("/set/data/whisper_weight_type", selected_whisper_weight_type);
};
const setSuccessSelectedWhisperWeightType = (wt) => {
updateSelectedWhisperWeightType(wt);
showNotification_SaveSuccess();
};
// Transcription Engines (Compute Device List)
const getSelectableTranscriptionComputeDeviceList = () => {
pendingSelectableTranscriptionComputeDeviceList();
asyncStdoutToPython("/get/data/transcription_compute_device_list");
};
const updateSelectableTranscriptionComputeDeviceList_FromBackend = (payload) => {
updateSelectableTranscriptionComputeDeviceList(transformToIndexedArray(payload));
};
// Transcription Engines (Selected Compute Device)
const getSelectedTranscriptionComputeDevice = () => {
pendingSelectedTranscriptionComputeDevice();
asyncStdoutToPython("/get/data/selected_transcription_compute_device");
};
const setSelectedTranscriptionComputeDevice = (selected_transcription_compute_device) => {
pendingSelectedTranscriptionComputeDevice();
asyncStdoutToPython("/set/data/selected_transcription_compute_device", selected_transcription_compute_device);
};
const setSuccessSelectedTranscriptionComputeDevice = (dev) => {
updateSelectedTranscriptionComputeDevice(dev);
showNotification_SaveSuccess();
};
// Advanced (Mic Avg Logprob)
const getMicAvgLogprob = () => {
pendingMicAvgLogprob();
asyncStdoutToPython("/get/data/mic_avg_logprob");
};
const setMicAvgLogprob = (selected_mic_avg_logprob) => {
pendingMicAvgLogprob();
asyncStdoutToPython("/set/data/mic_avg_logprob", selected_mic_avg_logprob);
};
const setSuccessMicAvgLogprob = (selected_mic_avg_logprob) => {
updateMicAvgLogprob(selected_mic_avg_logprob);
showNotification_SaveSuccess();
};
// Advanced (Mic No Speech Prob)
const getMicNoSpeechProb = () => {
pendingMicNoSpeechProb();
asyncStdoutToPython("/get/data/mic_no_speech_prob");
};
const setMicNoSpeechProb = (selected_mic_no_speech_prob) => {
pendingMicNoSpeechProb();
asyncStdoutToPython("/set/data/mic_no_speech_prob", selected_mic_no_speech_prob);
};
const setSuccessMicNoSpeechProb = (selected_mic_no_speech_prob) => {
updateMicNoSpeechProb(selected_mic_no_speech_prob);
showNotification_SaveSuccess();
};
// Advanced (Speaker Avg Logprob)
const getSpeakerAvgLogprob = () => {
pendingSpeakerAvgLogprob();
asyncStdoutToPython("/get/data/speaker_avg_logprob");
};
const setSpeakerAvgLogprob = (selected_speaker_avg_logprob) => {
pendingSpeakerAvgLogprob();
asyncStdoutToPython("/set/data/speaker_avg_logprob", selected_speaker_avg_logprob);
};
const setSuccessSpeakerAvgLogprob = (selected_speaker_avg_logprob) => {
updateSpeakerAvgLogprob(selected_speaker_avg_logprob);
showNotification_SaveSuccess();
};
// Advanced (Speaker No Speech Prob)
const getSpeakerNoSpeechProb = () => {
pendingSpeakerNoSpeechProb();
asyncStdoutToPython("/get/data/speaker_no_speech_prob");
};
const setSpeakerNoSpeechProb = (selected_speaker_no_speech_prob) => {
pendingSpeakerNoSpeechProb();
asyncStdoutToPython("/set/data/speaker_no_speech_prob", selected_speaker_no_speech_prob);
};
const setSuccessSpeakerNoSpeechProb = (selected_speaker_no_speech_prob) => {
updateSpeakerNoSpeechProb(selected_speaker_no_speech_prob);
showNotification_SaveSuccess();
};
return {
// Mic
currentMicRecordTimeout,
getMicRecordTimeout,
updateMicRecordTimeout,
setMicRecordTimeout,
setSuccessMicRecordTimeout,
currentMicPhraseTimeout,
getMicPhraseTimeout,
updateMicPhraseTimeout,
setMicPhraseTimeout,
setSuccessMicPhraseTimeout,
currentMicMaxWords,
getMicMaxWords,
updateMicMaxWords,
setMicMaxWords,
setSuccessMicMaxWords,
currentMicWordFilterList,
getMicWordFilterList,
getSuccessMicWordFilterList,
updateMicWordFilterList,
setMicWordFilterList,
setSuccessMicWordFilterList,
// Speaker
currentSpeakerRecordTimeout,
getSpeakerRecordTimeout,
updateSpeakerRecordTimeout,
setSpeakerRecordTimeout,
setSuccessSpeakerRecordTimeout,
currentSpeakerPhraseTimeout,
getSpeakerPhraseTimeout,
updateSpeakerPhraseTimeout,
setSpeakerPhraseTimeout,
setSuccessSpeakerPhraseTimeout,
currentSpeakerMaxWords,
getSpeakerMaxWords,
updateSpeakerMaxWords,
setSpeakerMaxWords,
setSuccessSpeakerMaxWords,
// Transcription Engines
currentSelectedTranscriptionEngine,
getSelectedTranscriptionEngine,
updateSelectedTranscriptionEngine,
setSelectedTranscriptionEngine,
setSuccessSelectedTranscriptionEngine,
currentWhisperWeightTypeStatus,
updateWhisperWeightTypeStatus,
updateDownloadedWhisperWeightTypeStatus,
updateDownloadProgressWhisperWeightTypeStatus,
pendingWhisperWeightType,
downloadedWhisperWeightType,
downloadWhisperWeight,
currentSelectedWhisperWeightType,
getSelectedWhisperWeightType,
updateSelectedWhisperWeightType,
setSelectedWhisperWeightType,
setSuccessSelectedWhisperWeightType,
currentSelectedTranscriptionComputeType,
getSelectedTranscriptionComputeType,
updateSelectedTranscriptionComputeType,
setSelectedTranscriptionComputeType,
setSuccessSelectedTranscriptionComputeType,
currentSelectableTranscriptionComputeDeviceList,
getSelectableTranscriptionComputeDeviceList,
updateSelectableTranscriptionComputeDeviceList,
updateSelectableTranscriptionComputeDeviceList_FromBackend,
currentSelectedTranscriptionComputeDevice,
getSelectedTranscriptionComputeDevice,
updateSelectedTranscriptionComputeDevice,
setSelectedTranscriptionComputeDevice,
setSuccessSelectedTranscriptionComputeDevice,
// Advanced
// Mic Avg Logprob
currentMicAvgLogprob,
getMicAvgLogprob,
updateMicAvgLogprob,
setMicAvgLogprob,
setSuccessMicAvgLogprob,
// Mic No Speech Prob
currentMicNoSpeechProb,
getMicNoSpeechProb,
updateMicNoSpeechProb,
setMicNoSpeechProb,
setSuccessMicNoSpeechProb,
// Speaker Avg Logprob
currentSpeakerAvgLogprob,
getSpeakerAvgLogprob,
updateSpeakerAvgLogprob,
setSpeakerAvgLogprob,
setSuccessSpeakerAvgLogprob,
// Speaker No Speech Prob
currentSpeakerNoSpeechProb,
getSpeakerNoSpeechProb,
updateSpeakerNoSpeechProb,
setSpeakerNoSpeechProb,
setSuccessSpeakerNoSpeechProb,
};
};

View File

@@ -1,198 +0,0 @@
import {
useStore_CTranslate2WeightTypeStatus,
useStore_SelectedCTranslate2WeightType,
useStore_SelectedTranslationComputeType,
useStore_SelectableTranslationComputeDeviceList,
useStore_SelectedTranslationComputeDevice,
useStore_DeepLAuthKey,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useI18n } from "@useI18n";
import { transformToIndexedArray, arrayToObject } from "@utils";
import { useNotificationStatus } from "@logics_common";
export const useTranslation = () => {
const { t } = useI18n();
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
const { currentCTranslate2WeightTypeStatus, updateCTranslate2WeightTypeStatus, pendingCTranslate2WeightTypeStatus } = useStore_CTranslate2WeightTypeStatus();
const { currentSelectedCTranslate2WeightType, updateSelectedCTranslate2WeightType, pendingSelectedCTranslate2WeightType } = useStore_SelectedCTranslate2WeightType();
const { currentSelectedTranslationComputeType, updateSelectedTranslationComputeType, pendingSelectedTranslationComputeType } = useStore_SelectedTranslationComputeType();
const { currentSelectableTranslationComputeDeviceList, updateSelectableTranslationComputeDeviceList, pendingSelectableTranslationComputeDeviceList } = useStore_SelectableTranslationComputeDeviceList();
const { currentSelectedTranslationComputeDevice, updateSelectedTranslationComputeDevice, pendingSelectedTranslationComputeDevice } = useStore_SelectedTranslationComputeDevice();
const { currentDeepLAuthKey, updateDeepLAuthKey, pendingDeepLAuthKey } = useStore_DeepLAuthKey();
const updateDownloadedCTranslate2WeightTypeStatus = (downloaded_weight_type_status) => {
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) => ({
...item,
is_downloaded: downloaded_weight_type_status[item.id] ?? item.is_downloaded,
}))
);
};
const updateDownloadProgressCTranslate2WeightTypeStatus = (payload) => {
if (payload === true) return console.error("fix me.");
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) =>
payload.weight_type === item.id
? { ...item, progress: payload.progress * 100 }
: item
)
);
};
const pendingCTranslate2WeightType = (id) => {
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_pending: true }
: item
)
);
};
const downloadedCTranslate2WeightType = (id) => {
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_downloaded: true, is_pending: false, progress: null }
: item
)
);
};
const downloadCTranslate2Weight = (weight_type) => {
asyncStdoutToPython("/run/download_ctranslate2_weight", weight_type);
};
const getSelectedCTranslate2WeightType = () => {
pendingSelectedCTranslate2WeightType();
asyncStdoutToPython("/get/data/ctranslate2_weight_type");
};
const setSelectedCTranslate2WeightType = (selected_ctranslate2_weight_type) => {
pendingSelectedCTranslate2WeightType();
asyncStdoutToPython("/set/data/ctranslate2_weight_type", selected_ctranslate2_weight_type);
};
const setSuccessSelectedCTranslate2WeightType = (selected_ctranslate2_weight_type) => {
updateSelectedCTranslate2WeightType(selected_ctranslate2_weight_type);
showNotification_SaveSuccess();
};
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 updateSelectableTranslationComputeDeviceList_FromBackend = (payload) => {
updateSelectableTranslationComputeDeviceList(transformToIndexedArray(payload));
};
const getSelectedTranslationComputeDevice = () => {
pendingSelectedTranslationComputeDevice();
asyncStdoutToPython("/get/data/selected_translation_compute_device");
};
const setSelectedTranslationComputeDevice = (selected_translation_compute_device) => {
pendingSelectedTranslationComputeDevice();
asyncStdoutToPython("/set/data/selected_translation_compute_device", selected_translation_compute_device);
};
const setSuccessSelectedTranslationComputeDevice = (selected_translation_compute_device) => {
updateSelectedTranslationComputeDevice(selected_translation_compute_device);
showNotification_SaveSuccess();
};
const getDeepLAuthKey = () => {
pendingDeepLAuthKey();
asyncStdoutToPython("/get/data/deepl_auth_key");
};
const setDeepLAuthKey = (selected_deepl_auth_key) => {
pendingDeepLAuthKey();
asyncStdoutToPython("/set/data/deepl_auth_key", selected_deepl_auth_key);
};
const setSuccessDeepLAuthKey = (data) => {
updateDeepLAuthKey(data);
showNotification_SaveSuccess(t("config_page.translation.deepl_auth_key.auth_key_success"), { category_id: "deepl_auth_key" });
};
const deleteDeepLAuthKey = () => {
pendingDeepLAuthKey();
asyncStdoutToPython("/delete/data/deepl_auth_key");
};
const deleteSuccessDeepLAuthKey = () => {
updateDeepLAuthKey("");
};
return {
currentCTranslate2WeightTypeStatus,
updateCTranslate2WeightTypeStatus,
updateDownloadedCTranslate2WeightTypeStatus,
updateDownloadProgressCTranslate2WeightTypeStatus,
pendingCTranslate2WeightType,
downloadedCTranslate2WeightType,
downloadCTranslate2Weight,
currentSelectedCTranslate2WeightType,
getSelectedCTranslate2WeightType,
updateSelectedCTranslate2WeightType,
setSelectedCTranslate2WeightType,
setSuccessSelectedCTranslate2WeightType,
currentSelectedTranslationComputeType,
getSelectedTranslationComputeType,
updateSelectedTranslationComputeType,
setSelectedTranslationComputeType,
setSuccessSelectedTranslationComputeType,
currentSelectableTranslationComputeDeviceList,
getSelectableTranslationComputeDeviceList,
updateSelectableTranslationComputeDeviceList,
updateSelectableTranslationComputeDeviceList_FromBackend,
currentSelectedTranslationComputeDevice,
getSelectedTranslationComputeDevice,
updateSelectedTranslationComputeDevice,
setSelectedTranslationComputeDevice,
setSuccessSelectedTranslationComputeDevice,
currentDeepLAuthKey,
getDeepLAuthKey,
updateDeepLAuthKey,
setDeepLAuthKey,
deleteDeepLAuthKey,
deleteSuccessDeepLAuthKey,
setSuccessDeepLAuthKey,
};
};

View File

@@ -1,145 +0,0 @@
import {
useStore_IsEnabledOverlaySmallLog,
useStore_IsEnabledOverlayLargeLog,
useStore_OverlaySmallLogSettings,
useStore_OverlayLargeLogSettings,
useStore_OverlayShowOnlyTranslatedMessages,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useNotificationStatus } from "@logics_common";
export const useVr = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
const { currentIsEnabledOverlaySmallLog, updateIsEnabledOverlaySmallLog, pendingIsEnabledOverlaySmallLog } = useStore_IsEnabledOverlaySmallLog();
const { currentIsEnabledOverlayLargeLog, updateIsEnabledOverlayLargeLog, pendingIsEnabledOverlayLargeLog } = useStore_IsEnabledOverlayLargeLog();
const { currentOverlaySmallLogSettings, updateOverlaySmallLogSettings, pendingOverlaySmallLogSettings } = useStore_OverlaySmallLogSettings();
const { currentOverlayLargeLogSettings, updateOverlayLargeLogSettings, pendingOverlayLargeLogSettings } = useStore_OverlayLargeLogSettings();
const { currentOverlayShowOnlyTranslatedMessages, updateOverlayShowOnlyTranslatedMessages, pendingOverlayShowOnlyTranslatedMessages } = useStore_OverlayShowOnlyTranslatedMessages();
const getIsEnabledOverlaySmallLog = () => {
pendingIsEnabledOverlaySmallLog();
asyncStdoutToPython("/get/data/overlay_small_log");
};
const toggleIsEnabledOverlaySmallLog = () => {
pendingIsEnabledOverlaySmallLog();
if (currentIsEnabledOverlaySmallLog.data) {
asyncStdoutToPython("/set/disable/overlay_small_log");
} else {
asyncStdoutToPython("/set/enable/overlay_small_log");
}
};
const setSuccessIsEnabledOverlaySmallLog = (enabled) => {
updateIsEnabledOverlaySmallLog(enabled);
showNotification_SaveSuccess();
};
const getIsEnabledOverlayLargeLog = () => {
pendingIsEnabledOverlayLargeLog();
asyncStdoutToPython("/get/data/overlay_large_log");
};
const toggleIsEnabledOverlayLargeLog = () => {
pendingIsEnabledOverlayLargeLog();
if (currentIsEnabledOverlayLargeLog.data) {
asyncStdoutToPython("/set/disable/overlay_large_log");
} else {
asyncStdoutToPython("/set/enable/overlay_large_log");
}
};
const setSuccessIsEnabledOverlayLargeLog = (enabled) => {
updateIsEnabledOverlayLargeLog(enabled);
showNotification_SaveSuccess();
};
const getOverlaySmallLogSettings = () => {
// pendingOverlaySmallLogSettings();
asyncStdoutToPython("/get/data/overlay_small_log_settings");
};
const setOverlaySmallLogSettings = (overlay_small_log_settings) => {
// pendingOverlaySmallLogSettings();
asyncStdoutToPython("/set/data/overlay_small_log_settings", overlay_small_log_settings);
};
const setSuccessOverlaySmallLogSettings = (settings) => {
updateOverlaySmallLogSettings(settings);
showNotification_SaveSuccess();
};
const getOverlayLargeLogSettings = () => {
// pendingOverlayLargeLogSettings();
asyncStdoutToPython("/get/data/overlay_large_log_settings");
};
const setOverlayLargeLogSettings = (overlay_large_log_settings) => {
// pendingOverlayLargeLogSettings();
asyncStdoutToPython("/set/data/overlay_large_log_settings", overlay_large_log_settings);
};
const setSuccessOverlayLargeLogSettings = (settings) => {
updateOverlayLargeLogSettings(settings);
showNotification_SaveSuccess();
};
const getOverlayShowOnlyTranslatedMessages = () => {
pendingOverlayShowOnlyTranslatedMessages();
asyncStdoutToPython("/get/data/overlay_show_only_translated_messages");
};
const toggleOverlayShowOnlyTranslatedMessages = () => {
pendingOverlayShowOnlyTranslatedMessages();
if (currentOverlayShowOnlyTranslatedMessages.data) {
asyncStdoutToPython("/set/disable/overlay_show_only_translated_messages");
} else {
asyncStdoutToPython("/set/enable/overlay_show_only_translated_messages");
}
};
const setSuccessOverlayShowOnlyTranslatedMessages = (enabled) => {
updateOverlayShowOnlyTranslatedMessages(enabled);
showNotification_SaveSuccess();
};
const sendTextToOverlay = (text) => {
asyncStdoutToPython("/run/send_text_overlay", text);
};
return {
currentIsEnabledOverlaySmallLog,
getIsEnabledOverlaySmallLog,
toggleIsEnabledOverlaySmallLog,
updateIsEnabledOverlaySmallLog,
setSuccessIsEnabledOverlaySmallLog,
currentIsEnabledOverlayLargeLog,
getIsEnabledOverlayLargeLog,
toggleIsEnabledOverlayLargeLog,
updateIsEnabledOverlayLargeLog,
setSuccessIsEnabledOverlayLargeLog,
currentOverlaySmallLogSettings,
getOverlaySmallLogSettings,
updateOverlaySmallLogSettings,
setOverlaySmallLogSettings,
setSuccessOverlaySmallLogSettings,
currentOverlayLargeLogSettings,
getOverlayLargeLogSettings,
updateOverlayLargeLogSettings,
setOverlayLargeLogSettings,
setSuccessOverlayLargeLogSettings,
currentOverlayShowOnlyTranslatedMessages,
getOverlayShowOnlyTranslatedMessages,
toggleOverlayShowOnlyTranslatedMessages,
updateOverlayShowOnlyTranslatedMessages,
setSuccessOverlayShowOnlyTranslatedMessages,
sendTextToOverlay,
};
};