@inworld/web-core
Version:
56 lines (55 loc) • 1.97 kB
TypeScript
import { AudioPlaybackConfig, Awaitable, OnPhomeneFn } from '../../common/data_structures/index.js';
import { InworldPacket } from '../../entities/packets/inworld_packet.entity.js';
interface AudioQueueItem<InworldPacketT> {
packet: InworldPacketT;
onBeforePlaying?: (packet: InworldPacketT) => void;
onAfterPlaying?: (packet: InworldPacketT) => void;
}
export declare class GrpcAudioPlayback<InworldPacketT extends InworldPacket = InworldPacket> {
private currentItem;
private audioQueue;
private audioPlaybackConfig;
private isPlaying;
private isStopping;
private playbackAudioContext;
private audioBufferSourceNode?;
private onAfterPlaying;
private onBeforePlaying;
private onStopPlaying;
private onPhoneme;
private destinationNode;
private gainNode;
private muted;
constructor(props?: {
audioPlaybackConfig?: AudioPlaybackConfig;
onAfterPlaying?: (message: InworldPacketT) => Awaitable<void>;
onBeforePlaying?: (message: InworldPacketT) => Awaitable<void>;
onStopPlaying?: () => Awaitable<void>;
onPhoneme?: OnPhomeneFn;
});
getIsActive(): boolean;
addToQueue(item: AudioQueueItem<InworldPacketT>): void;
clearQueue(): void;
excludeCurrentInteractionPackets(exceptInteractionId: string): InworldPacketT[];
hasPacketInQueue(props: {
interactionId?: string;
utteranceId?: string;
}): boolean;
isCurrentPacket(props: {
interactionId?: string;
utteranceId?: string;
}): boolean;
getCurrentPacket(): InworldPacketT;
getPlaybackStream(): MediaStream;
getMute(): boolean;
mute(mute: boolean): Promise<void>;
getVolume(): number;
stop(): Promise<void>;
stopForInteraction(interactionId: string): Promise<InworldPacketT[]>;
init(): Promise<void>;
private clearSourceNode;
private getSourceNode;
private playQueue;
private adjustVolume;
}
export {};