/** * Data models for LangVoice SDK */ interface VoiceData { id: string; name: string; gender?: string; language?: string; description?: string; } interface LanguageData { id: string; name: string; voices?: string[]; } interface GenerateRequestData { text: string; voice: string; language: string; speed: number; } interface MultiVoiceRequestData { text: string; language: string; speed: number; } interface GenerateResponseData { audioData: Buffer | ArrayBuffer; duration?: number; generationTime?: number; charactersProcessed?: number; } /** * Voice model */ declare class Voice implements VoiceData { readonly id: string; readonly name: string; readonly gender?: string; readonly language?: string; readonly description?: string; constructor(data: VoiceData); toJSON(): VoiceData; } /** * Language model */ declare class Language implements LanguageData { readonly id: string; readonly name: string; readonly voices?: string[]; constructor(data: LanguageData); toJSON(): LanguageData; } /** * Generate request model */ declare class GenerateRequest implements GenerateRequestData { readonly text: string; readonly voice: string; readonly language: string; readonly speed: number; constructor(data: Partial & { text: string; }); toJSON(): GenerateRequestData; } /** * Multi-voice request model */ declare class MultiVoiceRequest implements MultiVoiceRequestData { readonly text: string; readonly language: string; readonly speed: number; constructor(data: Partial & { text: string; }); toJSON(): MultiVoiceRequestData; } /** * Generate response model */ declare class GenerateResponse implements GenerateResponseData { readonly audioData: Buffer; readonly duration?: number; readonly generationTime?: number; readonly charactersProcessed?: number; constructor(data: GenerateResponseData); /** * Get audio as base64 string */ toBase64(): string; /** * Get audio as Uint8Array (for browser compatibility) */ toUint8Array(): Uint8Array; /** * Get audio as ArrayBuffer (for browser compatibility) */ toArrayBuffer(): ArrayBuffer; } /** * Voices response model */ declare class VoicesResponse { readonly voices: Voice[]; constructor(data: { voices: VoiceData[]; }); } /** * Languages response model */ declare class LanguagesResponse { readonly languages: Language[]; constructor(data: { languages: LanguageData[]; }); } declare const AMERICAN_VOICES: readonly ["heart", "bella", "nicole", "sarah", "nova", "sky", "jessica", "river", "michael", "fenrir", "eric", "liam", "onyx", "adam"]; declare const BRITISH_VOICES: readonly ["emma", "isabella", "alice", "lily", "george", "fable", "lewis", "daniel"]; declare const ALL_VOICES: readonly ["heart", "bella", "nicole", "sarah", "nova", "sky", "jessica", "river", "michael", "fenrir", "eric", "liam", "onyx", "adam", "emma", "isabella", "alice", "lily", "george", "fable", "lewis", "daniel"]; declare const LANGUAGES: readonly ["american_english", "british_english", "spanish", "french", "hindi", "italian", "japanese", "brazilian_portuguese", "mandarin_chinese"]; type VoiceId = (typeof ALL_VOICES)[number]; type LanguageId = (typeof LANGUAGES)[number]; /** * Main LangVoice API client */ interface LangVoiceClientOptions { /** API key for authentication */ apiKey?: string; /** Base URL for the API */ baseUrl?: string; /** Request timeout in milliseconds */ timeout?: number; } interface GenerateOptions { /** Text to convert to speech (max 5000 characters) */ text: string; /** Voice ID (e.g., 'heart', 'michael') */ voice?: string; /** Language code (e.g., 'american_english') */ language?: string; /** Speech speed from 0.5 to 2.0 */ speed?: number; } interface MultiVoiceOptions { /** Text with [voice] markers */ text: string; /** Language code for all voices */ language?: string; /** Speech speed from 0.5 to 2.0 */ speed?: number; } /** * LangVoice API client for text-to-speech generation * * @example * ```typescript * import { LangVoiceClient } from 'langvoice-sdk'; * * const client = new LangVoiceClient({ apiKey: 'your-api-key' }); * * const response = await client.generate({ * text: 'Hello, world!', * voice: 'heart', * }); * * // Save to file (Node.js) * import { writeFileSync } from 'fs'; * writeFileSync('output.mp3', response.audioData); * ``` */ declare class LangVoiceClient { private readonly apiKey; private readonly baseUrl; private readonly timeout; /** Available American voices */ static readonly AMERICAN_VOICES: readonly ["heart", "bella", "nicole", "sarah", "nova", "sky", "jessica", "river", "michael", "fenrir", "eric", "liam", "onyx", "adam"]; /** Available British voices */ static readonly BRITISH_VOICES: readonly ["emma", "isabella", "alice", "lily", "george", "fable", "lewis", "daniel"]; /** All available voices */ static readonly ALL_VOICES: readonly ["heart", "bella", "nicole", "sarah", "nova", "sky", "jessica", "river", "michael", "fenrir", "eric", "liam", "onyx", "adam", "emma", "isabella", "alice", "lily", "george", "fable", "lewis", "daniel"]; /** Supported languages */ static readonly LANGUAGES: readonly ["american_english", "british_english", "spanish", "french", "hindi", "italian", "japanese", "brazilian_portuguese", "mandarin_chinese"]; constructor(options?: LangVoiceClientOptions); /** * Get API key from environment variable */ private getEnvApiKey; /** * Make HTTP request */ private request; /** * Make HTTP request for binary data */ private requestBinary; /** * Handle API response errors */ private handleResponseErrors; /** * Parse float header value */ private parseFloatHeader; /** * Parse int header value */ private parseIntHeader; /** * Generate speech from text * * @param options - Generation options * @returns GenerateResponse with audio data and metadata * * @example * ```typescript * const response = await client.generate({ * text: 'Hello world!', * voice: 'heart', * language: 'american_english', * speed: 1.0, * }); * * console.log(`Duration: ${response.duration}s`); * ``` */ generate(options: GenerateOptions): Promise; /** * Generate speech with multiple voices * * @param options - Multi-voice options * @returns GenerateResponse with audio data and metadata * * @example * ```typescript * const response = await client.generateMultiVoice({ * text: '[heart] Hello! [michael] Hi there!', * language: 'american_english', * }); * ``` */ generateMultiVoice(options: MultiVoiceOptions): Promise; /** * Get all available voices * * @returns Array of Voice objects * * @example * ```typescript * const voices = await client.listVoices(); * voices.forEach(v => console.log(`${v.id}: ${v.name}`)); * ``` */ listVoices(): Promise; /** * Get all supported languages * * @returns Array of Language objects * * @example * ```typescript * const languages = await client.listLanguages(); * languages.forEach(l => console.log(`${l.id}: ${l.name}`)); * ``` */ listLanguages(): Promise; /** * Simple method to convert text to speech and return audio buffer * * @param text - Text to convert * @param voice - Voice ID * @param language - Language code * @param speed - Speech speed * @returns Audio data as Buffer * * @example * ```typescript * const audioBuffer = await client.textToSpeech('Hello!', 'heart'); * ``` */ textToSpeech(text: string, voice?: string, language?: string, speed?: number): Promise; /** * Get the API key (useful for passing to tools) */ getApiKey(): string; } export { AMERICAN_VOICES as A, BRITISH_VOICES as B, type GenerateOptions as G, LangVoiceClient as L, type MultiVoiceOptions as M, Voice as V, type LangVoiceClientOptions as a, Language as b, GenerateRequest as c, MultiVoiceRequest as d, GenerateResponse as e, VoicesResponse as f, LanguagesResponse as g, type VoiceData as h, type LanguageData as i, type GenerateRequestData as j, type MultiVoiceRequestData as k, type GenerateResponseData as l, ALL_VOICES as m, LANGUAGES as n, type VoiceId as o, type LanguageId as p };