@aituber-onair/core
Version:
Core library for AITuber OnAir providing voice synthesis and chat processing
148 lines (147 loc) • 4.45 kB
TypeScript
import { EventEmitter } from './EventEmitter';
import { ChatProcessorOptions } from './ChatProcessor';
import { MemoryOptions } from './MemoryManager';
import { VoiceServiceOptions } from '../services/voice/VoiceService';
import { Message, MemoryStorage } from '../types';
/**
* Setting options for AITuberOnAirCore
*/
export interface AITuberOnAirCoreOptions {
/** AI provider name */
chatProvider?: string;
/** AI API key */
apiKey: string;
/** AI model name (default is provider's default model) */
model?: string;
/** ChatProcessor options */
chatOptions: Omit<ChatProcessorOptions, 'useMemory'>;
/** Memory options (disabled by default) */
memoryOptions?: MemoryOptions;
/** Memory storage for persistence (optional) */
memoryStorage?: MemoryStorage;
/** Voice service options */
voiceOptions?: VoiceServiceOptions;
/** Debug mode */
debug?: boolean;
/** ChatService provider-specific options (optional) */
providerOptions?: Record<string, any>;
}
/**
* Event types for AITuberOnAirCore
*/
export declare enum AITuberOnAirCoreEvent {
/** Processing started */
PROCESSING_START = "processingStart",
/** Processing ended */
PROCESSING_END = "processingEnd",
/** Assistant (partial) response */
ASSISTANT_PARTIAL = "assistantPartial",
/** Assistant response completed */
ASSISTANT_RESPONSE = "assistantResponse",
/** Speech started */
SPEECH_START = "speechStart",
/** Speech ended */
SPEECH_END = "speechEnd",
/** Error occurred */
ERROR = "error"
}
/**
* AITuberOnAirCore is a core class that integrates the main features of AITuber
* - Chat processing (ChatService, ChatProcessor)
* - Speech synthesis (VoiceService)
* - Memory management (MemoryManager)
*/
export declare class AITuberOnAirCore extends EventEmitter {
private chatService;
private chatProcessor;
private memoryManager?;
private voiceService?;
private isProcessing;
private debug;
/**
* Constructor
* @param options Configuration options
*/
constructor(options: AITuberOnAirCoreOptions);
/**
* Process text chat
* @param text User input text
* @returns Success or failure of processing
*/
processChat(text: string): Promise<boolean>;
/**
* Process image-based chat
* @param imageDataUrl Image data URL
* @param visionPrompt Custom prompt for describing the image (optional)
* @returns Success or failure of processing
*/
processVisionChat(imageDataUrl: string, visionPrompt?: string): Promise<boolean>;
/**
* Stop speech playback
*/
stopSpeech(): void;
/**
* Get chat history
*/
getChatHistory(): Message[];
/**
* Set chat history from external source
* @param messages Message array to set as chat history
*/
setChatHistory(messages: Message[]): void;
/**
* Clear chat history
*/
clearChatHistory(): void;
/**
* Update voice service
* @param options New voice service options
*/
updateVoiceService(options: VoiceServiceOptions): void;
/**
* Speak text with custom voice options
* @param text Text to speak
* @param options Speech options
* @returns Promise that resolves when speech is complete
*/
speakTextWithOptions(text: string, options?: {
enableAnimation?: boolean;
temporaryVoiceOptions?: Partial<VoiceServiceOptions>;
audioElementId?: string;
}): Promise<void>;
/**
* Setup forwarding of ChatProcessor events
*/
private setupEventForwarding;
/**
* Output debug log (only in debug mode)
*/
private log;
/**
* Check if memory functionality is enabled
*/
isMemoryEnabled(): boolean;
/**
* Remove all event listeners
*/
offAll(): void;
/**
* Get current provider information
* @returns Provider information object
*/
getProviderInfo(): {
name: string;
model?: string;
};
/**
* Get list of available providers
* @returns Array of available provider names
*/
static getAvailableProviders(): string[];
/**
* Get list of models supported by the specified provider
* @param providerName Provider name
* @returns Array of supported models
*/
static getSupportedModels(providerName: string): string[];
}