export type VCModel = 'vachana-vc-v1'; export type SpeakerEmbedding = {embedding: string, shape: Array, dtype: string}; export type AudioEncoding = 'linear_pcm' | 'oggopus'; export type AudioContainer = 'raw' | 'mp3' | 'wav' | 'mulaw' | 'ogg'; export type MP3Bitrate = '96k' | '128k' | '192k'; export type AudioConfig = {sample_rate?: number | undefined, num_channels?: number | undefined, sample_width?: number | undefined, encoding?: AudioEncoding | undefined, container?: AudioContainer | undefined, bitrate?: MP3Bitrate | undefined}; export type VoiceCloneRequest = {text: string, model?: VCModel | undefined, speaker_embedding: SpeakerEmbedding, audio_config: AudioConfig}; export type CreateApiApiV1TtsInferenceArgs = {'X-API-Key-ID': string, body: VoiceCloneRequest}; export type CreateApiApiV1TtsInferenceOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Voice Cloned TTS Inference * * POST /api/v1/tts/inference */ export const createApiApiV1TtsInference = async (args: CreateApiApiV1TtsInferenceArgs, options?: CreateApiApiV1TtsInferenceOptions) => { const {baseUrl = "https://api.vachana.ai", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "audio/wav") if (args['X-API-Key-ID'] != null) headers.set("X-API-Key-ID", String(args['X-API-Key-ID'])) if (ApiKeyAuth !== undefined) headers.set("X-API-Key-ID", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/tts/inference${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() };