export type APIVersion = 'v1'; export type Gender = 'Male' | 'Female' | 'Neutral' | 'Unspecified'; export type VoiceUpdateRequest = {name?: (string | null) | undefined, description?: (string | null) | undefined, gender?: (Gender | null) | undefined, accent?: (string | null) | undefined, style?: (string | null) | undefined, is_active?: (boolean | null) | undefined, language?: (string | null) | undefined}; export type UpdateApiVoicesVoiceIdArgs = {voice_id: string, version?: APIVersion | undefined, 'X-Api-Key'?: string | undefined, body: VoiceUpdateRequest}; export type UpdateApiVoicesVoiceIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update Voice * * PUT /voices/{voice_id} */ export const updateApiVoicesVoiceId = async (args: UpdateApiVoicesVoiceIdArgs, options: UpdateApiVoicesVoiceIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.version != null) headers.set("version", String(args.version)) if (args['X-Api-Key'] != null) headers.set("X-Api-Key", String(args['X-Api-Key'])) const url = `${baseUrl.replace(/\/+$/, '')}/voices/${encodeURIComponent(String(args.voice_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };