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:
parent
e58f764f3d
commit
c1c6bfa478
6 changed files with 19 additions and 13 deletions
|
|
@ -1049,3 +1049,14 @@ export const DEBOUNCE_FIELD_LIST = [
|
||||||
"FloatInput",
|
"FloatInput",
|
||||||
"SliderInput",
|
"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" },
|
||||||
|
];
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ const SettingsVoiceModal = ({
|
||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value: string;
|
||||||
}[]
|
}[]
|
||||||
>([]);
|
>(openaiVoices);
|
||||||
|
|
||||||
const saveButtonClicked = useRef(false);
|
const saveButtonClicked = useRef(false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { OPENAI_VOICES } from "@/constants/constants";
|
||||||
import IconComponent from "../../../../../../../../../../components/common/genericIconComponent";
|
import IconComponent from "../../../../../../../../../../components/common/genericIconComponent";
|
||||||
import ShadTooltip from "../../../../../../../../../../components/common/shadTooltipComponent";
|
import ShadTooltip from "../../../../../../../../../../components/common/shadTooltipComponent";
|
||||||
import {
|
import {
|
||||||
|
|
@ -21,6 +22,8 @@ const VoiceSelect = ({
|
||||||
handleSetVoice,
|
handleSetVoice,
|
||||||
allVoices,
|
allVoices,
|
||||||
}: VoiceSelectProps) => {
|
}: VoiceSelectProps) => {
|
||||||
|
allVoices = allVoices?.length === 0 || !allVoices ? OPENAI_VOICES : allVoices;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid w-full items-center gap-2">
|
<div className="grid w-full items-center gap-2">
|
||||||
<span className="flex w-full items-center text-sm">
|
<span className="flex w-full items-center text-sm">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ export const checkProvider = () => {
|
||||||
const audioSettings = JSON.parse(
|
const audioSettings = JSON.parse(
|
||||||
getLocalStorage("lf_audio_settings_playground") || "{}",
|
getLocalStorage("lf_audio_settings_playground") || "{}",
|
||||||
);
|
);
|
||||||
if (!audioSettings.provider) {
|
if (!audioSettings?.provider) {
|
||||||
setLocalStorage(
|
setLocalStorage(
|
||||||
"lf_audio_settings_playground",
|
"lf_audio_settings_playground",
|
||||||
JSON.stringify({ provider: "openai", voice: "alloy" }),
|
JSON.stringify({ provider: "openai", voice: "alloy" }),
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,7 @@ export function VoiceAssistant({
|
||||||
audioContextRef.current = null;
|
audioContextRef.current = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, []);
|
}, [setShowAudioInput]);
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { OPENAI_VOICES } from "@/constants/constants";
|
||||||
import { VoiceStoreType } from "@/types/zustand/voice/voice.types";
|
import { VoiceStoreType } from "@/types/zustand/voice/voice.types";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
|
||||||
|
|
@ -19,16 +20,7 @@ export const useVoiceStore = create<VoiceStoreType>((set, get) => ({
|
||||||
value: string;
|
value: string;
|
||||||
}[],
|
}[],
|
||||||
) => set({ providersList }),
|
) => set({ providersList }),
|
||||||
openaiVoices: [
|
openaiVoices: 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" },
|
|
||||||
],
|
|
||||||
setOpenaiVoices: (
|
setOpenaiVoices: (
|
||||||
openaiVoices: {
|
openaiVoices: {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue