[Update] Save and register -able.
This commit is contained in:
@@ -533,6 +533,19 @@ class Config:
|
|||||||
self._MIC_WORD_FILTER = sorted(set(value), key=value.index)
|
self._MIC_WORD_FILTER = sorted(set(value), key=value.index)
|
||||||
self.saveConfig(inspect.currentframe().f_code.co_name, value)
|
self.saveConfig(inspect.currentframe().f_code.co_name, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@json_serializable('HOTKEYS')
|
||||||
|
def HOTKEYS(self):
|
||||||
|
return self._HOTKEYS
|
||||||
|
|
||||||
|
@HOTKEYS.setter
|
||||||
|
def HOTKEYS(self, value):
|
||||||
|
if isinstance(value, dict) and set(value.keys()) == set(self.HOTKEYS.keys()):
|
||||||
|
for key, value in value.items():
|
||||||
|
if isinstance(value, list) or value is None:
|
||||||
|
self._HOTKEYS[key] = value
|
||||||
|
self.saveConfig(inspect.currentframe().f_code.co_name, self.HOTKEYS, immediate_save=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@json_serializable('MIC_AVG_LOGPROB')
|
@json_serializable('MIC_AVG_LOGPROB')
|
||||||
def MIC_AVG_LOGPROB(self):
|
def MIC_AVG_LOGPROB(self):
|
||||||
@@ -1026,6 +1039,9 @@ class Config:
|
|||||||
self._MIC_PHRASE_TIMEOUT = 3
|
self._MIC_PHRASE_TIMEOUT = 3
|
||||||
self._MIC_MAX_PHRASES = 10
|
self._MIC_MAX_PHRASES = 10
|
||||||
self._MIC_WORD_FILTER = []
|
self._MIC_WORD_FILTER = []
|
||||||
|
self._HOTKEYS = {
|
||||||
|
"toggle_active_vrct": None,
|
||||||
|
}
|
||||||
self._MIC_AVG_LOGPROB = -0.8
|
self._MIC_AVG_LOGPROB = -0.8
|
||||||
self._MIC_NO_SPEECH_PROB = 0.6
|
self._MIC_NO_SPEECH_PROB = 0.6
|
||||||
self._AUTO_SPEAKER_SELECT = True
|
self._AUTO_SPEAKER_SELECT = True
|
||||||
|
|||||||
@@ -996,6 +996,15 @@ class Controller:
|
|||||||
response = {"status":200, "result":config.SPEAKER_MAX_PHRASES}
|
response = {"status":200, "result":config.SPEAKER_MAX_PHRASES}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getHotkeys(*args, **kwargs) -> dict:
|
||||||
|
return {"status":200, "result":config.HOTKEYS}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def setHotkeys(data, *args, **kwargs) -> dict:
|
||||||
|
config.HOTKEYS = data
|
||||||
|
return {"status":200, "result":config.HOTKEYS}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getSpeakerAvgLogprob(*args, **kwargs) -> dict:
|
def getSpeakerAvgLogprob(*args, **kwargs) -> dict:
|
||||||
return {"status":200, "result":config.SPEAKER_AVG_LOGPROB}
|
return {"status":200, "result":config.SPEAKER_AVG_LOGPROB}
|
||||||
|
|||||||
@@ -183,6 +183,9 @@ mapping = {
|
|||||||
"/get/data/mic_max_phrases": {"status": True, "variable":controller.getMicMaxPhrases},
|
"/get/data/mic_max_phrases": {"status": True, "variable":controller.getMicMaxPhrases},
|
||||||
"/set/data/mic_max_phrases": {"status": True, "variable":controller.setMicMaxPhrases},
|
"/set/data/mic_max_phrases": {"status": True, "variable":controller.setMicMaxPhrases},
|
||||||
|
|
||||||
|
"/get/data/hotkeys": {"status": True, "variable":controller.getHotkeys},
|
||||||
|
"/set/data/hotkeys": {"status": True, "variable":controller.setHotkeys},
|
||||||
|
|
||||||
"/get/data/mic_avg_logprob": {"status": True, "variable":controller.getMicAvgLogprob},
|
"/get/data/mic_avg_logprob": {"status": True, "variable":controller.getMicAvgLogprob},
|
||||||
"/set/data/mic_avg_logprob": {"status": True, "variable":controller.setMicAvgLogprob},
|
"/set/data/mic_avg_logprob": {"status": True, "variable":controller.setMicAvgLogprob},
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,16 @@ const _Entry = forwardRef((props, ref) => {
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
|
text={props.text ? props.text : "text"}
|
||||||
|
placeholder={props.placeholder ? props.placeholder : ""}
|
||||||
className={input_class_names}
|
className={input_class_names}
|
||||||
value={props.ui_variable === null ? "" : props.ui_variable}
|
value={props.ui_variable === null ? "" : props.ui_variable}
|
||||||
onChange={(e) => props.onChange(e)}
|
onChange={(e) => props.onChange?.(e)}
|
||||||
{...props}
|
onFocus={(e) => props.onFocus?.(e)}
|
||||||
|
onBlur={(e) => props.onBlur?.(e)}
|
||||||
|
onKeyDown={(e) => props.onKeyDown?.(e)}
|
||||||
|
onKeyUp={(e) => props.onKeyUp?.(e)}
|
||||||
|
readOnly={props.readOnly === true ? true : false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
import styles from "./HotkeysEntry.module.scss";
|
import styles from "./HotkeysEntry.module.scss";
|
||||||
import { _Entry } from "../_atoms/_entry/_Entry";
|
import { _Entry } from "../_atoms/_entry/_Entry";
|
||||||
import { useState, useRef } from "react";
|
import { useState, useRef, useEffect } from "react";
|
||||||
|
import DeleteSvg from "@images/cancel.svg?react";
|
||||||
|
import { clsx } from "clsx";
|
||||||
|
|
||||||
export const HotkeysEntry = (props) => {
|
export const HotkeysEntry = (props) => {
|
||||||
const [isAcceptingInput, setIsAcceptingInput] = useState(false);
|
const [isAcceptingInput, setIsAcceptingInput] = useState(false);
|
||||||
const [displayValue, setDisplayValue] = useState(props.value[props.hotkey_id]);
|
const [displayValue, setDisplayValue] = useState("");
|
||||||
const lastKeyRef = useRef(null);
|
const lastKeyRef = useRef(null);
|
||||||
const isModifierOnlyRef = useRef(false);
|
const isModifierOnlyRef = useRef(false);
|
||||||
const entryRef = useRef(null);
|
const entryRef = useRef(null);
|
||||||
const pressedKeys = useRef(new Set());
|
const pressedKeys = useRef(new Set());
|
||||||
const keysRef = useRef([]);
|
const keysRef = useRef([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const init_display_value = props.value[props.hotkey_id] ? props.value[props.hotkey_id].join(" + ") : "";
|
||||||
|
setDisplayValue(init_display_value);
|
||||||
|
}, []);
|
||||||
|
console.log(props.value[props.hotkey_id]);
|
||||||
|
|
||||||
|
|
||||||
const updateHotkeys = (keys) => {
|
const updateHotkeys = (keys) => {
|
||||||
entryRef.current.blur();
|
entryRef.current.blur();
|
||||||
props.setHotkeys({ [props.hotkey_id]: keys });
|
props.setHotkeys({ [props.hotkey_id]: keys });
|
||||||
@@ -85,23 +94,25 @@ export const HotkeysEntry = (props) => {
|
|||||||
setDisplayValue("");
|
setDisplayValue("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const is_pending = props.state === "pending";
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
|
{is_pending && <span className={styles.loader}></span>}
|
||||||
<_Entry
|
<_Entry
|
||||||
ref={entryRef}
|
ref={entryRef}
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Press hotkeys keys"
|
|
||||||
onFocus={() => setIsAcceptingInput(true)}
|
onFocus={() => setIsAcceptingInput(true)}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onKeyUp={handleKeyUp}
|
onKeyUp={handleKeyUp}
|
||||||
value={displayValue}
|
ui_variable={displayValue}
|
||||||
width="20rem"
|
width="20rem"
|
||||||
is_activated={isAcceptingInput}
|
is_activated={isAcceptingInput}
|
||||||
|
is_disabled={is_pending}
|
||||||
readOnly
|
readOnly
|
||||||
/>
|
/>
|
||||||
<button className={styles.delete_button} onClick={handleDelete}>
|
<button className={clsx(styles.delete_button, { [styles.is_pending]: is_pending })} onClick={handleDelete}>
|
||||||
Delete
|
<DeleteSvg className={styles.delete_svg}/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,41 @@
|
|||||||
|
@import "@scss_mixins";
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.delete_button {
|
.delete_button {
|
||||||
padding: 0.8rem;
|
padding: 0.4rem;
|
||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
background-color: var(--dark_800_color);
|
// background-color: var(--dark_800_color);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 0.2rem;
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--dark_850_color);
|
||||||
|
}
|
||||||
|
&:active {
|
||||||
|
background-color: var(--dark_900_color);
|
||||||
|
}
|
||||||
|
&.is_pending {
|
||||||
|
pointer-events: none;
|
||||||
|
& .delete_svg {
|
||||||
|
color: var(--dark_600_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete_svg {
|
||||||
|
width: 2.2rem;
|
||||||
|
color: var(--error_bc_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
@include loader(2rem, 0.2rem, left, -2.2rem);
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ const HotkeysBoxContainer = () => {
|
|||||||
label="Toggle active input box"
|
label="Toggle active input box"
|
||||||
hotkey_id="toggle_active_vrct"
|
hotkey_id="toggle_active_vrct"
|
||||||
value={currentHotkeys.data}
|
value={currentHotkeys.data}
|
||||||
|
state={currentHotkeys.state}
|
||||||
setHotkeys={setHotkeys}
|
setHotkeys={setHotkeys}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
import { useStore_Hotkeys } from "@store";
|
import { useStore_Hotkeys } from "@store";
|
||||||
// import { useStdoutToPython } from "@logics/useStdoutToPython";
|
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||||
|
|
||||||
export const useHotkeys = () => {
|
export const useHotkeys = () => {
|
||||||
// const { asyncStdoutToPython } = useStdoutToPython();
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
const { currentHotkeys, updateHotkeys, pendingHotkeys } = useStore_Hotkeys();
|
const { currentHotkeys, updateHotkeys, pendingHotkeys } = useStore_Hotkeys();
|
||||||
|
|
||||||
const getHotkeys = () => {
|
const getHotkeys = () => {
|
||||||
// pendingHotkeys();
|
pendingHotkeys();
|
||||||
// asyncStdoutToPython("/get/data/osc_ip_address");
|
asyncStdoutToPython("/get/data/hotkeys");
|
||||||
};
|
};
|
||||||
|
|
||||||
const setHotkeys = (hotkeys) => {
|
const setHotkeys = (hotkeys) => {
|
||||||
updateHotkeys(hotkeys);
|
pendingHotkeys();
|
||||||
// pendingHotkeys();
|
asyncStdoutToPython("/set/data/hotkeys", hotkeys);
|
||||||
// asyncStdoutToPython("/set/data/osc_ip_address", osc_ip_address);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentHotkeys,
|
currentHotkeys,
|
||||||
// getHotkeys,
|
getHotkeys,
|
||||||
updateHotkeys,
|
updateHotkeys,
|
||||||
setHotkeys,
|
setHotkeys,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ import {
|
|||||||
useIsEnabledOverlayLargeLog,
|
useIsEnabledOverlayLargeLog,
|
||||||
useOverlayLargeLogSettings,
|
useOverlayLargeLogSettings,
|
||||||
useOverlayShowOnlyTranslatedMessages,
|
useOverlayShowOnlyTranslatedMessages,
|
||||||
|
useHotkeys,
|
||||||
useOscIpAddress,
|
useOscIpAddress,
|
||||||
useOscPort,
|
useOscPort,
|
||||||
} from "@logics_configs";
|
} from "@logics_configs";
|
||||||
@@ -168,6 +169,8 @@ export const useReceiveRoutes = () => {
|
|||||||
const { updateIsEnabledOverlayLargeLog } = useIsEnabledOverlayLargeLog();
|
const { updateIsEnabledOverlayLargeLog } = useIsEnabledOverlayLargeLog();
|
||||||
const { updateOverlayShowOnlyTranslatedMessages } = useOverlayShowOnlyTranslatedMessages();
|
const { updateOverlayShowOnlyTranslatedMessages } = useOverlayShowOnlyTranslatedMessages();
|
||||||
|
|
||||||
|
const { updateHotkeys } = useHotkeys();
|
||||||
|
|
||||||
const { updateOscIpAddress } = useOscIpAddress();
|
const { updateOscIpAddress } = useOscIpAddress();
|
||||||
const { updateOscPort } = useOscPort();
|
const { updateOscPort } = useOscPort();
|
||||||
|
|
||||||
@@ -458,6 +461,10 @@ export const useReceiveRoutes = () => {
|
|||||||
"/set/enable/send_received_message_to_vrc": updateEnableSendReceivedMessageToVrc,
|
"/set/enable/send_received_message_to_vrc": updateEnableSendReceivedMessageToVrc,
|
||||||
"/set/disable/send_received_message_to_vrc": updateEnableSendReceivedMessageToVrc,
|
"/set/disable/send_received_message_to_vrc": updateEnableSendReceivedMessageToVrc,
|
||||||
|
|
||||||
|
// Hotkeys
|
||||||
|
"/get/data/hotkeys": updateHotkeys,
|
||||||
|
"/set/data/hotkeys": updateHotkeys,
|
||||||
|
|
||||||
// Advanced Settings
|
// Advanced Settings
|
||||||
"/get/data/osc_ip_address": updateOscIpAddress,
|
"/get/data/osc_ip_address": updateOscIpAddress,
|
||||||
"/set/data/osc_ip_address": updateOscIpAddress,
|
"/set/data/osc_ip_address": updateOscIpAddress,
|
||||||
|
|||||||
Reference in New Issue
Block a user