UNPKG

@speechly/browser-client

Version:

JavaScript client for Speechly Streaming API

65 lines (64 loc) 1.88 kB
import { Word, Entity, Intent, Segment } from './types'; /** * A high level API for automatic speech recognition (ASR) and natural language understanding (NLU) results. Results will accumulate in Segment for the duration of the an utterance. * @internal */ export declare class SegmentState { /** * Audio context id for the utterance. Unique for the processed audio chunk between start and stop calls. * One utterance may produce one or more segments. */ contextId: string; /** * 0-based segment index within the audio context. Together with {@link contextId} forms an unique identifier for the segment. */ id: number; /** * True when the segment will not be changed any more */ isFinalized: boolean; /** * Detected words in the segment */ words: Word[]; /** * Detected entities in the segment */ entities: Map<string, Entity>; /** * Detected intent for the segment */ intent: Intent; /** * @param contextId - Audio context id * @param segmentIndex - 0-based segment index within the audio context * @internal */ constructor(contextId: string, segmentIndex: number); toSegment(): Segment; toString(): string; /** * @param words - changed words * @returns updated SegmentState * @internal */ updateTranscript(words: Word[]): SegmentState; /** * @param entities - changed entities * @returns updated SegmentState * @internal */ updateEntities(entities: Entity[]): SegmentState; /** * @param intent - changed intent * @returns updated SegmentState * @internal */ updateIntent(intent: Intent): SegmentState; /** * @returns SegmentState with final flags set * @internal */ finalize(): SegmentState; private entityMapKey; }