mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🤖 refactor: Improve Speech Settings Initialization (#7869)
* ✨ feat: Implement speech settings initialization and update settings handling * 🔧 fix: Ensure setters reference is included in useEffect dependencies for speech settings initialization * chore: Update setter reference in useSpeechSettingsInit for improved type safety --------- Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
55f79bd2d1
commit
46ff008b07
4 changed files with 65 additions and 10 deletions
|
|
@ -76,16 +76,10 @@ function Speech() {
|
|||
playbackRate: { value: playbackRate, setFunc: setPlaybackRate },
|
||||
};
|
||||
|
||||
if (
|
||||
(settings[key].value !== newValue || settings[key].value === newValue || !settings[key]) &&
|
||||
settings[key].value === 'sttExternal' &&
|
||||
settings[key].value === 'ttsExternal'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const setting = settings[key];
|
||||
setting.setFunc(newValue);
|
||||
if (setting) {
|
||||
setting.setFunc(newValue);
|
||||
}
|
||||
},
|
||||
[
|
||||
sttExternal,
|
||||
|
|
@ -130,13 +124,20 @@ function Speech() {
|
|||
useEffect(() => {
|
||||
if (data && data.message !== 'not_found') {
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
updateSetting(key, value);
|
||||
// Only apply config values as defaults if no user preference exists in localStorage
|
||||
const existingValue = localStorage.getItem(key);
|
||||
if (existingValue === null && key !== 'sttExternal' && key !== 'ttsExternal') {
|
||||
updateSetting(key, value);
|
||||
} else if (key === 'sttExternal' || key === 'ttsExternal') {
|
||||
updateSetting(key, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [data]);
|
||||
|
||||
// Reset engineTTS if it is set to a removed/invalid value (e.g., 'edge')
|
||||
// TODO: remove this once the 'edge' engine is fully deprecated
|
||||
useEffect(() => {
|
||||
const validEngines = ['browser', 'external'];
|
||||
if (!validEngines.includes(engineTTS)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue