[Update] Config Page: Device Tab. Add dynamic energy threshold functionally and sync slider and entry component.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { useStore_MicThreshold } from "@store";
|
||||
import { useStore_MicThreshold, useStore_EnableAutomaticMicThreshold } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useMicThreshold = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { updateMicThreshold, currentMicThreshold } = useStore_MicThreshold();
|
||||
const { updateEnableAutomaticMicThreshold, currentEnableAutomaticMicThreshold } = useStore_EnableAutomaticMicThreshold();
|
||||
|
||||
const getMicThreshold = () => {
|
||||
asyncStdoutToPython("/config/input_mic_energy_threshold");
|
||||
@@ -13,10 +14,29 @@ export const useMicThreshold = () => {
|
||||
asyncStdoutToPython("/controller/callback_set_mic_energy_threshold", mic_threshold);
|
||||
};
|
||||
|
||||
const getEnableAutomaticMicThreshold = () => {
|
||||
updateEnableAutomaticMicThreshold(() => new Promise(() => {}));
|
||||
asyncStdoutToPython("/config/input_mic_dynamic_energy_threshold");
|
||||
};
|
||||
|
||||
const toggleEnableAutomaticMicThreshold = () => {
|
||||
updateEnableAutomaticMicThreshold(() => new Promise(() => {}));
|
||||
if (currentEnableAutomaticMicThreshold.data) {
|
||||
asyncStdoutToPython("/controller/callback_disable_mic_dynamic_energy_threshold");
|
||||
} else {
|
||||
asyncStdoutToPython("/controller/callback_enable_mic_dynamic_energy_threshold");
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
currentMicThreshold,
|
||||
getMicThreshold,
|
||||
setMicThreshold,
|
||||
updateMicThreshold,
|
||||
|
||||
currentEnableAutomaticMicThreshold,
|
||||
getEnableAutomaticMicThreshold,
|
||||
toggleEnableAutomaticMicThreshold,
|
||||
updateEnableAutomaticMicThreshold,
|
||||
};
|
||||
};
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useStore_SpeakerThreshold } from "@store";
|
||||
import { useStore_SpeakerThreshold, useStore_EnableAutomaticSpeakerThreshold } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSpeakerThreshold = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { updateSpeakerThreshold, currentSpeakerThreshold } = useStore_SpeakerThreshold();
|
||||
const { updateEnableAutomaticSpeakerThreshold, currentEnableAutomaticSpeakerThreshold } = useStore_EnableAutomaticSpeakerThreshold();
|
||||
|
||||
const getSpeakerThreshold = () => {
|
||||
asyncStdoutToPython("/config/input_speaker_energy_threshold");
|
||||
@@ -13,10 +14,29 @@ export const useSpeakerThreshold = () => {
|
||||
asyncStdoutToPython("/controller/callback_set_speaker_energy_threshold", speaker_threshold);
|
||||
};
|
||||
|
||||
const getEnableAutomaticSpeakerThreshold = () => {
|
||||
updateEnableAutomaticSpeakerThreshold(() => new Promise(() => {}));
|
||||
asyncStdoutToPython("/config/input_speaker_dynamic_energy_threshold");
|
||||
};
|
||||
|
||||
const toggleEnableAutomaticSpeakerThreshold = () => {
|
||||
updateEnableAutomaticSpeakerThreshold(() => new Promise(() => {}));
|
||||
if (currentEnableAutomaticSpeakerThreshold.data) {
|
||||
asyncStdoutToPython("/controller/callback_disable_speaker_dynamic_energy_threshold");
|
||||
} else {
|
||||
asyncStdoutToPython("/controller/callback_enable_speaker_dynamic_energy_threshold");
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
currentSpeakerThreshold,
|
||||
getSpeakerThreshold,
|
||||
setSpeakerThreshold,
|
||||
updateSpeakerThreshold,
|
||||
|
||||
currentEnableAutomaticSpeakerThreshold,
|
||||
getEnableAutomaticSpeakerThreshold,
|
||||
toggleEnableAutomaticSpeakerThreshold,
|
||||
updateEnableAutomaticSpeakerThreshold,
|
||||
};
|
||||
};
|
||||
@@ -36,8 +36,10 @@ export const useReceiveRoutes = () => {
|
||||
const { updateSelectedMicDevice } = useSelectedMicDevice();
|
||||
const { updateSpeakerDeviceList } = useSpeakerDeviceList();
|
||||
const { updateSelectedSpeakerDevice } = useSelectedSpeakerDevice();
|
||||
const { updateMicThreshold } = useMicThreshold();
|
||||
const { updateSpeakerThreshold } = useSpeakerThreshold();
|
||||
|
||||
const { updateMicThreshold, updateEnableAutomaticMicThreshold } = useMicThreshold();
|
||||
const { updateSpeakerThreshold, updateEnableAutomaticSpeakerThreshold } = useSpeakerThreshold();
|
||||
|
||||
const { updateEnableAutoClearMessageBox } = useEnableAutoClearMessageBox();
|
||||
const { updateSendMessageButtonType } = useSendMessageButtonType();
|
||||
|
||||
@@ -94,6 +96,12 @@ export const useReceiveRoutes = () => {
|
||||
"/config/input_speaker_energy_threshold": updateSpeakerThreshold,
|
||||
"/controller/callback_set_speaker_energy_threshold": updateSpeakerThreshold,
|
||||
|
||||
"/config/input_mic_dynamic_energy_threshold": updateEnableAutomaticMicThreshold,
|
||||
"/controller/callback_enable_mic_dynamic_energy_threshold": updateEnableAutomaticMicThreshold,
|
||||
"/controller/callback_disable_mic_dynamic_energy_threshold": updateEnableAutomaticMicThreshold,
|
||||
"/config/input_speaker_dynamic_energy_threshold": updateEnableAutomaticSpeakerThreshold,
|
||||
"/controller/callback_enable_speaker_dynamic_energy_threshold": updateEnableAutomaticSpeakerThreshold,
|
||||
"/controller/callback_disable_speaker_dynamic_energy_threshold": updateEnableAutomaticSpeakerThreshold,
|
||||
|
||||
"/controller/callback_messagebox_send": updateSentMessageLogById,
|
||||
"/action/transcription_send_mic_message": addSentMessageLog,
|
||||
|
||||
Reference in New Issue
Block a user