Merge remote-tracking branch 'origin/main'
Docs / docs (push) Successful in 28s
Playwright Tests / test-playwright (1, 2) (push) Successful in 4m6s
Playwright Tests / test-playwright (2, 2) (push) Successful in 2m36s
pre-commit / pre-commit (push) Successful in 3m33s
Test Backend / test-backend (3.12) (push) Failing after 6m15s
Test Backend / test-backend (3.14) (push) Failing after 5m56s
Compose Smoke Test / test-compose (push) Successful in 36s
Playwright Tests / merge-reports (push) Successful in 1m20s

This commit is contained in:
2026-11-06 14:39:38 +01:00
6 changed files with 93 additions and 24 deletions
+17 -8
View File
@@ -9,7 +9,7 @@ offered. Every other input is read as context ("outside_temperature: 7.5").
An answer goes out on ``reply`` a sentence at a time while the model writes
it, so a ``tts`` node speaks the first before the last is written. A change is
confirmed from the values set ("Kitchen light off."), without asking the model
a second time.
a second time. Talk the panel overheard, such as a TV, gets no answer.
"""
from __future__ import annotations
@@ -47,6 +47,10 @@ LISTENING = "listening"
UNAVAILABLE = "The assistant isn't available right now."
#: Said when the model ends a turn without a word or a change.
CANT = "Sorry, I can't do that."
#: The model's whole answer to talk not meant for the panel, which is not said.
#: Asked to answer with nothing instead, Gemma writes tokens nobody sees until
#: the length limit.
IGNORED = "Ignored."
#: A server that is not there is given up on after a few seconds, while a
#: model that has to be loaded first takes about ten.
@@ -60,14 +64,18 @@ _SCHEMAS: dict[DType, dict[str, str]] = {
DType.STR: {"type": "string"},
}
_SYSTEM = """You are the voice of a home: someone spoke to a panel on the wall, \
_SYSTEM = f"""You are the voice of a home: someone spoke to a panel on the wall, \
and you answer out loud.
- To change something, call its tool without a word: the change is confirmed \
for you. The tools are all you can change.
- If no tool can do what was asked, or you did not understand it, say so in a \
few words, such as "Sorry, I can't do that."
- Answer questions from the readings below.
- To change something in the home, call its tool without a word: the change \
is confirmed for you. The tools are all you can change.
- If a change was asked for that no tool can make, say so in a few words, such \
as "Sorry, I can't do that."
- Answer questions about the home from the readings below, and other questions \
from what you know.
- The panel also hears talk that is not meant for it, such as a TV or people \
talking to each other. If the words are neither a request nor a question for \
you, answer only "{IGNORED}"
- Speak plainly: one or two short sentences, no lists, no markdown, no emoji.
"""
@@ -308,7 +316,8 @@ class AssistantNode(Node):
async def say(text: str) -> None:
nonlocal said
said = True
await asyncio.to_thread(self._say, text)
if text.rstrip(".") != IGNORED.rstrip("."):
await asyncio.to_thread(self._say, text)
if config is None:
await say(UNAVAILABLE)
+23 -3
View File
@@ -186,7 +186,18 @@ class SttNode(_Speech):
alone.
"""
__slots__ = ("_heard", "_listening", "_lock", "_session", "_tasks")
class Params(BaseModel):
model_config = ConfigDict(extra="allow")
prompt: str = Field(
default="",
description=(
"Words the speech is likely to hold, such as the names of rooms "
"and devices, given to the server as its transcription prompt."
),
)
__slots__ = ("cfg", "_heard", "_listening", "_lock", "_session", "_tasks")
def __init__(
self,
@@ -195,6 +206,7 @@ class SttNode(_Speech):
params: dict[str, Any] | None = None,
name: str | None = None,
):
self.cfg = self.Params.model_validate(params or {})
self._lock = threading.Lock()
#: The chunks of the utterance being spoken, None between utterances.
self._session: asyncio.Queue[bytes | None] | None = None
@@ -293,7 +305,11 @@ class SttNode(_Speech):
try:
async with asyncio.timeout(UTTERANCE_S):
async for final, text in client.transcribe_stream(
url + "/v1", chunks, rate=RATE, idle_s=IDLE_S
url + "/v1",
chunks,
rate=RATE,
idle_s=IDLE_S,
prompt=self.cfg.prompt,
):
words = text.strip() if final else words + text
if final and words:
@@ -317,7 +333,11 @@ class SttNode(_Speech):
async def _clip(self, url: str, audio: dict[str, Any], data: bytes) -> None:
try:
text = await client.transcribe(
url + "/v1", data, "speech.wav", str(audio.get("media_type"))
url + "/v1",
data,
"speech.wav",
str(audio.get("media_type")),
prompt=self.cfg.prompt,
)
except Exception as exc:
logger.warning("'%s' lost a clip: %s: %s", self.id, type(exc).__name__, exc)