Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ on:

jobs:
lint-and-test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]
include:
# README promises Python 3.9+. ubuntu-latest (26.04 since 2026-11)
# no longer offers 3.9 in setup-python, so this one job stays on
# 24.04 — remove it together with the 3.9 promise, not before.
- os: ubuntu-24.04
python-version: "3.9"

steps:
- name: Checkout code
Expand Down
16 changes: 15 additions & 1 deletion brain/nox_voice_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,20 @@ def sanitize_speech(text):
return cleaned or None


_D_ACCORD = re.compile(r"(?<!\w)d['\u2019]accord(?!\w)", re.IGNORECASE)


def echo_safe_speech(text):
"""The fixed replies stopped saying "D'accord !" because Vosk hears the
dog's own voice say it as 'dakar' — an echo no word match can catch
(issue #45, log 10). In chat mode the LLM writes its own sentences and
still reached for the word (log 11), so it is swapped for "OK" on the
way to the TTS, whatever the model wrote."""
if not text:
return text
return _D_ACCORD.sub("OK", text)


# ─── Voice Processing ───
def process_voice_intelligent(msg):
"""Process voice input using Claude AI."""
Expand Down Expand Up @@ -570,7 +584,7 @@ def process_voice_intelligent(msg):
if response_text:
parsed = parse_response(response_text)

speak_text = sanitize_speech(parsed.get("speak", response_text))
speak_text = echo_safe_speech(sanitize_speech(parsed.get("speak", response_text)))
actions = parsed.get("actions", [])
if parsed.get("_no_json") and not actions:
# A small model that ignored the JSON format would make the dog
Expand Down
46 changes: 46 additions & 0 deletions tests/test_field_session_6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Round six of field findings (issue #45, log 11, 2026-10-30).

The fixed replies say "OK !" since round five, yet 'dakar' still showed up in
the voice log: in chat mode the LLM writes its own sentences and can pick
"d'accord" by itself. The word is now swapped for "OK" on the way to the TTS.
"""
import inspect

import brain.nox_voice_brain as vb


def test_d_accord_from_the_llm_becomes_ok():
assert vb.echo_safe_speech("D'accord ! J'arrive.") == "OK ! J'arrive."
assert vb.echo_safe_speech("d'accord") == "OK"


def test_typographic_apostrophe_and_case_are_covered():
# LLMs like the curly apostrophe
assert vb.echo_safe_speech("D’accord, je m’assois.") == "OK, je m’assois."
assert vb.echo_safe_speech("D'ACCORD !") == "OK !"


def test_word_in_the_middle_of_a_sentence():
assert vb.echo_safe_speech("Je suis d'accord avec toi.") == "Je suis OK avec toi."


def test_other_words_and_apostrophes_stay():
for sentence in ("J'arrive tout de suite.", "Un accord parfait.", "Raccordé !",
"Sitz! Mach ich.", "On it!"):
assert vb.echo_safe_speech(sentence) == sentence


def test_nothing_to_say_stays_nothing():
assert vb.echo_safe_speech(None) is None
assert vb.echo_safe_speech("") == ""


def test_sanitize_speech_itself_is_unchanged():
# its job is stage directions and markdown — the apostrophe test of
# round two keeps holding
assert vb.sanitize_speech("D'accord ! J'arrive.") == "D'accord ! J'arrive."


def test_the_llm_reply_passes_through_the_swap_before_the_tts():
src = inspect.getsource(vb.process_voice_intelligent)
assert "echo_safe_speech(sanitize_speech(" in src
Loading