voiceai-sdk
Version:
Official SDK for SLNG.AI Voice API - Text-to-Speech, Speech-to-Text, and LLM services
207 lines (195 loc) • 6.79 kB
TypeScript
interface VoiceAIConfig {
apiKey: string;
baseUrl?: string;
timeout?: number;
}
declare class VoiceAI {
private static instance;
private config;
constructor(config: VoiceAIConfig);
static getInstance(): VoiceAI;
getConfig(): VoiceAIConfig;
updateApiKey(apiKey: string): void;
}
interface TTSOptions {
voice?: string;
language?: string;
stream?: boolean;
format?: 'mp3' | 'wav' | 'aac' | 'flac';
temperature?: number;
speed?: number;
[key: string]: any;
}
interface TTSResult {
audio: ArrayBuffer | ReadableStream;
duration?: number;
format?: string;
}
declare const tts: {
synthesize(text: string, model: string, options?: TTSOptions): Promise<TTSResult>;
vui: (text: string, options?: TTSOptions) => Promise<TTSResult>;
orpheus: (text: string, options?: TTSOptions) => Promise<TTSResult>;
koroko: (text: string, options?: TTSOptions) => Promise<TTSResult>;
xtts: (text: string, options?: TTSOptions & {
speakerVoice: string;
}) => Promise<TTSResult>;
mars6: (text: string, options?: TTSOptions & {
audioRef: string;
}) => Promise<TTSResult>;
orpheusIndic: (text: string, options?: TTSOptions & {
language: string;
}) => Promise<TTSResult>;
elevenlabs: {
multiV2: (text: string, options?: TTSOptions) => Promise<TTSResult>;
turbo: (text: string, options?: TTSOptions) => Promise<TTSResult>;
v3: (text: string, options?: TTSOptions) => Promise<TTSResult>;
flash: (text: string, options?: TTSOptions) => Promise<TTSResult>;
};
models: string[];
getVoices: (model: string) => string[];
getLanguages: (model: string) => string[];
};
interface STTOptions {
language?: string;
format?: string;
timestamps?: boolean;
diarization?: boolean;
[key: string]: any;
}
interface STTResult {
text: string;
confidence?: number;
language?: string;
segments?: Array<{
text: string;
start: number;
end: number;
confidence?: number;
}>;
}
declare const stt: {
transcribe(audio: File | Blob | ArrayBuffer | string, model: string, options?: STTOptions): Promise<STTResult>;
whisper: (audio: File | Blob | ArrayBuffer | string, options?: STTOptions) => Promise<STTResult>;
kyutai: (audio: File | Blob | ArrayBuffer | string, options?: STTOptions) => Promise<STTResult>;
models: string[];
getLanguages: (model: string) => string[];
};
interface LLMMessage {
role: 'system' | 'user' | 'assistant';
content: string;
}
interface LLMOptions {
temperature?: number;
maxTokens?: number;
topP?: number;
stream?: boolean;
[key: string]: any;
}
interface LLMResult {
content: string;
usage?: {
promptTokens: number;
completionTokens: number;
totalTokens: number;
};
}
declare const llm: {
complete(messages: LLMMessage[] | string, model: string, options?: LLMOptions): Promise<LLMResult | ReadableStream>;
llamaScout: (messages: LLMMessage[] | string, options?: LLMOptions) => Promise<ReadableStream<any> | LLMResult>;
models: string[];
};
interface SignupOptions {
email: string;
password?: string;
referralCode?: string;
}
interface LoginOptions {
email: string;
password: string;
}
interface AccountInfo {
email: string;
apiKey: string;
credits: number;
plan: string;
usage?: {
tts: number;
stt: number;
llm: number;
};
}
declare class Auth {
private static signupUrl;
private static dashboardUrl;
static signup(_options: SignupOptions): Promise<{
message: string;
apiKey?: string;
}>;
static getAccount(): Promise<AccountInfo | null>;
static checkCredits(): Promise<number | null>;
static showDashboard(): void;
static showPricing(): Promise<void>;
static showModels(): Promise<void>;
}
declare const auth: typeof Auth;
/**
* Warmup utilities for pre-warming models to avoid cold start delays
*/
declare class Warmup {
/**
* Pre-warm a TTS model to avoid cold start delays
* @param model - The TTS model to warm up (e.g., 'orpheus', 'elevenlabs/multi-v2')
* @returns Promise that resolves when the model is ready
*/
static tts(model: string): Promise<void>;
/**
* Pre-warm an STT model
* @param model - The STT model to warm up (e.g., 'whisper-v3')
*/
static stt(model: string): Promise<void>;
/**
* Pre-warm an LLM model
* @param model - The LLM model to warm up (e.g., 'llama-4-scout')
*/
static llm(model: string): Promise<void>;
/**
* Pre-warm multiple models in parallel
* @param models - Array of model identifiers with their types
* @example
* await Warmup.multiple([
* { type: 'tts', model: 'orpheus' },
* { type: 'stt', model: 'whisper-v3' },
* { type: 'llm', model: 'llama-4-scout' }
* ]);
*/
static multiple(models: Array<{
type: 'tts' | 'stt' | 'llm';
model: string;
}>): Promise<void>;
}
declare const warmup: typeof Warmup;
type AudioFormat = 'mp3' | 'wav' | 'aac' | 'flac' | 'ogg' | 'pcm';
type TTSModel = 'vui' | 'orpheus' | 'orpheus-indic' | 'koroko' | 'xtts-v2' | 'mars6' | 'elevenlabs/multi-v2' | 'elevenlabs/turbo-v2-5' | 'elevenlabs/v3' | 'elevenlabs/ttv-v3' | 'elevenlabs/flash-v2-5' | 'twi-speecht5';
type STTModel = 'whisper-v3' | 'kyutai' | 'general';
type LLMModel = 'llama-4-scout' | 'general';
interface LLMProvider {
complete: (messages: LLMMessage[], options: LLMOptions, config: VoiceAIConfig) => Promise<LLMResult | ReadableStream>;
}
declare const LLMProviders: Record<string, LLMProvider>;
interface STTProvider {
transcribe: (audio: File | Blob | ArrayBuffer | string, options: STTOptions, config: VoiceAIConfig) => Promise<STTResult>;
languages?: string[];
}
declare const STTProviders: Record<string, STTProvider>;
interface TTSProvider {
synthesize: (text: string, options: TTSOptions, config: VoiceAIConfig) => Promise<TTSResult>;
voices?: string[];
languages?: string[];
}
declare const TTSProviders: Record<string, TTSProvider>;
declare const providers: {
tts: Record<string, TTSProvider>;
stt: Record<string, STTProvider>;
llm: Record<string, LLMProvider>;
};
export { type AccountInfo, type AudioFormat, type LLMMessage, type LLMModel, type LLMOptions, type LLMProvider, LLMProviders, type LLMResult, type LoginOptions, type STTModel, type STTOptions, type STTProvider, STTProviders, type STTResult, type SignupOptions, type TTSModel, type TTSOptions, type TTSProvider, TTSProviders, type TTSResult, VoiceAI, type VoiceAIConfig, auth, VoiceAI as default, llm, providers, stt, tts, warmup };