export type GetApiV1VoicesVoiceIdSamplesSampleIdAudioArgs = {voice_id: string, sample_id: string, 'xi-api-key'?: (string | null) | undefined}; export type GetApiV1VoicesVoiceIdSamplesSampleIdAudioOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get Audio From Sample * * GET /v1/voices/{voice_id}/samples/{sample_id}/audio */ export const getApiV1VoicesVoiceIdSamplesSampleIdAudio = async (args: GetApiV1VoicesVoiceIdSamplesSampleIdAudioArgs, options: GetApiV1VoicesVoiceIdSamplesSampleIdAudioOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "audio/*") if (args['xi-api-key'] != null) headers.set("xi-api-key", String(args['xi-api-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/voices/${encodeURIComponent(String(args.voice_id))}/samples/${encodeURIComponent(String(args.sample_id))}/audio${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };