Skip to content

Add speaker diarization attributes and modes to SpeechRecognition - #228

Open
alan33d wants to merge 1 commit into
WebAudio:mainfrom
alan33d:speaker-diarization-spec
Open

alan33d wants to merge 1 commit into
WebAudio:mainfrom
alan33d:speaker-diarization-spec

Conversation

@alan33d

@alan33d alan33d commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds WebIDL definitions and normative algorithm steps for opt-in speaker diarization to the Web Speech API (index.bs), as proposed in tracking issue #226 and companion explainer PR #227.

Summary of Changes

  1. interface SpeechRecognition:
    • attribute SpeechRecognitionDiarization diarization; (defaults to "none")
    • attribute unsigned long minSpeakers; (defaults to 0)
    • attribute unsigned long maxSpeakers; (defaults to 0)
  2. enum SpeechRecognitionDiarization:
    • Introduces "none", "speaker-turns", and "speaker-labels".
  3. dictionary SpeechRecognitionOptions:
    • Adds SpeechRecognitionDiarization diarization = "none"; enabling feature detection and download gating via static SpeechRecognition.available() and install().
  4. enum SpeechRecognitionErrorCode:
    • Adds "diarization-not-supported".
  5. interface SpeechRecognitionResult:
    • readonly attribute boolean speakerChanged;
    • readonly attribute DOMString? speaker;
  6. Algorithms & Normative Prose:
    • Parameter Validation: The start session algorithm throws a RangeError if minSpeakers > 0 and maxSpeakers > 0 and minSpeakers > maxSpeakers.
    • Capability Verification: Fires a SpeechRecognitionErrorEvent with error = "diarization-not-supported" if the requested diarization mode is not supported.
    • Boundary Enforcement: Requires that the recognition service segment results at speaker turns when diarization is "speaker-turns" or "speaker-labels".
    • Canonical Labeling: Sets speaker to 1-based index strings ("1", "2", ...) assigned in order of appearance within the session when diarization === "speaker-labels".
    • Immutability Contract: Guarantees that once result.isFinal is true, speaker and speakerChanged are immutable.

Related


Preview | Diff

This branch has not been deployed

No deployments
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.

1 participant