fix: centralize OpenAI voice definitions and fix voice array state loading in voice assistant (#7390)

 (constants.ts): add new constants for OpenAI voices to be used in the application
🔧 (audio-settings-dialog.tsx, voice-select.tsx, check-provider.ts, voiceStore.ts): import and use the newly added OpenAI voices constants in various components and store to improve maintainability and consistency in voice selection functionality
This commit is contained in:
Cristhian Zanforlin Lousa 2025-04-01 16:22:25 -03:00 committed by GitHub
commit c1c6bfa478
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 13 deletions

View file

@ -1049,3 +1049,14 @@ export const DEBOUNCE_FIELD_LIST = [
"FloatInput",
"SliderInput",
];
export const OPENAI_VOICES = [
{ name: "alloy", value: "alloy" },
{ name: "ash", value: "ash" },
{ name: "ballad", value: "ballad" },
{ name: "coral", value: "coral" },
{ name: "echo", value: "echo" },
{ name: "sage", value: "sage" },
{ name: "shimmer", value: "shimmer" },
{ name: "verse", value: "verse" },
];

View file

@ -75,7 +75,7 @@ const SettingsVoiceModal = ({
name: string;
value: string;
}[]
>([]);
>(openaiVoices);
const saveButtonClicked = useRef(false);

View file

@ -1,3 +1,4 @@
import { OPENAI_VOICES } from "@/constants/constants";
import IconComponent from "../../../../../../../../../../components/common/genericIconComponent";
import ShadTooltip from "../../../../../../../../../../components/common/shadTooltipComponent";
import {
@ -21,6 +22,8 @@ const VoiceSelect = ({
handleSetVoice,
allVoices,
}: VoiceSelectProps) => {
allVoices = allVoices?.length === 0 || !allVoices ? OPENAI_VOICES : allVoices;
return (
<div className="grid w-full items-center gap-2">
<span className="flex w-full items-center text-sm">

View file

@ -4,7 +4,7 @@ export const checkProvider = () => {
const audioSettings = JSON.parse(
getLocalStorage("lf_audio_settings_playground") || "{}",
);
if (!audioSettings.provider) {
if (!audioSettings?.provider) {
setLocalStorage(
"lf_audio_settings_playground",
JSON.stringify({ provider: "openai", voice: "alloy" }),

View file

@ -286,7 +286,7 @@ export function VoiceAssistant({
audioContextRef.current = null;
}
};
}, []);
}, [setShowAudioInput]);
const scrollToBottom = () => {
setTimeout(() => {

View file

@ -1,3 +1,4 @@
import { OPENAI_VOICES } from "@/constants/constants";
import { VoiceStoreType } from "@/types/zustand/voice/voice.types";
import { create } from "zustand";
@ -19,16 +20,7 @@ export const useVoiceStore = create<VoiceStoreType>((set, get) => ({
value: string;
}[],
) => set({ providersList }),
openaiVoices: [
{ name: "alloy", value: "alloy" },
{ name: "ash", value: "ash" },
{ name: "ballad", value: "ballad" },
{ name: "coral", value: "coral" },
{ name: "echo", value: "echo" },
{ name: "sage", value: "sage" },
{ name: "shimmer", value: "shimmer" },
{ name: "verse", value: "verse" },
],
openaiVoices: OPENAI_VOICES,
setOpenaiVoices: (
openaiVoices: {
name: string;