Skip to content

encodeEventStreamMessage

Encode an event-stream message with string headers.

function encodeEventStreamMessage(headers, payload): Uint8Array;

Defined in: src/utils/aws/eventstream.ts:109

Encode an event-stream message with string headers.

Parameters

ParameterTypeDescription
headersRecord<string, string>Header name/value pairs (e.g. { ':message-type': 'event' }).
payloadUint8ArrayRaw payload bytes (e.g. a PCM audio chunk).

Returns

Uint8Array

The framed binary message, including prelude and CRCs.

Remarks

All header values are written as type 7 (string) entries — the format AWS speech services expect on client-to-server events such as Amazon Transcribe’s AudioEvent.

Example

const frame = encodeEventStreamMessage(
  {
    ':message-type': 'event',
    ':event-type': 'AudioEvent',
    ':content-type': 'application/octet-stream',
  },
  new Uint8Array(pcmChunk)
);
websocket.send(frame);

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency