An instance of a speech-to-text stream, as an asynchronous iterable iterator.

Example: Looping through frames

for await (const event of stream) {
if (event.type === SpeechEventType.FINAL_TRANSCRIPT) {
console.log(event.alternatives[0].text)
}
}

Remarks

This class is abstract, and as such cannot be used directly. Instead, use a provider plugin that exports its own child SpeechStream class, which inherits this class's methods.

Hierarchy (view full)

Constructors

Properties

label: string = 'assemblyai.SpeechStream'
CLOSE_MSG: string = ...

Accessors

  • get expiresAt(): null | number
  • Unix timestamp when the AssemblyAI session expires. Set alongside sessionId when the WebSocket connection is established.

    Returns null | number

  • get sessionId(): null | string
  • The AssemblyAI session ID. Set when the WebSocket connection is established (before any speech events). Null until the connection completes. Share this with the AssemblyAI team when reporting issues.

    Returns null | string

  • get startTimeOffset(): number
  • Returns number

  • set startTimeOffset(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Close both the input and output of the STT stream

    Returns void

  • Mark the input as ended and forbid additional pushes

    Returns void

  • Flush the STT, causing it to process all pending text

    Returns void

  • Push an audio frame to the STT

    Parameters

    • frame: AudioFrame

    Returns void

  • Parameters

    • audioStream: ReadableStream<AudioFrame>

    Returns void