Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Tests: fix mistral_connector swallowing harness (9th file) + the non-deterministic speakers bug it hid
Murtaza Nasircdeb04d94dc4
diff --git a/src/services/transcription/connectors/mistral.py b/src/services/transcription/connectors/mistral.pyindex 6ab22ef1..954f25db 100644--- a/src/services/transcription/connectors/mistral.py+++ b/src/services/transcription/connectors/mistral.py@@ -180,8 +180,11 @@ class MistralTranscriptionConnector(BaseTranscriptionConnector):# Determine detected languagedetected_language = result.get('language', request.language)- # Build speaker list from segments- speakers = list({s.speaker for s in segments if s.speaker})+ # Build speaker list from segments — distinct, in order of first+ # appearance. dict.fromkeys dedupes while preserving order; a plain+ # set() gave hash-randomised (non-deterministic) ordering, which+ # produced an unstable speakers list across runs.+ speakers = list(dict.fromkeys(s.speaker for s in segments if s.speaker))return TranscriptionResponse(text=result.get('text', ''),diff --git a/tests/test_mistral_connector.py b/tests/test_mistral_connector.pyindex a9ee8d11..38dc5732 100644--- a/tests/test_mistral_connector.py+++ b/tests/test_mistral_connector.py@@ -40,10 +40,14 @@ def run_test(name, func):print(f" ✗ {name}: {e}")FAILED += 1ERRORS.append((name, str(e)))+ if "pytest" in sys.modules:+ raiseexcept Exception as e:print(f" ✗ {name}: EXCEPTION - {e}")FAILED += 1ERRORS.append((name, f"Exception: {e}"))+ if "pytest" in sys.modules:+ raise# =============================================================================