ttc-ai-client
Version:
TypeScript client sdk for TTC AI services with decorators and schema validation.
97 lines • 2.94 kB
TypeScript
/**
* TTC Call Functionality
* Handles voice calls using hybrid speech services (Chrome native + TTC Speech Client fallback)
*/
interface SpeechRecognition extends EventTarget {
continuous: boolean;
interimResults: boolean;
lang: string;
start(): void;
stop(): void;
onstart: ((this: SpeechRecognition, ev: Event) => any) | null;
onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
onend: ((this: SpeechRecognition, ev: Event) => any) | null;
onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any) | null;
}
interface SpeechRecognitionEvent extends Event {
readonly resultIndex: number;
readonly results: SpeechRecognitionResultList;
}
interface SpeechRecognitionErrorEvent extends Event {
readonly error: string;
readonly message: string;
}
interface SpeechRecognitionResultList {
readonly length: number;
item(index: number): SpeechRecognitionResult;
[index: number]: SpeechRecognitionResult;
}
interface SpeechRecognitionResult {
readonly length: number;
item(index: number): SpeechRecognitionAlternative;
[index: number]: SpeechRecognitionAlternative;
isFinal: boolean;
}
interface SpeechRecognitionAlternative {
transcript: string;
confidence: number;
}
declare var SpeechRecognition: {
prototype: SpeechRecognition;
new (): SpeechRecognition;
};
export interface CallState {
isActive: boolean;
isListening: boolean;
isSpeaking: boolean;
transcript: string;
lastActivity: number;
}
export interface CallOptions {
onTranscript?: (text: string) => void;
onSpeechStart?: () => void;
onSpeechEnd?: () => void;
onCallStart?: () => void;
onCallEnd?: () => void;
onError?: (error: string) => void;
conversationId?: string;
token?: string;
modelId?: string;
serverUrl?: string;
}
export declare class TTCCallManager {
private speechIntegration;
private state;
private options;
private inactivityTimer;
private readonly INACTIVITY_TIMEOUT;
private currentTranscript;
private isProcessingResponse;
private isPlayingAudio;
constructor(options?: CallOptions);
private initializeSpeechIntegration;
private resetInactivityTimer;
startCall(): Promise<boolean>;
endCall(): boolean;
private startListening;
private stopRecording;
speak(text: string, options?: {
token?: string;
modelId?: string;
}): Promise<void>;
private handleTTSAudio;
private onTTSPlaybackComplete;
onResponseReceived(responseText: string): void;
getState(): CallState;
isSupported(): boolean;
checkConnectivity(): Promise<boolean>;
destroy(): void;
}
declare global {
interface Window {
SpeechRecognition: typeof SpeechRecognition;
webkitSpeechRecognition: typeof SpeechRecognition;
}
}
export {};
//# sourceMappingURL=call.d.ts.map