From 2a46088a5ae40f1df4f8f622ff315522fbcc019e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20B=C3=B6hm?= Date: Sun, 8 Nov 2026 05:25:00 +0000 Subject: [PATCH] 26.11.46: dictate the shopping list - Microphone next to the free-text field when a speech model is set up - Transcript split into items by rules (lib/spoken-list.ts), no model; the person checks and edits before they are added - Shared transcribeUpload (lib/voice.ts) and useRecorder hook - POST /api/shopping/items accepts several labels at once Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HUc2nv7rJVU2gp3Bgtha3q --- CLAUDE.md | 4 +- OlaresManifest.yaml | 4 +- app/(app)/einkauf/page.tsx | 3 +- app/api/dishes/voice/route.ts | 27 ++------ app/api/shopping/items/route.ts | 7 +- app/api/shopping/voice/route.ts | 18 +++++ components/shopping/shopping-list.tsx | 5 +- components/shopping/voice-add.tsx | 99 +++++++++++++++++++++++++++ docs/entscheidungen.md | 8 +++ e2e/einkauf.spec.ts | 24 +++++++ lib/spoken-list.ts | 28 ++++++++ lib/use-recorder.ts | 48 +++++++++++++ lib/voice.ts | 29 ++++++++ messages/de.json | 22 +++++- messages/en.json | 22 +++++- messages/es.json | 22 +++++- messages/fr.json | 22 +++++- olares/Chart.yaml | 4 +- olares/OlaresManifest.yaml | 4 +- olares/markt/26.11.46.md | 5 ++ tests/spoken-list.test.ts | 20 ++++++ 21 files changed, 387 insertions(+), 38 deletions(-) create mode 100644 app/api/shopping/voice/route.ts create mode 100644 components/shopping/voice-add.tsx create mode 100644 lib/spoken-list.ts create mode 100644 lib/use-recorder.ts create mode 100644 lib/voice.ts create mode 100644 olares/markt/26.11.46.md create mode 100644 tests/spoken-list.test.ts diff --git a/CLAUDE.md b/CLAUDE.md index a1819fc..219827a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,7 +7,7 @@ > **Plattform:** Olares One (Kubernetes), Repo und CI auf Gitea — kein Supabase, > kein Vercel (E-0001). Eigene Gestaltung, nicht AImighty (E-0002). > Verteilung über den Markt, Repo öffentlich (E-0005). -> **Status:** 26.11.45 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut: +> **Status:** 26.11.46 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut: > Anmeldung (Passkeys, Kinder mit Gerät + PIN), Gerichte (Link, Kochbuchfoto, AI über den > Olares Router), Wünschen, Plan, Einkaufsliste (Echtzeit, offline), Kochmodus mit > Bewertung, Web-App; Einzahl bei Stück-Mengen (26.11.15), Preise und Kosten mit Ampel @@ -22,7 +22,7 @@ > (26.11.39, E-0016), Anmelden per Mail-Link über Resend (26.11.40, E-0017; nur > anmelden, keine Geräte oder Passkeys aus einer Mail-Sitzung), Leiste bleibt nach der > Tastatur unten (26.11.41), Icon Kochmütze mit Herz (26.11.42), Fotos aus der Mediathek (26.11.43), gleich große Karten (26.11.44), Runde beenden/löschen/ändern, -> Tage je Gericht von Hand und Kalender-Abo je Haushalt (26.11.45, E-0018). Offen: Kai trägt +> Tage je Gericht von Hand und Kalender-Abo je Haushalt (26.11.45, E-0018), Einkaufsliste einsprechen (26.11.46). Offen: Kai trägt > den Resend-Schlüssel unter Mehr › Mails verschicken ein und abonniert den Kalender-Link einmal auf dem iPhone. > **Letzte Aktualisierung:** 8. November 2026 diff --git a/OlaresManifest.yaml b/OlaresManifest.yaml index 9baccd1..e379235 100644 --- a/OlaresManifest.yaml +++ b/OlaresManifest.yaml @@ -21,7 +21,7 @@ metadata: title: foodplanhero description: Plan. Cook. Smile. The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box. icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png - version: 26.11.45 + version: 26.11.46 categories: - Applications @@ -61,7 +61,7 @@ permission: appData: true spec: - versionName: '26.11.45' + versionName: '26.11.46' featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png promoteImage: diff --git a/app/(app)/einkauf/page.tsx b/app/(app)/einkauf/page.tsx index 2a9c19b..9cb4451 100644 --- a/app/(app)/einkauf/page.tsx +++ b/app/(app)/einkauf/page.tsx @@ -4,6 +4,7 @@ import { getLocale, getTranslations } from "next-intl/server"; import { ShoppingList } from "@/components/shopping/shopping-list"; import { StorePicker } from "@/components/shopping/store-picker"; import { buttonVariants } from "@/components/ui/button"; +import { aiFor } from "@/lib/ai-settings"; import { requireAdult } from "@/lib/auth/session"; import { withHousehold } from "@/lib/db"; import { currentRound } from "@/lib/rounds"; @@ -37,7 +38,7 @@ export default async function ShoppingPage() { {data.chains.length ? : null} {"items" in data && data.items ? ( - + ) : (

{data.round ? t("notYet") : t("noRound")}

diff --git a/app/api/dishes/voice/route.ts b/app/api/dishes/voice/route.ts index 8c78d45..8efeb8e 100644 --- a/app/api/dishes/voice/route.ts +++ b/app/api/dishes/voice/route.ts @@ -1,30 +1,13 @@ -import { getLocale } from "next-intl/server"; -import { AiNotConfigured, AiUnavailable, transcribe } from "@/lib/ai"; -import { aiFor } from "@/lib/ai-settings"; import { guardWrite, isResponse } from "@/lib/auth/guard"; -import { fail, json } from "@/lib/auth/http"; +import { json } from "@/lib/auth/http"; +import { transcribeUpload } from "@/lib/voice"; export const dynamic = "force-dynamic"; -const MAX_BYTES = 25 * 1024 * 1024; // rund zehn Minuten Sprache - -// Gericht einsprechen, Schritt 1: Aufnahme → Abschrift (Router „default-stt“ oder -// eigenes Sprachmodell). Die Aufnahme wird nicht gespeichert. +// Gericht einsprechen, Schritt 1: Aufnahme → Abschrift. export async function POST(request: Request) { const session = await guardWrite(request); if (isResponse(session)) return session; - const form = await request.formData().catch(() => null); - const audio = form?.get("audio"); - if (!(audio instanceof File) || audio.size === 0 || audio.size > MAX_BYTES || !/^(audio|video)\//.test(audio.type)) return fail("audio", 400); - const ai = await aiFor(session.householdId); - if (!ai?.speechModel) return fail("noSpeech", 409); - try { - const ext = audio.type.includes("mp4") || audio.type.includes("m4a") ? "m4a" : audio.type.includes("ogg") ? "ogg" : audio.type.includes("wav") ? "wav" : "webm"; - const text = await transcribe(ai, audio, `aufnahme.${ext}`, await getLocale()); - if (!text) return fail("empty", 422); - return json({ text }); - } catch (error) { - if (error instanceof AiUnavailable || error instanceof AiNotConfigured) return fail("aiUnavailable", 503); - throw error; - } + const result = await transcribeUpload(request, session.householdId); + return result instanceof Response ? result : json(result); } diff --git a/app/api/shopping/items/route.ts b/app/api/shopping/items/route.ts index 766a269..75aabe8 100644 --- a/app/api/shopping/items/route.ts +++ b/app/api/shopping/items/route.ts @@ -14,10 +14,13 @@ export async function PATCH(request: Request) { } export async function POST(request: Request) { - const body = z.object({ label: z.string().trim().min(1).max(80) }).safeParse(await readJson(request)); + // Ein Posten getippt, oder mehrere auf einmal nach dem Einsprechen (26.11.46). + const label = z.string().trim().min(1).max(80); + const body = z.union([z.object({ label }), z.object({ labels: z.array(label).min(1).max(20) })]).safeParse(await readJson(request)); if (!body.success) return fail("invalid", 400); + const labels = "labels" in body.data ? body.data.labels : [body.data.label]; return withShopping(request, async (c, round, session) => { - await addManual(c, session.householdId, round.id, body.data.label); + for (const l of labels) await addManual(c, session.householdId, round.id, l); return json({ ok: true }, 201); }); } diff --git a/app/api/shopping/voice/route.ts b/app/api/shopping/voice/route.ts new file mode 100644 index 0000000..5c6ac10 --- /dev/null +++ b/app/api/shopping/voice/route.ts @@ -0,0 +1,18 @@ +import { guardWrite, isResponse } from "@/lib/auth/guard"; +import { json } from "@/lib/auth/http"; +import { SHOPPERS } from "@/lib/auth/roles"; +import { splitSpoken } from "@/lib/spoken-list"; +import { transcribeUpload } from "@/lib/voice"; + +export const dynamic = "force-dynamic"; + +// Einkaufsliste einsprechen (Kai, 8.11.2026): Abschrift → einzelne Posten. Kein +// Sprachmodell zerlegt — die Regeln in lib/spoken-list.ts tun es, und auf die +// Liste kommt erst, was die Person geprüft hat. +export async function POST(request: Request) { + const session = await guardWrite(request, [...SHOPPERS]); + if (isResponse(session)) return session; + const result = await transcribeUpload(request, session.householdId); + if (result instanceof Response) return result; + return json({ text: result.text, items: splitSpoken(result.text) }); +} diff --git a/components/shopping/shopping-list.tsx b/components/shopping/shopping-list.tsx index 8c7b958..209a04f 100644 --- a/components/shopping/shopping-list.tsx +++ b/components/shopping/shopping-list.tsx @@ -5,6 +5,7 @@ import { useLocale, useTranslations } from "next-intl"; import { useCallback, useEffect, useRef, useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; +import { VoiceAdd } from "@/components/shopping/voice-add"; import { formatQuantity, type PackKind } from "@/lib/units"; import { cn } from "@/lib/utils"; @@ -46,7 +47,7 @@ function writeQueue(ops: Op[]) { // Einkaufsliste (Konzept, „Einkaufen“): große Haken, nach Gängen des Hauptladens, // in Echtzeit bei allen (SSE), und ohne Netz bedienbar — Haken landen in einer // Warteschlange im Browser und gehen raus, sobald wieder Netz da ist. -export function ShoppingList({ initial, aisles, me }: { initial: Item[]; aisles: Aisle[]; me: string }) { +export function ShoppingList({ initial, aisles, me, canRecord = false }: { initial: Item[]; aisles: Aisle[]; me: string; canRecord?: boolean }) { const t = useTranslations("shopping"); const tm = useTranslations("measure"); const locale = useLocale(); @@ -131,6 +132,7 @@ export function ShoppingList({ initial, aisles, me }: { initial: Item[]; aisles: async function send(method: string, url: string, body: object) { const res = await fetch(url, { method, headers: { "content-type": "application/json" }, body: JSON.stringify(body) }).catch(() => null); if (res?.ok) await reload(); + return !!res?.ok; } const amount = (i: Item) => { @@ -212,6 +214,7 @@ export function ShoppingList({ initial, aisles, me }: { initial: Item[]; aisles: + {canRecord ? send("POST", "/api/shopping/items", { labels })} /> : null} {done.length ? (
diff --git a/components/shopping/voice-add.tsx b/components/shopping/voice-add.tsx new file mode 100644 index 0000000..de4f3d9 --- /dev/null +++ b/components/shopping/voice-add.tsx @@ -0,0 +1,99 @@ +"use client"; + +import { Mic, Square, X } from "lucide-react"; +import { useTranslations } from "next-intl"; +import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { ErrorNotice } from "@/components/ui/notice"; +import { useRecorder } from "@/lib/use-recorder"; + +const mmss = (s: number) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`; + +// Einkaufsliste einsprechen (Kai, 8.11.2026, 26.11.46): aufnehmen, Abschrift in +// Posten zerlegen (lib/spoken-list.ts), prüfen und ändern, dann hinzufügen. +export function VoiceAdd({ onAdd }: { onAdd: (labels: string[]) => Promise }) { + const t = useTranslations("shopping.voice"); + const [busy, setBusy] = useState<"transcribe" | "add" | null>(null); + const [error, setError] = useState(null); + const [items, setItems] = useState(null); + const rec = useRecorder(upload); + + async function upload(audio: Blob) { + setBusy("transcribe"); + const form = new FormData(); + form.append("audio", new File([audio], "aufnahme", { type: audio.type })); + const res = await fetch("/api/shopping/voice", { method: "POST", body: form }).catch(() => null); + const data = await res?.json().catch(() => ({})); + setBusy(null); + if (!res?.ok) return setError(["noSpeech", "aiUnavailable", "empty", "audio"].includes(data?.error) ? data.error : "unknown"); + if (!data.items?.length) return setError("empty"); + setItems(data.items); + } + + async function add() { + const labels = (items ?? []).map((i) => i.trim()).filter(Boolean); + if (!labels.length) return; + setBusy("add"); + const ok = await onAdd(labels); + setBusy(null); + if (ok) setItems(null); + else setError("unknown"); + } + + const filled = (items ?? []).filter((i) => i.trim()).length; + + return ( +
+
+ +

+ {rec.recording ? t("recording", { time: mmss(rec.seconds) }) : busy === "transcribe" ? t("transcribing") : items ? null : t("hint")} +

+
+ + {items ? ( +
+

+ {t("check")} +

+
    + {items.map((item, i) => ( +
  • + setItems((all) => all!.map((x, j) => (j === i ? e.target.value : x)))} + /> + +
  • + ))} +
+ + +
+ ) : null} + {error ? {t(`errors.${error}`)} : null} +
+ ); +} diff --git a/docs/entscheidungen.md b/docs/entscheidungen.md index 539cb09..9ae44db 100644 --- a/docs/entscheidungen.md +++ b/docs/entscheidungen.md @@ -369,3 +369,11 @@ Haushalts, Vorgabe 18:30, eine Stunde. keine Wünsche. - Fehlversuche bremsen je Adresse und gemeinsam; gültige Abrufe zählen nicht, weil Kalender stündlich nachfragen. + +**Nachtrag 26.11.46 · Einkaufsliste einsprechen** (Kai, 8.11.2026): Neben dem +Freitextfeld der Einkaufsliste steht ein Mikrofon, sobald ein Sprachmodell +eingerichtet ist (dasselbe wie bei „Gericht einsprechen“). Die Abschrift zerlegt +`lib/spoken-list.ts` ohne Sprachmodell in Posten (Komma, „und“, Satzende; +Füllwörter wie „wir brauchen noch“, „bitte“ fallen weg). Die Person prüft und +ändert die Posten, erst dann kommen sie unter „Sonstiges“ auf die Liste. Die +Aufnahme wird nicht gespeichert. diff --git a/e2e/einkauf.spec.ts b/e2e/einkauf.spec.ts index 79b0bdf..cd390dd 100644 --- a/e2e/einkauf.spec.ts +++ b/e2e/einkauf.spec.ts @@ -108,6 +108,10 @@ test.describe("receipts", () => { req.on("data", (c) => (raw += c)); req.on("end", () => { if (req.headers.authorization !== "Bearer sk-test") return res.writeHead(401).end(); + // Einkaufsliste einsprechen (26.11.46): feste Abschrift. + if (req.url === "/v1/audio/transcriptions") { + return res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify({ text: "Wir brauchen noch Hafermilch, zwei Gurken und Spülmittel, bitte." })); + } if (raw.includes("supermarket receipt photo")) { return res.writeHead(200, { "content-type": "application/json" }).end( reply({ @@ -174,6 +178,26 @@ test.describe("receipts", () => { await page.getByRole("link", { name: /Spaghetti Bolognese/ }).click(); await expect(page.locator("section", { hasText: "Kosten" }).last().locator("li", { hasText: "Spaghetti" }).first()).toContainText("3,58 € je kg · vom Bon"); }); + + test("the list can be dictated: items are split, checked, then added", async ({ page }) => { + await page.goto("/einkauf"); + await page.getByRole("button", { name: "Einkaufsliste einsprechen" }).click(); + await expect(page.getByText(/Aufnahme läuft/)).toBeVisible(); + await page.waitForTimeout(1200); + await page.getByRole("button", { name: "Aufnahme beenden" }).click(); + const check = page.getByRole("region", { name: "Erkannt — bitte prüfen" }); + await expect(check.getByRole("textbox")).toHaveCount(3); + await expect(check.getByLabel("Posten 1")).toHaveValue("Hafermilch"); + await expect(check.getByLabel("Posten 2")).toHaveValue("Zwei Gurken"); + await check.getByRole("button", { name: "Spülmittel weglassen" }).click(); + await check.getByLabel("Posten 2").fill("2 Gurken"); + await check.getByRole("button", { name: "2 Posten hinzufügen" }).click(); + await expect(check).toHaveCount(0); + const other = page.getByRole("region", { name: "Sonstiges" }); + await expect(other).toContainText("Hafermilch"); + await expect(other).toContainText("2 Gurken"); + await expect(page.getByText("Spülmittel")).toHaveCount(0); + }); }); /** Nach links wischen wie am Handy (Chromium hat keine Wischgeste). */ diff --git a/lib/spoken-list.ts b/lib/spoken-list.ts new file mode 100644 index 0000000..e5557e1 --- /dev/null +++ b/lib/spoken-list.ts @@ -0,0 +1,28 @@ +// Einkaufsliste einsprechen (26.11.46): Abschrift → Posten, ohne Sprachmodell. +// „Milch, zwei Packungen Eier und Brot, bitte“ → Milch · zwei Packungen Eier · Brot. +// Was falsch getrennt ist („Salz und Pfeffer“), korrigiert die Person vor dem Hinzufügen. + +const SEPARATORS = /[,;\n]+|\.\s+|\s+(?:und dann|und|sowie|außerdem|dann|and then|and|then|et|y)\s+/giu; + +// Füllwörter am Anfang oder Ende eines Postens. +const LEADING = + /^(?:(?:ich|wir)\s+(?:brauche|brauchen|hätte gern|hätten gern|möchte|möchten)|brauchen wir|bitte|noch|auch|außerdem|schreib(?:e)?(?:\s+auf)?|setz(?:e)?|kauf(?:e|en)?|wir haben kein(?:e|en)?|es fehlt|es fehlen|(?:we|i)\s+need|please|also|add|buy|get)\s+/iu; +const TRAILING = /\s+(?:bitte|noch|kaufen|einkaufen|auf die liste|mitbringen|please|too|as well)$/iu; + +export function splitSpoken(text: string): string[] { + const out: string[] = []; + for (const raw of text.split(SEPARATORS)) { + let item = raw.trim().replace(/[.!?…]+$/u, "").trim(); + for (let i = 0; i < 3; i++) { + const before = item; + item = item.replace(LEADING, "").replace(TRAILING, "").trim(); + if (item === before) break; + } + if (!item || /^(?:bitte|danke|das wär'?s|das ist alles|fertig|(?:ich|wir) brauche[n]?|please|thanks|that's it)$/iu.test(item)) continue; + item = item.charAt(0).toLocaleUpperCase("de") + item.slice(1); + if (item.length > 80) item = item.slice(0, 80).trim(); + if (!out.some((o) => o.toLocaleLowerCase("de") === item.toLocaleLowerCase("de"))) out.push(item); + if (out.length >= 20) break; + } + return out; +} diff --git a/lib/use-recorder.ts b/lib/use-recorder.ts new file mode 100644 index 0000000..d784519 --- /dev/null +++ b/lib/use-recorder.ts @@ -0,0 +1,48 @@ +"use client"; + +import { useEffect, useRef, useState } from "react"; + +// Aufnahme im Browser (MediaRecorder): iPhone liefert audio/mp4, andere webm. +// Nach „stop“ geht die Aufnahme an `onDone`; Mikrofon wird sofort freigegeben. +export function useRecorder(onDone: (audio: Blob) => void) { + const [recording, setRecording] = useState(false); + const [seconds, setSeconds] = useState(0); + const recorder = useRef(null); + const chunks = useRef([]); + const done = useRef(onDone); + done.current = onDone; + + useEffect(() => { + if (!recording) return; + const tick = setInterval(() => setSeconds((s) => s + 1), 1000); + return () => clearInterval(tick); + }, [recording]); + + async function start(): Promise { + try { + const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + const type = ["audio/mp4", "audio/webm;codecs=opus", "audio/webm"].find((x) => MediaRecorder.isTypeSupported?.(x)); + const rec = new MediaRecorder(stream, type ? { mimeType: type } : undefined); + chunks.current = []; + rec.ondataavailable = (e) => e.data.size && chunks.current.push(e.data); + rec.onstop = () => { + stream.getTracks().forEach((track) => track.stop()); + done.current(new Blob(chunks.current, { type: rec.mimeType || "audio/webm" })); + }; + rec.start(1000); + recorder.current = rec; + setSeconds(0); + setRecording(true); + return true; + } catch { + return false; + } + } + + function stop() { + setRecording(false); + recorder.current?.stop(); + } + + return { recording, seconds, start, stop }; +} diff --git a/lib/voice.ts b/lib/voice.ts new file mode 100644 index 0000000..56dbd73 --- /dev/null +++ b/lib/voice.ts @@ -0,0 +1,29 @@ +import "server-only"; +import { getLocale } from "next-intl/server"; +import { AiNotConfigured, AiUnavailable, transcribe } from "@/lib/ai"; +import { aiFor } from "@/lib/ai-settings"; +import { fail } from "@/lib/auth/http"; + +const MAX_BYTES = 25 * 1024 * 1024; // rund zehn Minuten Sprache + +/** + * Aufnahme aus dem Formular (Feld „audio“) → Abschrift über den Router + * („default-stt“) oder das eigene Sprachmodell. Die Aufnahme wird nicht gespeichert. + * Gemeinsam für „Gericht einsprechen“ (26.11.24) und die Einkaufsliste (26.11.46). + */ +export async function transcribeUpload(request: Request, householdId: string): Promise<{ text: string } | Response> { + const form = await request.formData().catch(() => null); + const audio = form?.get("audio"); + if (!(audio instanceof File) || audio.size === 0 || audio.size > MAX_BYTES || !/^(audio|video)\//.test(audio.type)) return fail("audio", 400); + const ai = await aiFor(householdId); + if (!ai?.speechModel) return fail("noSpeech", 409); + try { + const ext = audio.type.includes("mp4") || audio.type.includes("m4a") ? "m4a" : audio.type.includes("ogg") ? "ogg" : audio.type.includes("wav") ? "wav" : "webm"; + const text = await transcribe(ai, audio, `aufnahme.${ext}`, await getLocale()); + if (!text) return fail("empty", 422); + return { text }; + } catch (error) { + if (error instanceof AiUnavailable || error instanceof AiNotConfigured) return fail("aiUnavailable", 503); + throw error; + } +} diff --git a/messages/de.json b/messages/de.json index f637438..1054248 100644 --- a/messages/de.json +++ b/messages/de.json @@ -781,7 +781,27 @@ "add": "Hinzufügen", "remove": "{name} entfernen", "offline": "{n, plural, =0 {Kein Netz. Die Liste bleibt bedienbar.} one {Kein Netz: 1 Haken wird nachgeholt.} other {Kein Netz: # Haken werden nachgeholt.}}", - "packOf": "{count} {word} à {size}" + "packOf": "{count} {word} à {size}", + "voice": { + "record": "Einkaufsliste einsprechen", + "stop": "Aufnahme beenden", + "recording": "Aufnahme läuft · {time}", + "transcribing": "Wird abgeschrieben …", + "hint": "Einsprechen, z. B. „Milch, Eier und Brot“", + "check": "Erkannt — bitte prüfen", + "item": "Posten {n}", + "drop": "{name} weglassen", + "add": "{n, plural, one {# Posten hinzufügen} other {# Posten hinzufügen}}", + "discard": "Verwerfen", + "errors": { + "mic": "Das Mikrofon ist nicht freigegeben. Erlaube es in den Einstellungen des Browsers.", + "noSpeech": "Für Sprache ist noch kein Modell eingerichtet (Mehr › AI).", + "aiUnavailable": "Die Abschrift ist gerade nicht erreichbar. Bitte versuch es gleich noch einmal.", + "empty": "Da war nichts zu verstehen. Bitte noch einmal.", + "audio": "Die Aufnahme ging nicht durch. Bitte noch einmal.", + "unknown": "Das hat nicht geklappt. Bitte versuch es noch einmal." + } + } }, "cooking": { "eyebrow": "Kochen", diff --git a/messages/en.json b/messages/en.json index 06c74d0..b9ef56c 100644 --- a/messages/en.json +++ b/messages/en.json @@ -781,7 +781,27 @@ "add": "Add", "remove": "Remove {name}", "offline": "{n, plural, =0 {No connection. The list keeps working.} one {No connection: 1 tick will be sent later.} other {No connection: # ticks will be sent later.}}", - "packOf": "{count} {word} of {size}" + "packOf": "{count} {word} of {size}", + "voice": { + "record": "Dictate to the shopping list", + "stop": "Stop recording", + "recording": "Recording · {time}", + "transcribing": "Transcribing …", + "hint": "Say it, e.g. “milk, eggs and toilet paper”", + "check": "Recognised — please check", + "item": "Item {n}", + "drop": "Leave out {name}", + "add": "{n, plural, one {Add # item} other {Add # items}}", + "discard": "Discard", + "errors": { + "mic": "The microphone isn’t allowed. Allow it in your browser settings.", + "noSpeech": "No speech model is set up yet (More › AI).", + "aiUnavailable": "Transcription isn’t reachable right now. Please try again shortly.", + "empty": "Nothing could be understood. Please try again.", + "audio": "The recording didn’t come through. Please try again.", + "unknown": "That didn’t work. Please try again." + } + } }, "cooking": { "eyebrow": "Cooking", diff --git a/messages/es.json b/messages/es.json index 31d4208..d089d1a 100644 --- a/messages/es.json +++ b/messages/es.json @@ -781,7 +781,27 @@ "add": "Add", "remove": "Remove {name}", "offline": "{n, plural, =0 {No connection. The list keeps working.} one {No connection: 1 tick will be sent later.} other {No connection: # ticks will be sent later.}}", - "packOf": "{count} {word} de {size}" + "packOf": "{count} {word} de {size}", + "voice": { + "record": "Dictar la lista de la compra", + "stop": "Detener grabación", + "recording": "Grabando · {time}", + "transcribing": "Transcribiendo …", + "hint": "Dilo, p. ej. «leche, huevos y papel higiénico»", + "check": "Reconocido — revísalo", + "item": "Artículo {n}", + "drop": "Quitar {name}", + "add": "{n, plural, one {Añadir # artículo} other {Añadir # artículos}}", + "discard": "Descartar", + "errors": { + "mic": "El micrófono no está permitido. Permítelo en los ajustes del navegador.", + "noSpeech": "Aún no hay modelo de voz (Más › AI).", + "aiUnavailable": "La transcripción no está disponible ahora. Inténtalo en un momento.", + "empty": "No se entendió nada. Inténtalo de nuevo.", + "audio": "La grabación no llegó. Inténtalo de nuevo.", + "unknown": "No ha funcionado. Inténtalo de nuevo." + } + } }, "cooking": { "eyebrow": "Cooking", diff --git a/messages/fr.json b/messages/fr.json index d46e8e1..5378a89 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -781,7 +781,27 @@ "add": "Add", "remove": "Remove {name}", "offline": "{n, plural, =0 {No connection. The list keeps working.} one {No connection: 1 tick will be sent later.} other {No connection: # ticks will be sent later.}}", - "packOf": "{count} {word} de {size}" + "packOf": "{count} {word} de {size}", + "voice": { + "record": "Dicter la liste de courses", + "stop": "Arrêter l’enregistrement", + "recording": "Enregistrement · {time}", + "transcribing": "Transcription …", + "hint": "Dis-le, p. ex. « lait, œufs et papier toilette »", + "check": "Reconnu — vérifie", + "item": "Article {n}", + "drop": "Retirer {name}", + "add": "{n, plural, one {Ajouter # article} other {Ajouter # articles}}", + "discard": "Abandonner", + "errors": { + "mic": "Le micro n’est pas autorisé. Autorise-le dans les réglages du navigateur.", + "noSpeech": "Aucun modèle vocal n’est configuré (Plus › AI).", + "aiUnavailable": "La transcription n’est pas joignable. Réessaie dans un instant.", + "empty": "Rien n’a été compris. Réessaie.", + "audio": "L’enregistrement n’est pas passé. Réessaie.", + "unknown": "Cela n’a pas marché. Réessaie." + } + } }, "cooking": { "eyebrow": "Cooking", diff --git a/olares/Chart.yaml b/olares/Chart.yaml index c6127ff..5f3077d 100644 --- a/olares/Chart.yaml +++ b/olares/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: lunch description: foodplanhero (Plan. Cook. Smile.) — die Familie entscheidet gemeinsam, was es gibt; aus dem Plan entsteht die Einkaufsliste type: application -version: 26.11.45 # YY.M. wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen -appVersion: "26.11.45" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran +version: 26.11.46 # YY.M. wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen +appVersion: "26.11.46" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran diff --git a/olares/OlaresManifest.yaml b/olares/OlaresManifest.yaml index 9baccd1..e379235 100644 --- a/olares/OlaresManifest.yaml +++ b/olares/OlaresManifest.yaml @@ -21,7 +21,7 @@ metadata: title: foodplanhero description: Plan. Cook. Smile. The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box. icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png - version: 26.11.45 + version: 26.11.46 categories: - Applications @@ -61,7 +61,7 @@ permission: appData: true spec: - versionName: '26.11.45' + versionName: '26.11.46' featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png promoteImage: diff --git a/olares/markt/26.11.46.md b/olares/markt/26.11.46.md new file mode 100644 index 0000000..56d1c53 --- /dev/null +++ b/olares/markt/26.11.46.md @@ -0,0 +1,5 @@ +# Dictate the shopping list +v26.11.46: The shopping list has a microphone next to the free-text field. Say what is missing, for example "milk, two cucumbers and washing-up liquid": the app splits it into items, you check and change them, then they go on the list. It uses the same speech model as dictating a dish; the recording is not stored. + +## Deutsch +v26.11.46: Die Einkaufsliste hat neben dem Freitextfeld ein Mikrofon. Sag, was fehlt, etwa „Milch, zwei Gurken und Spülmittel“: Die App teilt es in Posten auf, du prüfst und änderst sie, dann kommen sie auf die Liste. Es nutzt dasselbe Sprachmodell wie „Gericht einsprechen“; die Aufnahme wird nicht gespeichert. diff --git a/tests/spoken-list.test.ts b/tests/spoken-list.test.ts new file mode 100644 index 0000000..94679e7 --- /dev/null +++ b/tests/spoken-list.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from "vitest"; +import { splitSpoken } from "@/lib/spoken-list"; + +describe("spoken shopping list", () => { + it("splits on commas and 'und' and drops fillers", () => { + expect(splitSpoken("Wir brauchen noch Milch, zwei Packungen Eier und Brot, bitte.")).toEqual(["Milch", "Zwei Packungen Eier", "Brot"]); + }); + it("handles sentences and 'außerdem'", () => { + expect(splitSpoken("Klopapier. Außerdem Spülmittel und dann Bananen kaufen. Das wär's.")).toEqual(["Klopapier", "Spülmittel", "Bananen"]); + }); + it("keeps what was said, once", () => { + expect(splitSpoken("Butter, butter und 500 Gramm Hack")).toEqual(["Butter", "500 Gramm Hack"]); + }); + it("works in English", () => { + expect(splitSpoken("We need apples, oat milk and then coffee please")).toEqual(["Apples", "Oat milk", "Coffee"]); + }); + it("gives nothing for nothing", () => { + expect(splitSpoken("Danke.")).toEqual([]); + }); +});