export type VoiceTuningConfig = {stability?: number | undefined, similarityBoost?: number | undefined, speed?: number | undefined, modelId?: string | undefined, engine?: string | undefined, emotion?: string | undefined, volume?: number | undefined, version?: string | undefined, voiceDescription?: string | undefined, instantMode?: boolean | undefined}; export type SynthesizeAudioRequest = {text: string, config: VoiceTuningConfig, language?: string | undefined}; export type CreateApiV1AgentsAgentIdAudioCacheEntryIdSynthesizeArgs = {body: SynthesizeAudioRequest}; export type CreateApiV1AgentsAgentIdAudioCacheEntryIdSynthesizeOptions = {baseUrl?: string | undefined, polyApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Synthesize audio preview * * POST /v1/agents/{agentId}/audio-cache/{entryId}/synthesize */ export const createApiV1AgentsAgentIdAudioCacheEntryIdSynthesize = async (args: CreateApiV1AgentsAgentIdAudioCacheEntryIdSynthesizeArgs, options?: CreateApiV1AgentsAgentIdAudioCacheEntryIdSynthesizeOptions) => { const {baseUrl = "https://api.us.poly.ai", fetch: fetchFn = fetch, polyApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "audio/wav") if (polyApiKey !== undefined) headers.set("X-API-KEY", polyApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/agents/${encodeURIComponent(String(args.agentId))}/audio-cache/${encodeURIComponent(String(args.entryId))}/synthesize${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 res.blob() };