export type CreateApiSynthesizeDarijaAudioDarijaCountryArgs = {darija_country: 'darija_marocaine' | 'darija_tunisienne' | 'amiyia_egyptienne', body: {text: string, speaker_name?: string | undefined}}; export type CreateApiSynthesizeDarijaAudioDarijaCountryOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Convert Darija Text to Speech * * POST /synthesize/darija-audio/{darija_country} */ export const createApiSynthesizeDarijaAudioDarijaCountry = async (args: CreateApiSynthesizeDarijaAudioDarijaCountryArgs, options?: CreateApiSynthesizeDarijaAudioDarijaCountryOptions) => { const {baseUrl = "https://apis.smartly.ai", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "audio/wav") if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/synthesize/darija-audio/${encodeURIComponent(String(args.darija_country))}${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() };