Commit graph

2 commits

Author SHA1 Message Date
Bossiara13
20b6b06b5d test: +13 more tests (99→112), incl. live Ollama smoke (ignored by default)
text_utils (was 5, now 12 tests, +7)
  - empty_input_yields_empty_output
  - handles_usa_uk_sos_brands — verifies all brand replacements survive
  - collapse_two_letter_acronym_not_changed — 2-letter dotted patterns stay
  - short_url_under_threshold_not_stripped — gate is len > 7
  - smart_quotes_softened — «»/"" stripped
  - collapses_repeated_whitespace — no 3+ spaces in row
  - idempotent_when_already_clean — sanitize(sanitize(x)) == sanitize(x)

llm::client (was 4, now 10 tests + 1 ignored, +6 + 1 smoke)
  - chat_message_serde_round_trip — pins JSON shape {role, content}
  - ollama_client_has_no_api_key — uses LlmBackend::Ollama
  - groq_client_carries_token — verifies token + default model
  - ollama_default_model_can_be_overridden — OLLAMA_MODEL env honoured
  - parses_response_with_unicode_content — Russian Cyrillic survives JSON
  - empty_choices_yields_empty_response_err — graceful on []
  - ollama_smoke (#[ignore]) — actual API call when Ollama is running locally.
    Run with: cargo test --lib llm::client::tests::ollama_smoke -- --ignored

Total: 112 passing + 1 ignored. Smoke test verified locally — Ollama not
running (expected), test correctly skipped.

Build: cargo build --release -p jarvis-app -p jarvis-gui green.
2026-05-15 18:40:06 +03:00
Bossiara13
80b54af1ee fix(tts): sanitise text before SAPI so it stops reading "J.A.R.V.I.S." as "J точка A точка R точка..."
User complaint: SAPI reads every dotted acronym character-by-character with a
"точка" between letters. Unbearable on every speak. No real TTS analog
shipping yet (Silero/Coqui/Inworld in roadmap), so the immediate fix is text
preprocessing.

New module `jarvis-core::text_utils` with `sanitize_for_speech()`:
- Specific brand mapping: J.A.R.V.I.S. → Джарвис, U.S.A. → США, U.K. →
  Британия, U.S. → США, S.O.S. → сос.
- Generic dotted-acronym collapse: any `[letter].[letter].[letter].(...)`
  run of 3+ letters gets its dots stripped. "T.O.N." → "TON".
- URL stripping: anything starting with http/https gets replaced with the
  word "ссылка". SAPI reading URLs char-by-char is unlistenable.
- Em/en-dash normalisation: — → -, « » " stripped.
- Whitespace collapse.

Wired in two places:
- `jarvis.speak(text, opts?)` Lua API runs sanitiser unless opts.raw=true.
- `jarvis-app/llm_fallback::speak_via_sapi` runs sanitiser before the SAPI
  PowerShell shell-out for LLM auto-fallback replies.

5 unit tests in `text_utils::tests` covering jarvis-name collapse, generic
acronym pattern, URL stripping, dash normalisation, and "leave clean
russian sentences alone" — all green.

Real TTS upgrade (Silero v4 first cut) tracked as P0.1 in roadmap.
2026-05-15 14:48:42 +03:00