'use client' import { useId } from 'react' import { useTranslation } from 'react-i18next' import type { CatalogModel, VoiceModelOption, VoiceOptions } from '@/lib/model-catalog-types' import { DEFAULT_SPEECH_REQUEST_TIMEOUT, MIN_SPEECH_REQUEST_TIMEOUT, MAX_SPEECH_REQUEST_TIMEOUT, } from '@/lib/voice-settings' import { RegistryField, RegistryModelIdField } from './RegistryControls' import { inputClass } from './shared' export function VoiceModelFields({ service, provider, model, options, preset, update, disabled, }: { service: 'tts' | 'stt' provider: string model: CatalogModel options?: VoiceOptions preset?: VoiceModelOption update: (field: keyof CatalogModel, value: string) => void disabled: boolean }) { const { t } = useTranslation() const speedId = useId() const instructionId = useId() const timeoutId = useId() const languages = preset?.languages ?? [] const docsUrl = preset?.docs_url ?? options?.docs_url return (
{service === 'tts' && (
update('request_timeout', e.target.value)} />

{t( '5–600 seconds. Leave blank for 60 seconds. Applies to voice previews and speech playback.' )}

)} {service === 'tts' && ( <> update('response_format', v)} placeholder={preset?.formats[0] ?? 'mp3'} /> )} {(service === 'stt' || Boolean(preset?.languages.length)) && ( l.id)} onChange={v => update('language', v)} placeholder={t('Auto detect')} /> )} {service === 'tts' && preset?.speed && (
update('speed', e.target.value)} />

{preset.speed.min}–{preset.speed.max}×

)} {service === 'tts' && preset?.sample_rates && ( update('sample_rate', v)} /> )} {service === 'stt' && provider === 'volcengine_speech' && ( update('resource_id', v)} /> )}
{service === 'tts' && preset?.instructions && (