omi icon indicating copy to clipboard operation
omi copied to clipboard

Speaker diarization and identification stopped working automatically

Open omi-discord-vector[bot] opened this issue 8 months ago • 3 comments

Problem

Speaker diarization and identification stopped working automatically today (March 31, 2026). It was working fine yesterday.

Symptoms

  1. New conversations do not automatically start diarization - no speaker labels are being assigned
  2. Manual assignment works but doesn't persist - if user manually assigns speakers in one conversation, it works for that conversation only
  3. Speaker assignments do not carry over to next conversation - the system is not remembering identified speakers
  4. Automatic speaker identification is broken - no automatic recognition across conversations

Expected Behavior

  • Diarization should start automatically on new conversations
  • Once speakers are identified/assigned, the system should remember them for future conversations via speaker profiles/embeddings
  • Speaker identification should work consistently across all conversations using voice embeddings

Timeline

  • ✅ Working correctly: March 30, 2026 and before
  • ❌ Issue started: March 31, 2026

Technical Context

The manual assignment feature still works within a single conversation, but the persistence and automatic recognition across conversations is broken. This suggests the issue might be related to:

  • Speaker profile matching/embedding comparison
  • User preference storage for speaker profiles
  • Speaker-to-person mapping persistence
  • Speech profile lookup or caching

Possible Causes

  1. Recent backend changes to speaker identification logic
  2. Database migration affecting speech_profiles or people collections
  3. Redis cache invalidation for speaker embeddings
  4. Breaking change in utils/speaker_identification.py or utils/stt/speaker_embedding.py

Priority

High - Core feature regression affecting all users. Speaker identification is a key differentiator for Omi.

omi-discord-vector[bot] avatar Mar 31 '26 10:03 omi-discord-vector[bot]

Investigation Update

Found the likely root cause. Massive speaker identification refactor on March 28-29, 2026:

Breaking Changes (commits from last 3 days):

March 28:

  • c4ea57f62 - Replace presecond trick with speaker embedding for user identification
  • 378ef1441 - Remove presecond speech profile trick from streaming module
  • 0e738af84 - Fix user sentinel mismatch: use 'user' to match speaker_assignment.py
  • bf7788cdb - Extract and store speaker embedding at speech profile upload time
  • bc87e7a2d - Load user speaker embedding from Firestore instead of extracting from WAV each session
  • 29581e942 - Add user-level speaker embedding storage functions to Firestore

March 29:

  • 9a8ea792e - Implement speaker_map_dirty flag for efficient retroactive speaker assignment
  • 335690d69 - Fix: only run speaker assignment on current batch, not all segments
  • 0904234a8 - Flush speaker assignments before conversation rollover
  • c92d3dbce - Drain in-flight speaker match tasks before conversation rollover

Root Cause Hypothesis:

The old system used "presecond" speech profile trick (extracting user voice from first second of audio).

The new system expects speaker embeddings stored in Firestore at speech profile upload time.

The migration broke persistence because:

  1. Old users don't have embeddings in Firestore (only WAV files)
  2. The new code loads embeddings from Firestore (bc87e7a2d) but may not be falling back to WAV extraction properly
  3. Without embeddings, automatic speaker matching fails silently
  4. Manual assignment works because it bypasses embedding lookup

Affected Code:

  • backend/utils/stt/streaming.py - removed presecond extraction
  • backend/utils/stt/speaker_embedding.py - new Firestore loading logic
  • backend/utils/speaker_assignment.py - user sentinel changes
  • backend/database/users.py - new embedding storage functions

Fix Needed:

  1. Add migration to extract and store embeddings for existing users with speech profiles
  2. Ensure fallback: if Firestore embedding missing, extract from WAV and cache
  3. Or: auto-trigger embedding extraction on first conversation after upgrade

Verification:

Check if users with speech profiles uploaded before March 28 have speaker_embedding field in Firestore. If missing, that's the bug.

omi-discord-vector[bot] avatar Mar 31 '26 11:03 omi-discord-vector[bot]

@beastoin @mdmohsin7 gift for you

hugoaap-code avatar Mar 31 '26 11:03 hugoaap-code

@hugoaap-code We investigated this by pulling 48h of production speaker identification logs (Mar 30–31). The system is actively running with consistent volumes across both days — no drop on March 31. Specifically: embeddings are loading (566 unique UIDs on Mar 31), comparisons are running (2,351 on Mar 31 vs 2,318 on Mar 30), and successful matches are happening (e.g. speaker 1 -> USER distance=0.428). The March 28–29 speaker refactor and March 31 translation refactor (fd25ede51) did not break speaker identification — both the embedding loading path (routers/transcribe.py:1716-1749) and the WAV fallback (commit 2b23ddc0c) are working with 0 extraction errors.

Two things we did find: (1) 5,000+ sessions correctly skip speaker ID because those users never set up speech profiles — this is expected, not a bug; (2) one user has corrupted person embeddings causing a dimension mismatch error, which is a data issue not a code regression.

To dig deeper into the specific case, can you share the affected user's UID and the exact timeframe (UTC) when they observed the issue? That way we can trace their specific sessions in the logs.


by AI for @beastoin

beastoin avatar Mar 31 '26 13:03 beastoin