import { Loader2, Mic } from 'lucide-react'; import { useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from '@/components/ui/form'; import { Input } from '@/components/ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { Textarea } from '@/components/ui/textarea'; import { getLanguageOptionsForEngine, type LanguageCode } from '@/lib/constants/languages'; import { useGenerationForm } from '@/lib/hooks/useGenerationForm'; import { useProfile } from '@/lib/hooks/useProfiles'; import { useUIStore } from '@/stores/uiStore'; import { applyEngineSelection, EngineModelSelector, getEngineDescription, } from './EngineModelSelector'; import { ParalinguisticInput } from './ParalinguisticInput'; function getEngineSelectValue(engine: string): string { if (engine === 'qwen') return 'qwen:1.7B'; if (engine === 'qwen_custom_voice') return 'qwen_custom_voice:1.7B'; if (engine === 'tada') return 'tada:1B'; return engine; } export function GenerationForm() { const selectedProfileId = useUIStore((state) => state.selectedProfileId); const { data: selectedProfile } = useProfile(selectedProfileId || ''); const { form, handleSubmit, isPending } = useGenerationForm(); useEffect(() => { if (!selectedProfile) { return; } if (selectedProfile.language) { form.setValue('language', selectedProfile.language as LanguageCode); } const preferredEngine = selectedProfile.default_engine || selectedProfile.preset_engine; if (preferredEngine) { applyEngineSelection(form, getEngineSelectValue(preferredEngine)); } }, [form, selectedProfile]); async function onSubmit(data: Parameters[0]) { await handleSubmit(data, selectedProfileId); } return ( Generate Speech
Voice Profile {selectedProfile ? (
{selectedProfile.name} {selectedProfile.language}
) : (
Click on a profile card above to select a voice profile
)}
( Text to Speak {form.watch('engine') === 'chatterbox_turbo' ? ( ) : (