Commit Graph
84 Commits
Author SHA1 Message Date
didar 2ea6e6f4bb feat: update AI voice settings for improved responsiveness and pacing
deploy / deploy (push) Successful in 31s
2026-08-25 01:42:10 +05:00
didar 6ccdaf9167 feat: update ElevenLabs TTS model ID and add prebuffering for improved audio streaming
deploy / deploy (push) Successful in 31s
2026-08-25 01:20:52 +05:00
didar c399296165 feat: implement no-speech reprompt functionality with configurable parameters
deploy / deploy (push) Successful in 33s
2026-08-24 14:17:00 +05:00
didar c590528694 feat: add debug audio dump functionality for ElevenLabs ASR provider
deploy / deploy (push) Successful in 30s
2026-08-23 13:38:56 +05:00
didar 9a09a39849 feat: enhance ElevenLabs ASR provider to accumulate autonomous VAD commits
deploy / deploy (push) Successful in 31s
2026-08-23 13:20:31 +05:00
didar 8dd3e238f2 feat: enhance low signal transcript handling with finalization checks and logging
deploy / deploy (push) Successful in 31s
2026-08-23 12:40:59 +05:00
didar 4e1039ab58 Merge pull request 'Play a filler ack during slow voice decisions and cache KB search rows' (#2) from voice-latency-llm-tts-improvements into main
deploy / deploy (push) Canceled after 27h22m42s
Reviewed-on: #2
2026-08-20 09:47:45 +00:00
Didar KozhikovandClaude Sonnet 5 49489f89b5 Play a filler ack during slow voice decisions and cache KB search rows
Two independent latency fixes for the voice-assistant reply pipeline,
both scoped to the parts of the flow that run regardless of whether
voice_v2 is enabled for a queue:

1. media_runtime._process_utterance: the v1/fallback turn path (used by
   any queue not covered by AI_VOICE_V2_QUEUE_CODES) silently awaited the
   full LLM decision with no audio playing at all, unlike the v2 path
   which already has a decision-timeout ack. Give v1 the same behavior:
   wait up to 600ms (_v1_ack_wait_seconds) for the decision, and if it's
   still not ready, play a short "Секунду." filler via the existing
   _emit_early_ack before the real reply, instead of leaving the caller
   in silence for the full LLM+TTS round trip. Reuses the same ack
   selection/playback code path v2 already exercises, so no new failure
   modes - just an added timeout branch mirroring the existing v2 one.

2. ai_orchestrator_service._kb_search: every voice/chat turn re-ran a
   full-table scan of kb_articles (all columns, including body text) and
   rescored every row in Python, even though the KB rarely changes
   mid-conversation. Added an in-process cache keyed by language, gated
   on a cheap content fingerprint (row count + max id + max updated_at +
   summed title/body/tags length, all computed server-side without
   transferring the text columns). A fingerprint mismatch always
   triggers a fresh fetch, so this can never serve stale results after
   an insert/update/delete - unlike a naive TTL cache, which would have
   been be wrong the moment a test (or a real KB edit) changed the table
   within the cache window.

   Note the first fingerprint design (count + max id + max updated_at
   only) was insufficient: utc_now_iso() truncates to whole seconds and
   SQLite reuses primary keys after a full-table delete, so two
   different row sets written in the same wall-clock second could share
   a fingerprint. Caught this via a real test failure
   (test_ai_whatsapp_relaxed_kb_search_answers_phrase_query breaking
   only when run after test_ai_orchestrator_service.py in the same
   process) before it could reach production; the summed content-length
   term closes the gap.

Added test_media_runtime_plays_filler_ack_when_v1_decision_is_slow
(asserts greeting -> ack -> reply delivery order when process_turn is
slow) and verified the KB cache against the full
test_ai_orchestrator_service.py + test_ai_whatsapp_orchestrator_service.py
suite plus a wider kb/orchestrator/whatsapp/telegram/voice-filtered run:
only the same pre-existing, already-documented failures remain (unrelated
sales_service test-isolation ordering, one known persona-prompt
assertion) - no new failures from either change.

Streaming the LLM decision itself (start speaking reply_text before the
full structured JSON response finishes generating) was scoped but
deliberately deferred: it needs incremental JSON parsing on top of SSE
streaming to detect when just the reply_text field is complete, shared
across both voice and text-channel decision paths - a separate,
higher-risk change that deserves its own PR and testing pass rather than
being bundled here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-19 21:54:02 +05:00
Didar KozhikovandClaude Sonnet 5 a9be976845 Implement real streaming TTS for ElevenLabs to cut voice-assistant reply latency
The AudioSocket/media_runtime playback pipeline already supports chunked
TTS streaming (voice_v2_streaming_tts), but every provider inherited the
base TTSProvider.synthesize_chunks(), which just called the blocking
synthesize() and yielded the entire finished audio as a single "chunk" -
so the caller waited for full-utterance synthesis before any playback
could start regardless of the flag.

ElevenLabs is the production default (AI_VOICE_TTS_PROVIDER=elevenlabs in
deployment/docker-compose.server.yml), so give it a real implementation
that POSTs to the /stream endpoint and yields audio as network chunks
arrive, instead of waiting for the whole response body. Chunk boundaries
are re-aligned to whole 16-bit PCM samples so a split sample at a network
read boundary can't corrupt playback. The full synthesized audio is still
written to the on-disk cache afterwards so repeat phrases stay fast and
skip the vendor call entirely, matching the existing synthesize() cache
behavior.

Added test_elevenlabs_tts_provider_streams_chunks_and_caches_full_audio to
cover: chunk splitting mid-sample gets re-aligned, all yielded chunks are
sample-aligned, the full audio round-trips through the cache, and a
cached synthesis is replayed without invoking the streaming endpoint
again.

Verified via tests/test_ai_voice_tts_provider.py (9/9 pass) and a wider
voice/tts-filtered run across the suite: the only failures present are
the same pre-existing, already-documented ones (sales_service test
cross-file isolation ordering, one known persona-prompt assertion) -
identical set to before this change, no new failures.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-19 21:40:35 +05:00
Magzhan Zhumabayev 5236ee74ac Autostage Telegram sales leads 2026-05-12 19:41:04 +05:00
Magzhan Zhumabayev fbc77ba8a7 Expand sales leads and customer contracts 2026-05-12 19:09:31 +05:00
Magzhan Zhumabayev ce3ba270aa Add configurable AI operator persona 2026-05-11 17:37:26 +05:00
Magzhan Zhumabayev 67a0255c0d Fix sales post-repair acceptance gaps 2026-05-11 17:33:08 +05:00
Magzhan Zhumabayev 64862dd49a Add sales contract repair routes 2026-05-11 16:57:30 +05:00
Magzhan Zhumabayev ebba6c3f82 Allow tenant header for bearer-authenticated requests 2026-05-11 16:02:16 +05:00
Magzhan Zhumabayev 53f9845195 Enrich Telegram error alerts with request and upstream context 2026-05-11 13:52:13 +05:00
Magzhan Zhumabayev bf75a005c2 Normalize Telegram t.me channel IDs 2026-05-11 13:41:25 +05:00
Magzhan Zhumabayev 000ac984b6 Add Telegram channel alerts for gateway errors 2026-05-11 13:35:52 +05:00
Magzhan Zhumabayev a14fdea34f Fix sales API proxy endpoints and tests 2026-05-11 13:28:00 +05:00
Admin 8577d97356 Implement sales CRM workflow foundation 2026-05-10 20:54:01 +05:00
Magzhan Zhumabayev 866d96e560 Implement sales tenant pipeline events 2026-05-10 18:24:06 +05:00
Your Name fd1707bc58 Route /dashboard to sales UI 2026-05-09 10:40:13 +05:00
arys f53af1f7dc sales fix 2026-05-09 09:16:06 +05:00
Magzhan Zhumabayev d617b6908c . 2026-05-04 23:00:34 +05:00
Yera All aa64b6b94c Revert "feat(voice): start early replies before final asr"
This reverts commit a44a1b97a1.
2026-04-19 01:30:26 +05:00
Yera All 224973d840 Revert "fix(voice): race slow streaming asr finalize"
This reverts commit 77df41bce0.
2026-04-19 01:30:26 +05:00
Yera All 93002ab86a Revert "fix(voice): stop repeating failed clarifications"
This reverts commit 294d30a797.
2026-04-19 01:30:26 +05:00
Yera All 294d30a797 fix(voice): stop repeating failed clarifications 2026-04-19 01:19:54 +05:00
Yera All 77df41bce0 fix(voice): race slow streaming asr finalize 2026-04-19 01:06:03 +05:00
Yera All a44a1b97a1 feat(voice): start early replies before final asr 2026-04-19 00:46:16 +05:00
Yera All 9cd553bf92 feat(voice): start replies from stable streaming partials 2026-04-19 00:13:58 +05:00
Yera All 770ba4e925 feat(voice): add elevenlabs realtime streaming asr 2026-04-18 20:15:44 +05:00
Yera All ff3efe395b test(voice): align start name policy with service intent priority 2026-04-18 18:47:18 +05:00
Yera All 34b807e460 feat(voice): add elevenlabs stt and transcript truth fixes 2026-04-18 18:25:07 +05:00
Yera All ac2269b6a4 fix(voice): correct yandex asr endpoints 2026-04-17 13:39:26 +05:00
Yera All feb0ce01e2 fix(asterisk): update telecom route and recording fallback 2026-04-17 12:16:51 +05:00
Yera All 4adaf192fb fix(voice): avoid silence on ASR runtime failures 2026-04-17 01:28:06 +05:00
Yera All f66b289371 feat(voice): add Yandex streaming ASR 2026-04-17 01:06:45 +05:00
Yera All 5d40cfafd8 feat(voice): switch voice ASR to Yandex SpeechKit 2026-04-17 00:53:20 +05:00
Yera All 39096e114f fix(voice): harden noisy streaming turns 2026-04-17 00:30:41 +05:00
Yera All 8ca5f23e93 Polish operator messenger layout 2026-04-17 00:14:41 +05:00
Yera All aa6f838061 fix(voice): keep asr partial polling off push path 2026-04-17 00:06:27 +05:00
Yera All 52b2edfcd3 fix(voice): stop thinking continuation on silence 2026-04-16 23:56:10 +05:00
Yera All f14aeb39df test(voice): wait for async streaming asr push 2026-04-16 23:48:07 +05:00
Yera All d331981ac8 fix(voice): decouple streaming asr from media loop 2026-04-16 23:11:24 +05:00
Yera All 3b5a7ad2e7 Add operator unified messenger MVP 2026-04-16 22:16:57 +05:00
Yera All 1206ff91ac chore: push remaining local changes 2026-04-16 02:31:57 +05:00
Yera All 5af47991dc fix(voice): stabilize turn finalization after asr timeouts 2026-04-16 02:30:39 +05:00
Yera All 6b8f5d069b feat(ai): add rolling conversation summary memory 2026-04-13 11:59:43 +05:00
Yera All 989bf9a0c1 fix(voice): stabilize v2 streaming topic handling 2026-04-12 21:59:32 +05:00