export type CreateApiAccountsAccountSidTtsCacheSynthesizeArgs = {body: {speech_credential_sid: string, text: string, language: string, voice: string, encodingMp3?: boolean | undefined}}; export type CreateApiAccountsAccountSidTtsCacheSynthesizeOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * get TTS from provider * * POST /Accounts/{AccountSid}/TtsCache/Synthesize */ export const createApiAccountsAccountSidTtsCacheSynthesize = async (args: CreateApiAccountsAccountSidTtsCacheSynthesizeArgs, options?: CreateApiAccountsAccountSidTtsCacheSynthesizeOptions) => { const {baseUrl = "https://api.jambonz.cloud/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "audio/mpeg") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/Accounts/${encodeURIComponent(String(args.AccountSid))}/TtsCache/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() };