import { useCallback, useEffect, useState } from "react"; import Select from "react-select"; import { useLiveAPIContext } from "../../contexts/LiveAPIContext"; const voiceOptions = [ { value: "Puck", label: "Puck" }, { value: "Charon", label: "Charon" }, { value: "Kore", label: "Kore" }, { value: "Fenrir", label: "Fenrir" }, { value: "Aoede", label: "Aoede" }, ]; export default function VoiceSelector() { const { config, setConfig } = useLiveAPIContext(); useEffect(() => { const voiceName = config.generationConfig?.speechConfig?.voiceConfig?.prebuiltVoiceConfig ?.voiceName || "Atari02"; const voiceOption = { value: voiceName, label: voiceName }; setSelectedOption(voiceOption); }, [config]); const [selectedOption, setSelectedOption] = useState<{ value: string; label: string; } | null>(voiceOptions[5]); const updateConfig = useCallback( (voiceName: string) => { setConfig({ ...config, generationConfig: { ...config.generationConfig, speechConfig: { voiceConfig: { prebuiltVoiceConfig: { voiceName: voiceName, }, }, }, }, }); }, [config, setConfig] ); return (