Skip to content

feat: add USER_SPEECH_STARTED and USER_SPEECH_ENDED events#180

Merged
ao-anam merged 3 commits intomainfrom
feat/user-speech-started-ended-events
Mar 18, 2026
Merged

feat: add USER_SPEECH_STARTED and USER_SPEECH_ENDED events#180
ao-anam merged 3 commits intomainfrom
feat/user-speech-started-ended-events

Conversation

@bc-anam
Copy link
Copy Markdown
Contributor

@bc-anam bc-anam commented Mar 16, 2026

Summary

  • Adds USER_SPEECH_STARTED and USER_SPEECH_ENDED to DataChannelMessage enum (wire values: userSpeechStarted, userSpeechEnded)
  • Adds matching AnamEvent enum values and EventCallbacks type signatures
  • Handles new messages in StreamingClient.setupDataChannels() onmessage switch — emits public events directly with correlationId

These events fire when the engine's VAD detects user speech start/end, before transcription is available. Clients can use them for "listening" indicators and similar UX.

The callback receives a correlationId: string that matches the eventual MESSAGE_STREAM_EVENT_RECEIVED event's correlation ID.

Companion PRs: anam-engine#2520 (engine + WebRTC), docs (event documentation)

Test plan

  • Verify USER_SPEECH_STARTED fires when user begins speaking (before transcript)
  • Verify USER_SPEECH_ENDED fires when user stops speaking
  • Verify correlationId matches between speech events and subsequent transcript
  • Verify no errors for sessions that don't emit these events (audio passthrough, LiveKit)

Summary by cubic

Add early VAD-driven user speech start/end events so apps can show “listening” UI before transcription. Each event includes a correlationId that matches the later transcript event.

  • New Features

    • Added userSpeechStarted and userSpeechEnded to DataChannelMessage.
    • Added USER_SPEECH_STARTED and USER_SPEECH_ENDED to AnamEvent and EventCallbacks (correlationId: string).
    • StreamingClient emits these events on data-channel messages using user_action_correlation_id.
  • Bug Fixes

    • Aligned public event enums and callback types with internal data-channel messages to prevent type mismatches.

Written for commit 7be3013. Summary will update on new commits.

bc-anam and others added 2 commits March 16, 2026 17:00
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/types/events/public/EventCallbacks.ts">

<violation number="1" location="src/types/events/public/EventCallbacks.ts:51">
P2: These callbacks are typed as always receiving a string, but the emitter can pass `undefined` via `message.data?.user_action_correlation_id`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/types/events/public/EventCallbacks.ts
@ao-anam ao-anam merged commit 152086b into main Mar 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants