ai-interview-assistant 2.3.2__tar.gz → 2.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/PKG-INFO +1 -1
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/pyproject.toml +1 -1
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/__init__.py +1 -1
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/audio/capture.py +19 -76
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/audio/transcriber.py +18 -33
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/daemon.py +0 -33
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview_assistant.egg-info/PKG-INFO +1 -1
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/tests/test_transcription_phase.py +2 -41
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/README.md +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/setup.cfg +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/__main__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/ai_client.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/audio/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/buffer.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/cli.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/config.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/__main__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/app.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/screens/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/screens/dashboard.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/screens/hotkeys.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/screens/scripts.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/screens/settings.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/hotkey_config.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/hotkeys.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/i18n.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/llm_clients.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/menubar.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/metrics.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/ollama_utils.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/overlay.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/screenshot.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/__init__.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/app.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/routes.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/websocket.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/state.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/utils.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/watchdog.py +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview_assistant.egg-info/SOURCES.txt +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview_assistant.egg-info/dependency_links.txt +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview_assistant.egg-info/entry_points.txt +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview_assistant.egg-info/requires.txt +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview_assistant.egg-info/top_level.txt +0 -0
- {ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/tests/test_llm_clients.py +0 -0
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/audio/capture.py
RENAMED
|
@@ -285,33 +285,6 @@ class ScreenCaptureAudio:
|
|
|
285
285
|
# Combined capture: mic + system audio
|
|
286
286
|
# ---------------------------------------------------------------------------
|
|
287
287
|
|
|
288
|
-
class _QueueAudioSource:
|
|
289
|
-
"""Minimal capture-like adapter over a single Queue.
|
|
290
|
-
|
|
291
|
-
Exposes the same ``get_audio`` / ``flush`` surface a DeepgramTranscriber pulls
|
|
292
|
-
from, so a second transcriber can consume the candidate (mic) stream from its
|
|
293
|
-
own queue without knowing about CombinedAudioCapture internals.
|
|
294
|
-
"""
|
|
295
|
-
|
|
296
|
-
def __init__(self, queue: "Queue") -> None:
|
|
297
|
-
self._queue = queue
|
|
298
|
-
|
|
299
|
-
def get_audio(self, timeout: float = 0.1) -> Optional[np.ndarray]:
|
|
300
|
-
try:
|
|
301
|
-
return self._queue.get(timeout=timeout)
|
|
302
|
-
except Empty:
|
|
303
|
-
return None
|
|
304
|
-
|
|
305
|
-
def flush(self) -> int:
|
|
306
|
-
dropped = 0
|
|
307
|
-
while True:
|
|
308
|
-
try:
|
|
309
|
-
self._queue.get_nowait()
|
|
310
|
-
dropped += 1
|
|
311
|
-
except Empty:
|
|
312
|
-
return dropped
|
|
313
|
-
|
|
314
|
-
|
|
315
288
|
class CombinedAudioCapture:
|
|
316
289
|
"""Mixes microphone + system audio and feeds a Queue for the transcriber."""
|
|
317
290
|
|
|
@@ -324,11 +297,6 @@ class CombinedAudioCapture:
|
|
|
324
297
|
def __init__(self, sample_rate: int = SAMPLE_RATE) -> None:
|
|
325
298
|
self.sample_rate = sample_rate
|
|
326
299
|
self.audio_queue: Queue[np.ndarray] = Queue()
|
|
327
|
-
# Separate queue carrying the microphone (candidate) stream when system
|
|
328
|
-
# audio is the primary source. Only fed while a mic transcriber is active
|
|
329
|
-
# (see _mic_routing) so it never grows unbounded when unused.
|
|
330
|
-
self.mic_queue: Queue[np.ndarray] = Queue()
|
|
331
|
-
self._mic_routing = False
|
|
332
300
|
self._stop_event = Event()
|
|
333
301
|
self._mic: Optional[MicrophoneCapture] = None
|
|
334
302
|
self._sys: Optional[ScreenCaptureAudio] = None
|
|
@@ -383,12 +351,14 @@ class CombinedAudioCapture:
|
|
|
383
351
|
# transcriber is routing the candidate stream; otherwise drain-and-
|
|
384
352
|
# discard.
|
|
385
353
|
if self._mic:
|
|
386
|
-
keep_mic = (not self._has_system_audio) or self._mic_routing
|
|
387
354
|
while True:
|
|
388
355
|
mic_chunk = self._mic.get_audio(timeout=0)
|
|
389
356
|
if mic_chunk is None:
|
|
390
357
|
break
|
|
391
|
-
|
|
358
|
+
# Mic feeds the transcriber only as a fallback when there is no
|
|
359
|
+
# system audio; otherwise drain-and-discard so its queue can't
|
|
360
|
+
# back up. (Only the interviewer's voice is transcribed.)
|
|
361
|
+
if not self._has_system_audio:
|
|
392
362
|
mic_buf.extend(mic_chunk.flatten())
|
|
393
363
|
|
|
394
364
|
# Drain the system-audio queue fully (non-blocking).
|
|
@@ -402,12 +372,9 @@ class CombinedAudioCapture:
|
|
|
402
372
|
# Emit EVERY complete chunk this iteration (system audio decoupled from
|
|
403
373
|
# mic — it never waits on the mic having a chunk ready).
|
|
404
374
|
if self._has_system_audio:
|
|
405
|
-
produced = self._emit_all_chunks(sys_buf, chunk_size
|
|
406
|
-
# Candidate's own voice → separate queue for the mic transcriber.
|
|
407
|
-
if self._mic_routing:
|
|
408
|
-
produced += self._emit_all_chunks(mic_buf, chunk_size, self.mic_queue)
|
|
375
|
+
produced = self._emit_all_chunks(sys_buf, chunk_size)
|
|
409
376
|
else:
|
|
410
|
-
produced = self._emit_all_chunks(mic_buf, chunk_size
|
|
377
|
+
produced = self._emit_all_chunks(mic_buf, chunk_size)
|
|
411
378
|
|
|
412
379
|
# Stall-recovery: if the downstream consumer (Deepgram feed loop) has
|
|
413
380
|
# fallen behind real-time, trim oldest queued chunks so transcripts stay
|
|
@@ -417,11 +384,6 @@ class CombinedAudioCapture:
|
|
|
417
384
|
if trimmed:
|
|
418
385
|
_trim_events += 1
|
|
419
386
|
_trim_chunks += trimmed
|
|
420
|
-
# Bound the secondary (mic) queue too — if its transcriber dies (no
|
|
421
|
-
# Whisper fallback) routing stays on, so without this it would grow
|
|
422
|
-
# without limit. Same drop-oldest-to-stay-live policy as the primary.
|
|
423
|
-
if self._mic_routing:
|
|
424
|
-
self._trim_queue(self.mic_queue)
|
|
425
387
|
now = time.time()
|
|
426
388
|
if _trim_events and now - _last_drain_warn > 30:
|
|
427
389
|
import logging
|
|
@@ -442,9 +404,9 @@ class CombinedAudioCapture:
|
|
|
442
404
|
if not produced:
|
|
443
405
|
time.sleep(0.005)
|
|
444
406
|
|
|
445
|
-
def _emit_all_chunks(self, buf: "deque", chunk_size: int
|
|
407
|
+
def _emit_all_chunks(self, buf: "deque", chunk_size: int) -> int:
|
|
446
408
|
"""Pop every complete ``chunk_size`` window from ``buf`` and forward it to
|
|
447
|
-
|
|
409
|
+
the transcriber queue. Returns the number of chunks emitted.
|
|
448
410
|
|
|
449
411
|
Draining all complete chunks (not just one per call) is what keeps the
|
|
450
412
|
local buffer from accumulating a hidden backlog when the producer briefly
|
|
@@ -453,48 +415,29 @@ class CombinedAudioCapture:
|
|
|
453
415
|
produced = 0
|
|
454
416
|
while len(buf) >= chunk_size:
|
|
455
417
|
data = np.array([buf.popleft() for _ in range(chunk_size)], dtype=np.float32)
|
|
456
|
-
|
|
418
|
+
self.audio_queue.put(data)
|
|
457
419
|
produced += 1
|
|
458
420
|
return produced
|
|
459
421
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
self._mic_routing = True
|
|
468
|
-
|
|
469
|
-
def mic_source(self) -> "_QueueAudioSource":
|
|
470
|
-
"""A capture-like view over ``mic_queue`` (get_audio + flush) to hand to a
|
|
471
|
-
second DeepgramTranscriber for the candidate's own voice."""
|
|
472
|
-
return _QueueAudioSource(self.mic_queue)
|
|
473
|
-
|
|
474
|
-
def _trim_queue(self, queue: "Queue") -> int:
|
|
475
|
-
"""Drop oldest chunks from ``queue`` when it exceeds ~2s of backlog, down to
|
|
476
|
-
a ~0.5s tail. No-op at or below the threshold. Returns the count dropped.
|
|
477
|
-
|
|
478
|
-
A growing queue means its consumer (a transcriber feed loop) is behind
|
|
479
|
-
real-time — or, for the mic queue, has died (the secondary transcriber has
|
|
480
|
-
no Whisper fallback, so a dead Deepgram socket leaves no consumer). Either
|
|
481
|
-
way, bounding it keeps transcripts live and prevents unbounded growth.
|
|
422
|
+
def _trim_stale_backlog(self) -> int:
|
|
423
|
+
"""Drop oldest queued chunks when the backlog exceeds ~2s, down to a ~0.5s
|
|
424
|
+
tail. No-op at or below the trim threshold. Returns the count dropped.
|
|
425
|
+
|
|
426
|
+
Each item is one 10ms chunk; a growing queue means the Deepgram feed loop
|
|
427
|
+
is behind real-time, which would otherwise show as transcripts arriving
|
|
428
|
+
progressively later than live speech.
|
|
482
429
|
"""
|
|
483
|
-
if
|
|
430
|
+
if self.audio_queue.qsize() <= self._STALL_TRIM_CHUNKS:
|
|
484
431
|
return 0
|
|
485
432
|
trimmed = 0
|
|
486
|
-
while
|
|
433
|
+
while self.audio_queue.qsize() > self._STALL_TAIL_CHUNKS:
|
|
487
434
|
try:
|
|
488
|
-
|
|
435
|
+
self.audio_queue.get_nowait()
|
|
489
436
|
trimmed += 1
|
|
490
437
|
except Empty:
|
|
491
438
|
break
|
|
492
439
|
return trimmed
|
|
493
440
|
|
|
494
|
-
def _trim_stale_backlog(self) -> int:
|
|
495
|
-
"""Bound the primary transcriber queue (each item is one 10ms chunk)."""
|
|
496
|
-
return self._trim_queue(self.audio_queue)
|
|
497
|
-
|
|
498
441
|
def flush(self) -> int:
|
|
499
442
|
"""Drop every queued audio chunk; return how many were dropped.
|
|
500
443
|
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/audio/transcriber.py
RENAMED
|
@@ -37,20 +37,11 @@ class DeepgramTranscriber:
|
|
|
37
37
|
transcript_buffer: "RollingTranscriptBuffer",
|
|
38
38
|
api_key: str,
|
|
39
39
|
language: str = "en",
|
|
40
|
-
label: str = "",
|
|
41
|
-
whisper_fallback: bool = True,
|
|
42
40
|
) -> None:
|
|
43
41
|
self._capture = audio_capture
|
|
44
42
|
self._buffer = transcript_buffer
|
|
45
43
|
self._language = language
|
|
46
44
|
self._api_key = api_key
|
|
47
|
-
# Secondary streams (e.g. the candidate's mic) set a label so their text
|
|
48
|
-
# is prefixed in the AI context (so the model can tell who spoke) and so
|
|
49
|
-
# they don't fight the primary stream on the live transcript bar.
|
|
50
|
-
self._label = label
|
|
51
|
-
# Secondary streams skip the Whisper fallback — one local Whisper model is
|
|
52
|
-
# enough; a second would double CPU/memory for little gain.
|
|
53
|
-
self._whisper_fallback = whisper_fallback
|
|
54
45
|
self._stop_event = threading.Event()
|
|
55
46
|
self._thread: Optional[threading.Thread] = None
|
|
56
47
|
self._connection = None
|
|
@@ -59,11 +50,6 @@ class DeepgramTranscriber:
|
|
|
59
50
|
self._last_transcript_time: float = 0.0
|
|
60
51
|
self._last_interim = None
|
|
61
52
|
|
|
62
|
-
def _buffer_text(self, sentence: str) -> str:
|
|
63
|
-
"""Prefix a labeled (secondary) stream's text so the AI context shows who
|
|
64
|
-
spoke, e.g. ``[me] ...`` for the candidate's own voice."""
|
|
65
|
-
return f"[{self._label}] {sentence}" if self._label else sentence
|
|
66
|
-
|
|
67
53
|
def _on_message(self, sender, result=None, **kwargs):
|
|
68
54
|
try:
|
|
69
55
|
if result is None:
|
|
@@ -78,10 +64,9 @@ class DeepgramTranscriber:
|
|
|
78
64
|
|
|
79
65
|
if result.is_final:
|
|
80
66
|
# Final: add to AI buffer and broadcast; clear pending interim
|
|
81
|
-
logger.info("Deepgram final
|
|
82
|
-
f" [{self._label}]" if self._label else "", sentence[:120])
|
|
67
|
+
logger.info("Deepgram final: %s", sentence[:120])
|
|
83
68
|
self._last_interim = None
|
|
84
|
-
self._buffer.append(
|
|
69
|
+
self._buffer.append(sentence)
|
|
85
70
|
state.last_activity_at = time.time()
|
|
86
71
|
try:
|
|
87
72
|
from ai_interview.metrics import metrics
|
|
@@ -91,14 +76,12 @@ class DeepgramTranscriber:
|
|
|
91
76
|
if loop is not None:
|
|
92
77
|
import asyncio
|
|
93
78
|
asyncio.run_coroutine_threadsafe(
|
|
94
|
-
self._broadcast_transcript(sentence, interim=False
|
|
79
|
+
self._broadcast_transcript(sentence, interim=False), loop
|
|
95
80
|
)
|
|
96
81
|
else:
|
|
97
|
-
# Interim: track for utterance_end flush
|
|
98
|
-
# broadcasts interims — two streams replacing the same transcript
|
|
99
|
-
# bar in-place would flicker against each other.
|
|
82
|
+
# Interim: track for utterance_end flush; broadcast to transcript bar
|
|
100
83
|
self._last_interim = sentence
|
|
101
|
-
if loop is not None
|
|
84
|
+
if loop is not None:
|
|
102
85
|
import asyncio
|
|
103
86
|
asyncio.run_coroutine_threadsafe(
|
|
104
87
|
self._broadcast_transcript(sentence, interim=True), loop
|
|
@@ -107,10 +90,10 @@ class DeepgramTranscriber:
|
|
|
107
90
|
logger.warning("Deepgram message parse error: %s", exc)
|
|
108
91
|
|
|
109
92
|
@staticmethod
|
|
110
|
-
async def _broadcast_transcript(sentence: str, interim: bool = False
|
|
93
|
+
async def _broadcast_transcript(sentence: str, interim: bool = False) -> None:
|
|
111
94
|
try:
|
|
112
95
|
from ai_interview.server.websocket import broadcast
|
|
113
|
-
await broadcast({"type": "transcript", "text": sentence, "interim": interim
|
|
96
|
+
await broadcast({"type": "transcript", "text": sentence, "interim": interim})
|
|
114
97
|
except Exception:
|
|
115
98
|
pass
|
|
116
99
|
|
|
@@ -120,13 +103,13 @@ class DeepgramTranscriber:
|
|
|
120
103
|
last = getattr(self, '_last_interim', None)
|
|
121
104
|
if last:
|
|
122
105
|
logger.info("Deepgram utterance_end flush: %s", last[:80])
|
|
123
|
-
self._buffer.append(
|
|
106
|
+
self._buffer.append(last)
|
|
124
107
|
from ai_interview.state import state
|
|
125
108
|
loop = state.asyncio_loop
|
|
126
109
|
if loop is not None:
|
|
127
110
|
import asyncio
|
|
128
111
|
asyncio.run_coroutine_threadsafe(
|
|
129
|
-
self._broadcast_transcript(last, interim=False
|
|
112
|
+
self._broadcast_transcript(last, interim=False), loop
|
|
130
113
|
)
|
|
131
114
|
self._last_interim = None
|
|
132
115
|
except Exception as exc:
|
|
@@ -214,11 +197,8 @@ class DeepgramTranscriber:
|
|
|
214
197
|
except Exception:
|
|
215
198
|
pass
|
|
216
199
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
self._start_whisper_fallback()
|
|
220
|
-
else:
|
|
221
|
-
logger.error("Deepgram reconnect failed after 10 attempts (label=%s) — giving up, no Whisper fallback for secondary stream", self._label)
|
|
200
|
+
logger.error("Deepgram reconnect failed after 10 attempts — falling back to local Whisper")
|
|
201
|
+
self._start_whisper_fallback()
|
|
222
202
|
finally:
|
|
223
203
|
self._reconnect_lock.release()
|
|
224
204
|
|
|
@@ -237,7 +217,12 @@ class DeepgramTranscriber:
|
|
|
237
217
|
"""Read audio chunks and send to Deepgram connection."""
|
|
238
218
|
last_keepalive = time.time()
|
|
239
219
|
self._last_transcript_time = time.time()
|
|
240
|
-
|
|
220
|
+
# Reconnect if the interviewer is talking (audio being sent) but Deepgram
|
|
221
|
+
# returns no transcript for this long — i.e. a silent server-side stall.
|
|
222
|
+
# Kept low (vs the old 30s) so a stall doesn't leave the interviewer's
|
|
223
|
+
# question seconds behind; finals/interims normally arrive every 1-3s, so
|
|
224
|
+
# 12s with no message while sending audio is unambiguously a dead stream.
|
|
225
|
+
_WATCHDOG_TIMEOUT = 12
|
|
241
226
|
last_watchdog_check = time.time()
|
|
242
227
|
|
|
243
228
|
while not self._stop_event.is_set():
|
|
@@ -265,7 +250,7 @@ class DeepgramTranscriber:
|
|
|
265
250
|
|
|
266
251
|
# Watchdog: if we're sending audio but getting no transcripts, connection is dead
|
|
267
252
|
now = time.time()
|
|
268
|
-
if now - last_watchdog_check >
|
|
253
|
+
if now - last_watchdog_check > 3:
|
|
269
254
|
last_watchdog_check = now
|
|
270
255
|
silence_duration = now - self._last_transcript_time
|
|
271
256
|
if silence_duration > _WATCHDOG_TIMEOUT:
|
|
@@ -249,37 +249,6 @@ def run_daemon(config: Config) -> None:
|
|
|
249
249
|
state.transcriber_name = transcriber_name
|
|
250
250
|
state.ai_model = config.model
|
|
251
251
|
|
|
252
|
-
# Secondary transcriber: the candidate's own microphone on a SEPARATE Deepgram
|
|
253
|
-
# connection (per-role, like meeting-helper). The primary stream above carries
|
|
254
|
-
# system audio (interviewer); this adds the user's voice to the AI context,
|
|
255
|
-
# prefixed "[me]" so the model can tell the two apart. Only when system audio
|
|
256
|
-
# is the primary source (otherwise the mic already IS the primary), a Deepgram
|
|
257
|
-
# key is present, and not disabled via config.
|
|
258
|
-
mic_transcriber = None
|
|
259
|
-
if (
|
|
260
|
-
getattr(config, "transcribe_mic", True)
|
|
261
|
-
and isinstance(transcriber, DeepgramTranscriber)
|
|
262
|
-
and audio_capture.has_system_audio
|
|
263
|
-
and config.deepgram_api_key
|
|
264
|
-
):
|
|
265
|
-
try:
|
|
266
|
-
mic_t = DeepgramTranscriber(
|
|
267
|
-
audio_capture.mic_source(),
|
|
268
|
-
state.transcript_buffer,
|
|
269
|
-
config.deepgram_api_key,
|
|
270
|
-
language=config.transcription_language,
|
|
271
|
-
label="me",
|
|
272
|
-
whisper_fallback=False,
|
|
273
|
-
)
|
|
274
|
-
if mic_t.start():
|
|
275
|
-
audio_capture.enable_mic_routing()
|
|
276
|
-
mic_transcriber = mic_t
|
|
277
|
-
logger.info("Mic (candidate) transcriber started on a separate Deepgram connection")
|
|
278
|
-
else:
|
|
279
|
-
logger.warning("Mic transcriber failed to start — continuing with interviewer audio only")
|
|
280
|
-
except Exception as exc:
|
|
281
|
-
logger.warning("Mic transcriber setup failed: %s — continuing without it", exc)
|
|
282
|
-
|
|
283
252
|
# -----------------------------------------------------------------------
|
|
284
253
|
# Start Datadog metrics + structured logging (no-op if dd_api_key absent)
|
|
285
254
|
# -----------------------------------------------------------------------
|
|
@@ -394,8 +363,6 @@ def run_daemon(config: Config) -> None:
|
|
|
394
363
|
finally:
|
|
395
364
|
if transcriber is not None:
|
|
396
365
|
transcriber.stop()
|
|
397
|
-
if mic_transcriber is not None:
|
|
398
|
-
mic_transcriber.stop()
|
|
399
366
|
audio_capture.stop()
|
|
400
367
|
# Clean up all screenshots captured during this session
|
|
401
368
|
try:
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/tests/test_transcription_phase.py
RENAMED
|
@@ -96,7 +96,7 @@ def test_stall_constants_are_sane():
|
|
|
96
96
|
def test_emit_all_chunks_drains_every_complete_chunk(cap):
|
|
97
97
|
from collections import deque
|
|
98
98
|
buf = deque([0.0] * (160 * 3 + 30)) # 3 full 10ms chunks + 30 leftover samples
|
|
99
|
-
produced = cap._emit_all_chunks(buf, 160
|
|
99
|
+
produced = cap._emit_all_chunks(buf, 160)
|
|
100
100
|
assert produced == 3, "must emit ALL complete chunks in one call, not just one"
|
|
101
101
|
assert cap.audio_queue.qsize() == 3
|
|
102
102
|
assert len(buf) == 30, "sub-chunk remainder stays buffered for next time"
|
|
@@ -105,45 +105,6 @@ def test_emit_all_chunks_drains_every_complete_chunk(cap):
|
|
|
105
105
|
def test_emit_all_chunks_noop_below_chunk_size(cap):
|
|
106
106
|
from collections import deque
|
|
107
107
|
buf = deque([0.0] * 159)
|
|
108
|
-
assert cap._emit_all_chunks(buf, 160
|
|
108
|
+
assert cap._emit_all_chunks(buf, 160) == 0
|
|
109
109
|
assert cap.audio_queue.qsize() == 0
|
|
110
110
|
assert len(buf) == 159
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def test_emit_all_chunks_targets_the_given_queue(cap):
|
|
114
|
-
from collections import deque
|
|
115
|
-
buf = deque([0.0] * 320)
|
|
116
|
-
cap._emit_all_chunks(buf, 160, cap.mic_queue)
|
|
117
|
-
assert cap.mic_queue.qsize() == 2
|
|
118
|
-
assert cap.audio_queue.qsize() == 0, "must write to the queue it was handed"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
# --------------------------------------------------------------------------
|
|
122
|
-
# Separate mic stream: routing flag + queue adapter
|
|
123
|
-
# --------------------------------------------------------------------------
|
|
124
|
-
|
|
125
|
-
def test_enable_mic_routing_flag(cap):
|
|
126
|
-
assert cap._mic_routing is False
|
|
127
|
-
cap.enable_mic_routing()
|
|
128
|
-
assert cap._mic_routing is True
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def test_mic_source_get_and_flush(cap):
|
|
132
|
-
src = cap.mic_source()
|
|
133
|
-
assert src.get_audio(timeout=0.001) is None # empty queue
|
|
134
|
-
cap.mic_queue.put(_chunk())
|
|
135
|
-
cap.mic_queue.put(_chunk())
|
|
136
|
-
assert src.get_audio(timeout=0.001) is not None
|
|
137
|
-
assert src.flush() == 1 # the one remaining chunk dropped
|
|
138
|
-
assert cap.mic_queue.qsize() == 0
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def test_trim_queue_bounds_mic_queue(cap):
|
|
142
|
-
# If the mic transcriber dies, routing stays on and mic_queue would grow
|
|
143
|
-
# unbounded — _trim_queue must cap it to the live tail like the primary.
|
|
144
|
-
over = cap._STALL_TRIM_CHUNKS + 100
|
|
145
|
-
for _ in range(over):
|
|
146
|
-
cap.mic_queue.put(_chunk())
|
|
147
|
-
trimmed = cap._trim_queue(cap.mic_queue)
|
|
148
|
-
assert cap.mic_queue.qsize() == cap._STALL_TAIL_CHUNKS
|
|
149
|
-
assert trimmed == over - cap._STALL_TAIL_CHUNKS
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/audio/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/__init__.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/__main__.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/flet_gui/app.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/hotkey_config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/llm_clients.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/ollama_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/screenshot.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/__init__.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/app.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/routes.py
RENAMED
|
File without changes
|
{ai_interview_assistant-2.3.2 → ai_interview_assistant-2.3.3}/src/ai_interview/server/websocket.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|