export type CreateApiVoiceDialogStartArgs = {'Accept-Language'?: string | undefined, sourceId?: string | undefined, ksId?: string | undefined, sttId?: string | undefined, ttsId?: string | undefined, voiceId?: string | undefined, hliIds?: string | undefined, sinkId?: string | undefined, keyword?: string | undefined, listeningItem?: string | undefined}; export type CreateApiVoiceDialogStartOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Start dialog processing for a given audio source. * * POST /voice/dialog/start */ export const createApiVoiceDialogStart = async (args: CreateApiVoiceDialogStartArgs, options: CreateApiVoiceDialogStartOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (args.sourceId != null) query.append("sourceId", String(args.sourceId)) if (args.ksId != null) query.append("ksId", String(args.ksId)) if (args.sttId != null) query.append("sttId", String(args.sttId)) if (args.ttsId != null) query.append("ttsId", String(args.ttsId)) if (args.voiceId != null) query.append("voiceId", String(args.voiceId)) if (args.hliIds != null) query.append("hliIds", String(args.hliIds)) if (args.sinkId != null) query.append("sinkId", String(args.sinkId)) if (args.keyword != null) query.append("keyword", String(args.keyword)) if (args.listeningItem != null) query.append("listeningItem", String(args.listeningItem)) const url = `${baseUrl.replace(/\/+$/, '')}/voice/dialog/start${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };