UNPKG

orate

Version:
55 lines (52 loc) 2.85 kB
import { WebhookEventType } from 'replicate'; type ReplicateModel = `${string}/${string}` | `${string}/${string}:${string}`; type ReplicateProperties = { input: object; wait?: { mode: 'block'; interval?: number; timeout?: number; } | { mode: 'poll'; interval?: number; }; webhook?: string; webhook_events_filter?: WebhookEventType[]; signal?: AbortSignal; }; declare class Replicate { private apiKey; constructor(apiKey?: string); private createProvider; /** * Creates a text-to-speech synthesis function using Replicate TTS * @param {ReplicateModel} model - The model to use for synthesis. * @param {(prompt: string) => ReplicateProperties | Promise<ReplicateProperties>} inputTransformer - The properties to use for synthesis. * @param {(response: unknown) => File | Promise<File>} outputTransformer - The function to transform the response to a File. * @returns {Function} Async function that takes text and returns synthesized audio */ tts(model: ReplicateModel, inputTransformer: (prompt: string) => ReplicateProperties | Promise<ReplicateProperties>, outputTransformer: (response: unknown) => File | Promise<File>): { generate: (prompt: string) => Promise<File>; }; /** * Creates a speech-to-text transcription function using Replicate * @param {ReplicateModel} model - The model to use for transcription. * @param {(audio: File) => ReplicateProperties | Promise<ReplicateProperties>} inputTransformer - The properties to use for transcription. * @param {(response: unknown) => string | Promise<string>} outputTransformer - The function to transform the response to a string. * @returns {Function} Async function that takes audio and returns transcribed text */ stt(model: ReplicateModel, inputTransformer: (audio: File) => ReplicateProperties | Promise<ReplicateProperties>, outputTransformer: (response: unknown) => string | Promise<string>): { generate: (audio: File) => Promise<string>; }; /** * Creates a speech isolation function using Replicate * @param {ReplicateModel} model - The model to use for isolation. * @param {(audio: File) => ReplicateProperties | Promise<ReplicateProperties>} inputTransformer - The properties to use for isolation. * @param {(response: unknown) => File | Promise<File>} outputTransformer - The function to transform the response to a File. * @returns {Function} Async function that takes audio and returns isolated audio */ isl(model: ReplicateModel, inputTransformer: (audio: File) => ReplicateProperties | Promise<ReplicateProperties>, outputTransformer: (response: unknown) => File | Promise<File>): { generate: (audio: File) => Promise<File>; }; } export { Replicate };