TypeScript Support
KlleonSDK.d.ts
type LogLevelType = "debug" | "info" | "warn" | "error" | "silent";
type VoiceCodeType = "ko_kr" | "en_us" | "ja_jp" | "id_id";
type SubtitleCodeType = "ko_kr" | "en_us" | "ja_jp" | "id_id";
type Status =
| "IDLE"
| "CONNECTING"
| "CONNECTING_FAILED"
| "SOCKET_CONNECTED"
| "SOCKET_FAILED"
| "STREAMING_CONNECTED"
| "STREAMING_FAILED"
| "CONNECTED_FINISH"
| "VIDEO_LOAD"
| "VIDEO_CAN_PLAY";
interface InitOption {
sdk_key: string;
avatar_id: string;
voice_code?: VoiceCodeType; // Set the spoken voice language
subtitle_code?: SubtitleCodeType; // Set the subtitle language
voice_tts_speech_speed?: number; // Adjust the speech speed of the voice
enable_microphone?: boolean; // Connect without browser microphone permission
log_level?: LogLevelType; // Set the log level
}
export declare enum ResponseChatType {
TEXT = "TEXT", // Avatar message
STT_RESULT = "STT_RESULT", // User voice message
RATE_LIMIT = "RATE_LIMIT", // Avatar message reception disabled
WAIT = "WAIT", // Waiting to start chat
WARN_SUSPENDED = "WARN_SUSPENDED", // Warning : Chat will stop in 10 seconds if no interaction
DISABLED_TIME_OUT = "DISABLED_TIME_OUT", // Chat stops after a period of inactivity
TEXT_ERROR = "TEXT_ERROR", // Failed to send user message
TEXT_MODERATION = "TEXT_MODERATION", // User entered inappropriate message
ERROR = "ERROR", // Server error occurred
RESPONSE_IS_ENDED = "RESPONSE_IS_ENDED", // End of avatar message transmission
WORKER_DISCONNECTED = "WORKER_DISCONNECTED", // Streaming ended
ACTIVATE_VOICE = "ACTIVATE_VOICE", // Voice recognition started
PREPARING_RESPONSE = "PREPARING_RESPONSE", // Avatar preparing a response
EXCEED_CONCURRENT_QUOTA = "EXCEED_CONCURRENT_QUOTA", // Maximum concurrent users exceeded
}
interface ChatData {
message: string;
chat_type: ResponseChatType;
time: string;
id: string;
}
interface ChangeAvatar {
avatar_id: string;
subtitle_code?: SubtitleCodeType;
voice_code?: VoiceCodeType;
voice_tts_speech_speed?: number;
}
interface KlleonChat {
init: (option: InitOption) => Promise<void>;
onChatEvent: (callback: (data: ChatData) => void) => void;
onStatusEvent: (callback: (status: Status) => void) => void;
destroy: () => void;
sendTextMessage: (msg: string) => void;
startStt: () => void;
endStt: () => void;
cancelStt: () => void;
echo: (message: string) => void;
startAudioEcho: (audio: string) => void;
endAudioEcho: () => void;
changeAvatar: (options: ChangeAvatar) => Promise<void>;
clearMessageList: () => void;
stopSpeech: () => void;
}
declare global {
interface Window {
KlleonChat: KlleonChat;
}
}
declare module "react" {
namespace JSX {
interface IntrinsicElements {
"avatar-container": React.DetailedHTMLProps<
Omit<React.HTMLAttributes<HTMLElement>, "className"> & {
class?: string;
},
HTMLElement
>;
"chat-container": React.DetailedHTMLProps<
Omit<React.HTMLAttributes<HTMLElement>, "className"> & {
class?: string;
},
HTMLElement
>;
}
}
}
tsconfig.json
// tsconfig.json
{
"compilerOptions": {...},
"include": [KlleonSDK.d.ts]
}
Last updated