Offline recordings lack diarization and custom vocabulary support
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:
- No diarization control - Always passes
diarize=True(default), but never checks user preference - No custom vocabulary - Never retrieves or passes user's
transcription_preferences.vocabulary - 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
vocabularylist askeywordsparameter 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:
- 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)
- 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
)
- Update
deepgram_prerecorded()inbackend/utils/stt/pre_recorded.pyto accept and usekeywordsparameter:
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.
@beastoin a gift for you ❤️
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.