UNPKG

orate

Version:
72 lines (69 loc) 3.54 kB
import { TextToSpeechRequest, BodySpeechToTextV1SpeechToTextPost, BodySpeechToSpeechV1SpeechToSpeechVoiceIdPost, BodyAudioIsolationV1AudioIsolationPost } from 'elevenlabs/api'; type ElevenLabsModel = 'eleven_multilingual_v2' | 'eleven_flash_v2_5' | 'eleven_flash_v2' | 'eleven_turbo_v2' | 'eleven_turbo_v2_5' | 'eleven_multilingual_sts_v2' | 'eleven_english_sts_v2'; declare const voices: { alice: string; aria: string; bill: string; brian: string; callum: string; charlie: string; charlotte: string; chris: string; daniel: string; eric: string; george: string; jessica: string; laura: string; liam: string; lily: string; matilda: string; river: string; roger: string; sarah: string; will: string; }; declare class ElevenLabs { private apiKey; constructor(apiKey?: string); private createProvider; /** * Creates a text-to-speech synthesis function using ElevenLabs * @param {ElevenLabsModel} model - The model ID to use for synthesis. Defaults to 'multilingual_v2' * @param {keyof typeof voices} voice - The voice ID to use for synthesis. Defaults to 'aria' * @param {Omit<TextToSpeechRequest, 'text' | 'model_id'>} options - Additional options for the synthesis * @returns {Function} Async function that takes text and returns synthesized audio */ tts(model?: ElevenLabsModel, voice?: keyof typeof voices | (string & {}), options?: Omit<TextToSpeechRequest, 'text' | 'model_id'>): { generate: (prompt: string) => Promise<File>; stream: (prompt: string) => Promise<ReadableStream>; }; /** * Creates a speech-to-text transcription function using ElevenLabs * @param {BodySpeechToTextV1SpeechToTextPost["model_id"]} model - The model to use for transcription. Defaults to 'scribe_v1' * @param {Omit<BodySpeechToTextV1SpeechToTextPost, 'model_id' | 'file'>} properties - Additional properties for the transcription request * @returns {Function} Async function that takes audio and returns transcribed text */ stt(model?: 'scribe_v1', properties?: Omit<BodySpeechToTextV1SpeechToTextPost, 'model_id' | 'file'>): { generate: (audio: File) => Promise<string>; }; /** * Creates a speech-to-speech conversion function using ElevenLabs * @param {BodySpeechToSpeechV1SpeechToSpeechVoiceIdPost['model_id']} model - The model ID to use for conversion. Defaults to 'eleven_multilingual_sts_v2' * @param {keyof typeof voices | (string & {})} voice - The voice ID to use for synthesis. Defaults to 'aria' * @param {Omit<BodySpeechToSpeechV1SpeechToSpeechVoiceIdPost, 'audio' | 'model_id'>} options - Additional options for the conversion * @returns {Function} Async function that takes audio and returns converted speech */ sts(model?: BodySpeechToSpeechV1SpeechToSpeechVoiceIdPost['model_id'], voice?: keyof typeof voices | (string & {}), options?: Omit<BodySpeechToSpeechV1SpeechToSpeechVoiceIdPost, 'audio' | 'model_id'>): { generate: (audio: File) => Promise<File>; stream: (audio: File) => Promise<ReadableStream>; }; /** * Creates a speech isolation function using ElevenLabs * @returns {Function} Async function that takes audio and returns converted speech */ isl(options?: Omit<BodyAudioIsolationV1AudioIsolationPost, 'audio'>): { generate: (audio: File) => Promise<File>; stream: (audio: File) => Promise<ReadableStream>; }; } export { ElevenLabs };