omi icon indicating copy to clipboard operation
omi copied to clipboard

Offline recordings lack diarization and custom vocabulary support

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

Problem

Offline recorded audio files (and live recordings that fall back to offline when internet fails) are not getting speaker diarization or custom vocabulary applied when synced to the backend.

Root Cause

In backend/routers/sync.py, the process_segment() function calls deepgram_prerecorded() with hardcoded parameters:

words, language = deepgram_prerecorded(url, speakers_count=3, attempts=0, return_language=True)

Missing:

  1. No diarization control - Always passes diarize=True (default), but never checks user preference
  2. No custom vocabulary - Never retrieves or passes user's transcription_preferences.vocabulary
  3. No language preference - Ignores user's preferred language setting

By contrast, the live streaming path (backend/routers/transcribe.py) correctly:

  • Fetches user preferences via get_user_transcription_preferences(uid)
  • Passes vocabulary list as keywords parameter to Deepgram
  • Respects user language settings

Impact

Users who configure custom vocabulary (names, technical terms, product names) get accurate transcription during live recording but lose that accuracy when:

  • Device records offline and syncs later
  • Internet connection drops mid-recording (recording continues offline)

Fix

Update process_segment() in backend/routers/sync.py to:

  1. Fetch user transcription preferences:
from database.users import get_user_transcription_preferences

transcription_prefs = get_user_transcription_preferences(uid)
vocabulary = transcription_prefs.get('vocabulary', [])
user_language = transcription_prefs.get('language', None)
  1. Pass vocabulary to deepgram_prerecorded():
words, language = deepgram_prerecorded(
    url,
    speakers_count=3,
    attempts=0,
    return_language=True,
    diarize=True,
    language=user_language,
    keywords=vocabulary,  # Pass user's custom vocabulary
)
  1. Update deepgram_prerecorded() in backend/utils/stt/pre_recorded.py to accept and use keywords parameter:
def deepgram_prerecorded(
    audio_url: str,
    speakers_count: int = None,
    attempts: int = 0,
    return_language: bool = False,
    diarize: bool = True,
    language: Optional[str] = None,
    model: str = "nova-3",
    keywords: List[str] = [],  # ADD THIS
) -> Union[List[dict], Tuple[List[dict], str]]:
    # ...
    options = {
        "model": model,
        "smart_format": True,
        "punctuate": True,
        "diarize": diarize,
        "detect_language": should_detect_language,
        "utterances": True,
    }
    
    # ADD THIS BLOCK
    if keywords and len(keywords) > 0:
        if model == 'nova-3':
            options['keyterm'] = keywords  # Nova-3 uses keyterm
        else:
            options['keywords'] = keywords  # Nova-2 uses keywords
    # ...

References

  • Deepgram Keywords API: https://developers.deepgram.com/docs/keywords
  • Deepgram Keyterm Prompting (Nova-3): https://developers.deepgram.com/docs/keyterm
  • Current streaming implementation: backend/utils/stt/streaming.py (search for _dg_keywords_set)

Priority

Medium-High - Affects user experience for offline/sync scenarios, creates inconsistency between live and offline transcription quality.

omi-discord-vector[bot] avatar Mar 28 '26 23:03 omi-discord-vector[bot]

@beastoin a gift for you ❤️

hugoaap-code avatar Mar 28 '26 23:03 hugoaap-code

Consolidated into #6172 which deep-dives all feature gaps between the sync and realtime transcription paths. This issue's vocabulary + diarization concerns are captured there.

beastoin avatar Mar 30 '26 05:03 beastoin