Turn a Galaxy Watch into a wearable AI note taker. Local transcription with speaker labels, summaries from the AI you already pay for.
Python
Enter the Hugging Face token and calendar link in the dashboard
Alex2df3e70f55a5
diff --git a/.env.example b/.env.exampleindex e009398..2c3d732 100644--- a/.env.example+++ b/.env.example@@ -6,6 +6,7 @@ INGEST_TOKEN=# Hugging Face read token, for speaker labels (free). Accept the model terms first:# https://huggingface.co/pyannote/speaker-diarization-community-1# Without it everything still works, but every line is labeled as one speaker.+# Easiest: paste it in the dashboard under Settings > Voices > Speaker labels, which writes this line.HF_TOKEN=# --- Network ---------------------------------------------------------------@@ -24,6 +25,7 @@ CF_ACCESS_CLIENT_SECRET=# --- Optional --------------------------------------------------------------# Private iCal link of your calendar, for "record my meetings" in auto mode.+# The dashboard writes this for you (Settings > Auto mode > When to listen).CALENDAR_ICS_URL=# API key for the "API key or local model" summary provider. The dashboard writes this for you.SUMMARY_API_KEY=diff --git a/AGENTS.md b/AGENTS.mdindex a047108..8ad28c5 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -20,8 +20,8 @@ When the user says "set this up" (or similar), run the setup below. Work through3. **Settings file.** Copy `.env.example` to `.env` if there isn't one, then `python launch.py token`.4. **Ask the user** (one question, not one at a time):- Which AI should write the summaries: Claude subscription, ChatGPT subscription, an API key, or a free local model?- - Do they have a Hugging Face read token for speaker labels? If not, give them the two links from SETUP.md step 3 and wait. They can skip it and add it later.- Have the user paste secrets into `.env` themselves, or write them there for the user without echoing them back.+ - Do they have a Hugging Face read token for speaker labels? If not, give them the link in SETUP.md step 4 and wait. They can skip it and add it later.+ Secrets go in through the dashboard once it is running (step 6), so the user never has to edit `.env` and never has to paste a key into this chat.5. **Start it.** `python launch.py start`. Verify: `python launch.py status` shows the worker alive.6. **Set the provider.** Either walk the user through Settings > Summaries in the dashboard, or set it over the local API:`PUT http://127.0.0.1:8808/api/settings` with `{"summary": {"provider": "...", "model": "...", "base_url": "...", "api_key": "..."}}`.@@ -29,6 +29,7 @@ When the user says "set this up" (or similar), run the setup below. Work through- Claude: `claude auth status` must show logged in. If not, the user runs `claude login`.- Codex: `codex --version` must work. If not, `npm i -g @openai/codex`, then the user runs `codex login`.- Local: follow "Using a free local model" in SETUP.md. Check that Ollama (`http://localhost:11434/v1/models`) or LM Studio (`http://localhost:1234/v1/models`) answers and use a model name from that list. Suggest a small model (7B to 12B). Ask before downloading one, since it is several GB.+ - **Keys.** Point the user at the dashboard fields and let them paste: Hugging Face token under Settings > Voices > Speaker labels, API key under Settings > Summaries, calendar link under Settings > Auto mode. Each saves to `.env`. If the user would rather hand you a key, send it with the same endpoint, `{"secrets": {"hf_token": "..."}}` or `{"secrets": {"calendar_url": "..."}}`, and don't echo it back. `GET /api/settings` reports `secrets.hf_token_set` and `secrets.calendar_url_set`, never the values.- With a local model, ask whether they game, edit or render on this PC. If yes, suggest `"when": "daily"` with a `daily_time`, and `{"system": {"pause_when_busy": true}}` (same settings endpoint).7. **Prove the PC side.** Upload a short speech clip: `POST /api/upload` with a `file` form field. Poll `GET /api/conversations/<recording_id>` until `status` is `done`. The first run downloads models and can take several minutes. Show the user the title and summary.8. **Pair the watch.** This needs the user's hands. Give them SETUP.md step 5, one instruction at a time, and run the `adb pair` and `adb connect` commands for them with the numbers they read out. Verify with `adb devices`.diff --git a/README.md b/README.mdindex 1da27f9..35ec4ee 100644--- a/README.md+++ b/README.md@@ -44,6 +44,8 @@ Already cloned it? Open the folder and say "Set this up for me."The agent reads [AGENTS.md](AGENTS.md), installs everything, checks each step, and stops to ask you for the few things only you can do (pairing the watch, the Hugging Face token).+Your keys go in through the dashboard, not a text file. Settings has a box for the Hugging Face token (Voices), the AI provider API key (Summaries) and the optional calendar link (Auto mode). Each one is saved to a local `.env` file on your PC and is never shown again.+To do it by hand, follow [SETUP.md](SETUP.md). Plan on about an hour, most of it downloads.## How it worksdiff --git a/SETUP.md b/SETUP.mdindex 0379ad9..657d905 100644--- a/SETUP.md+++ b/SETUP.md@@ -40,8 +40,15 @@ python launch.py tokenThe second command creates the upload token the watch will use and saves it in `.env`.-**Speaker labels (recommended).** Make a free account at huggingface.co, open-https://huggingface.co/pyannote/speaker-diarization-community-1 and accept the terms, then create a read token under Settings > Access Tokens. Put it in `.env` as `HF_TOKEN=`. Without it every line is labeled as one speaker.+You don't have to edit `.env` by hand after this. The keys you add yourself are all entered in the dashboard, which saves them to `.env` for you:++| What | Where in the dashboard |+|---|---|+| Hugging Face token (speaker labels) | Settings > Voices > Speaker labels |+| AI provider API key | Settings > Summaries > AI provider |+| Calendar link (optional) | Settings > Auto mode > When to listen |++A saved key is never shown again. The box just says "saved", and you can replace or remove it.## 4. Start it and pick your AI@@ -49,7 +56,11 @@ https://huggingface.co/pyannote/speaker-diarization-community-1 and accept the tpython launch.py start```-Open http://127.0.0.1:8808 and go to **Settings > Summaries**. Pick a provider and press **Save and test**.+Open http://127.0.0.1:8808 and go to **Settings**.++**Speaker labels (recommended).** Under **Voices > Speaker labels**, follow the three steps shown there: make a free account at huggingface.co, accept the terms on https://huggingface.co/pyannote/speaker-diarization-community-1, create a read token, paste it in and press **Save token**. Without it every line is labeled as one speaker.++**Summaries.** Under **Summaries**, pick a provider and press **Save and test**.| Provider | What to do first ||---|---|@@ -166,7 +177,9 @@ When you're finished, turn Wireless debugging off on the watch. The recorder doe## Optional: record calendar meetings-Put your calendar's private iCal link in `.env` as `CALENDAR_ICS_URL=`, restart, and tick **Record calendar meetings** in Settings. In Google Calendar the link is under Settings > your calendar > "Secret address in iCal format". Auto mode then also opens for meetings that have attendees or a video-call link.+In the dashboard, go to **Settings > Auto mode > When to listen**. Paste your calendar's private iCal link into **Calendar link** and press **Save link**, then tick **Record calendar meetings** and press **Save changes**. In Google Calendar the link is under Settings > your calendar > "Secret address in iCal format". Auto mode then also opens for meetings that have attendees or a video-call link.++The link is read-only and there is no sign-in to your calendar account. Treat it like a password anyway: anyone who has it can read your calendar. It is stored only in the `.env` file on your PC.## Optional: upload from anywhere (tunnel mode)@@ -186,7 +199,7 @@ Wi-Fi mode only uploads at home. To upload from anywhere, put the PC behind a tu| Watch says "rejected: check tokens" | The token in `.env` changed. Run `python tools/setup_watch.py --config-only`. || `adb devices` shows nothing or "offline" | `adb disconnect`, then `adb connect` again with the address on the Wireless debugging screen. The port changes each time debugging is switched on. || "More than one device" | The watch can show up twice. Pass `--serial <address:port>` to the setup script. |-| Every line is "Speaker A" | No `HF_TOKEN` in `.env`, or the model terms weren't accepted. |+| Every line is "Speaker A" | No Hugging Face token saved (Settings > Voices > Speaker labels), or the model terms weren't accepted. || Summaries never appear | Settings > Summaries > Save and test shows the exact error. Also check "When to summarize": on the daily or manual setting they wait on purpose. || Recordings sit at "queued" | "Wait while the PC is busy" is on and something is loading the GPU or CPU. Pipeline status shows the reason. || Dashboard says "wrong Python" | Start it with `python launch.py start`, which uses the `.venv` in this folder. |diff --git a/server.py b/server.pyindex 4d73261..e537edc 100644--- a/server.py+++ b/server.py@@ -482,6 +482,7 @@ async def enroll(file: UploadFile = File(...), name: str = Form("Me"), is_self:def _settings_out(s: dict) -> dict:"""Settings for the dashboard. The API key itself never leaves the PC, only whether one is saved."""s["summary"]["api_key_set"] = bool(config.summary_api_key())+ s["secrets"] = {"hf_token_set": bool(config.hf_token()), "calendar_url_set": bool(config.calendar_ics_url())}return s@@ -566,9 +567,32 @@ async def put_settings(request: Request):if summ.get("clear_api_key"):config.set_env_value("SUMMARY_API_KEY", "")changed = True+ # Secrets typed into Settings are written to .env. "" keeps what is saved; clear_* removes it.+ sec = body.get("secrets") or {}+ hf = str(sec.get("hf_token") or "").strip()+ if hf:+ if len(hf) > 300 or " " in hf:+ raise HTTPException(422, "that doesn't look like a Hugging Face token")+ config.set_env_value("HF_TOKEN", hf)+ changed = True+ if sec.get("clear_hf_token"):+ config.set_env_value("HF_TOKEN", "")+ if config.hf_token(): # an older HUGGINGFACE_TOKEN line is still set+ config.set_env_value("HUGGINGFACE_TOKEN", "")+ changed = True+ cal_url = str(sec.get("calendar_url") or "").strip()+ if cal_url:+ if len(cal_url) > 2000 or not re.match(r"^(https?|webcal)://\S+$", cal_url):+ raise HTTPException(422, "the calendar link must start with https:// or webcal://")+ config.set_env_value("CALENDAR_ICS_URL", cal_url)+ changed = True+ if sec.get("clear_calendar_url"):+ config.set_env_value("CALENDAR_ICS_URL", "")+ changed = True+ s.pop("secrets", None)db.set_kv(c, "settings", s)if changed:- db.set_kv(c, "summary_changed_at", db.now_iso()) # the worker retries paused summaries+ db.set_kv(c, "summary_changed_at", db.now_iso()) # the worker re-reads .env and retries paused summariesreturn _settings_out(s)finally:c.close()diff --git a/static/app.js b/static/app.jsindex d5c19ff..00584d4 100644--- a/static/app.js+++ b/static/app.js@@ -820,6 +820,9 @@ function normalizeSettings(s) {s.summary.daily_time = s.summary.daily_time || '23:00';s.system = s.system || {};s.system.pause_when_busy = !!s.system.pause_when_busy;+ s.secrets = s.secrets || {};+ s.secrets.hf_token_set = !!s.secrets.hf_token_set;+ s.secrets.calendar_url_set = !!s.secrets.calendar_url_set;return s;}@@ -836,7 +839,7 @@ function healthBlockHtml(h) {['Calendar', h.calendar ? 'Connected' : 'Not set up'],];let html = '<dl class="kv">' + rows.map(r => '<dt>' + esc(r[0]) + '</dt><dd>' + r[1] + '</dd>').join('') + '</dl>';- if (!h.hf_token) html += '<div class="notice" style="margin-top:10px;margin-bottom:0">Speaker labels are off until a Hugging Face token is added.</div>';+ if (!h.hf_token) html += '<div class="notice" style="margin-top:10px;margin-bottom:0">Speaker labels are off until a Hugging Face token is added under Voices, above.</div>';if (h.problems && h.problems.length) html += '<div style="margin-top:10px"><b>Problems</b>' + listHtml(h.problems) + '</div>';return html;}@@ -911,6 +914,28 @@ function whenFieldsHtml(st) {'<div class="card-meta" id="sm-run-status"></div>';}+const HF_MODEL_URL = 'https://huggingface.co/pyannote/speaker-diarization-community-1';+const HF_TOKENS_URL = 'https://huggingface.co/settings/tokens';++function hfFieldsHtml(st) {+ const set = st.secrets.hf_token_set;+ return '<ol class="steps"><li>Make a free account at huggingface.co.</li>' ++ '<li>Open <a href="' + HF_MODEL_URL + '" target="_blank" rel="noopener">the speaker model page</a> and accept its terms.</li>' ++ '<li>Create a read token on <a href="' + HF_TOKENS_URL + '" target="_blank" rel="noopener">your tokens page</a> and paste it here.</li></ol>' ++ '<div class="field-row"><label for="sc-hf">Token</label><input type="password" id="sc-hf" class="wide" value="" autocomplete="off" spellcheck="false" placeholder="' + (set ? 'saved (type to replace)' : 'hf_...') + '"></div>' ++ '<div class="btn-row" style="margin-top:6px"><button class="btn" type="button" id="sc-hf-save">Save token</button>' ++ (set ? '<button class="btn" type="button" id="sc-hf-clear">Remove</button>' : '') + '</div>' ++ '<div class="card-meta" id="sc-hf-status">' + (set ? 'A token is saved. Speaker labels are on for new recordings.' : 'No token yet. Every line is labeled as one speaker.') + '</div>';+}++function calFieldsHtml(st) {+ const set = st.secrets.calendar_url_set;+ return '<div class="field-row indent"><label for="sc-cal">Calendar link</label><input type="password" id="sc-cal" class="wide" value="" autocomplete="off" spellcheck="false" placeholder="' + (set ? 'saved (paste to replace)' : 'private iCal link, https://...') + '"></div>' ++ '<div class="btn-row indent" style="margin-top:6px"><button class="btn" type="button" id="sc-cal-save">Save link</button>' ++ (set ? '<button class="btn" type="button" id="sc-cal-clear">Remove</button>' : '') + '</div>' ++ '<div class="card-meta indent" id="sc-cal-status">' + (set ? 'A calendar link is saved.' : 'In Google Calendar: Settings, your calendar, "Secret address in iCal format". The link is read-only and stays on this PC.') + '</div>';+}+function summaryFieldsHtml(st) {const sm = st.summary;const compat = sm.provider === 'openai_compatible';@@ -956,10 +981,11 @@ async function renderSettings(token) {'<div class="settings">' +'<div class="s-group">Auto mode</div>' +- sRow('When to listen', 'Auto mode listens whenever the watch is on your wrist, unless you set weekly windows below. Calendar meetings also count once a calendar link is added (see SETUP.md).',+ sRow('When to listen', 'Auto mode listens whenever the watch is on your wrist, unless you set weekly windows below. Calendar meetings also count once you paste a calendar link here.','<label class="row-check"><input type="checkbox" id="st-always"' + (st.auto.always_while_worn ? ' checked' : '') + '> Listen whenever I\'m wearing it, even outside my windows</label>' +'<label class="row-check"><input type="checkbox" id="st-cal"' + (st.auto.calendar.enabled ? ' checked' : '') + '> Record calendar meetings</label>' +- '<div class="field-row indent"><label for="st-lead">Start</label><input type="number" id="st-lead" min="0" max="120" value="' + esc(st.auto.calendar.lead_min) + '"><label for="st-lead">minutes before the meeting</label></div>') ++ '<div class="field-row indent"><label for="st-lead">Start</label><input type="number" id="st-lead" min="0" max="120" value="' + esc(st.auto.calendar.lead_min) + '"><label for="st-lead">minutes before the meeting</label></div>' ++ '<div id="sc-cal-fields">' + calFieldsHtml(st) + '</div>') +sRow('Weekly time windows', 'Optional. Leave every day empty to listen all day. Add windows to limit auto mode to those hours.','<div class="btn-row" style="margin:0 0 6px"><button type="button" class="btn small" id="st-copy-mon">Copy Monday to weekdays</button></div>' +'<div id="st-windows">' + windowsHtml(st) + '</div>') +@@ -971,6 +997,8 @@ async function renderSettings(token) {'<label class="row-check"><input type="checkbox" id="st-batt"' + (st.upload.battery_saver ? ' checked' : '') + '> Battery saver: upload only on Wi-Fi or while charging</label>') +'<div class="s-group">Voices</div>' ++ sRow('Speaker labels', 'Telling speakers apart uses a free model from Hugging Face, which needs a token. It is saved in the .env file on this PC and never shown again.',+ '<div id="sc-hf-fields">' + hfFieldsHtml(st) + '</div>') +sRow('Enroll a voice', 'Read the paragraph out loud for about 30 seconds, or upload a clip. New recordings then label that person by name.','<div class="field-row"><label for="en-name">Name</label><input type="text" id="en-name" value="" placeholder="Your name" style="max-width:240px"></div>' +'<label class="row-check"><input type="checkbox" id="en-self" checked> This is me</label>' +@@ -1034,6 +1062,7 @@ async function renderSettings(token) {const out = JSON.parse(JSON.stringify(st));DAYS.forEach(([k]) => { out.auto.windows[k] = out.auto.windows[k].filter(w => w[0] && w[1]); });delete out.summary.api_key_set;+ delete out.secrets;const key = $('#sm-key') ? $('#sm-key').value.trim() : '';if (key) out.summary.api_key = key;const res = await api('api/settings', { method: 'PUT', json: out });@@ -1061,6 +1090,34 @@ async function renderSettings(token) {});$('#st-busy').addEventListener('change', e => { st.system.pause_when_busy = e.target.checked; });+ /* ---- secrets (written to .env on the PC) ---- */+ const secretBox = (hostId, render, inputId, field, clearField, savedMsg, clearedMsg) => {+ const host = $(hostId);+ const send = async (secrets, msg) => {+ const res = await api('api/settings', { method: 'PUT', json: { secrets } });+ if (token !== state.nav) return;+ if (res && res.secrets) st.secrets = normalizeSettings(res).secrets;+ host.innerHTML = render(st);+ host.querySelector('.card-meta').textContent = msg;+ refreshHealth().then(h => { if (token === state.nav && $('#health-block')) $('#health-block').innerHTML = healthBlockHtml(h); });+ };+ host.addEventListener('click', async e => {+ try {+ if (e.target.closest(inputId + '-save')) {+ const v = $(inputId).value.trim();+ if (!v) { host.querySelector('.card-meta').textContent = 'Paste it in the box first.'; return; }+ await send({ [field]: v }, savedMsg);+ } else if (e.target.closest(inputId + '-clear')) {+ await send({ [clearField]: true }, clearedMsg);+ }+ } catch (err) { fail(err); }+ });+ };+ secretBox('#sc-hf-fields', hfFieldsHtml, '#sc-hf', 'hf_token', 'clear_hf_token',+ 'Saved. Speaker labels are on for new recordings.', 'Removed. Speaker labels are off.');+ secretBox('#sc-cal-fields', calFieldsHtml, '#sc-cal', 'calendar_url', 'clear_calendar_url',+ 'Saved. Tick "Record calendar meetings" above and press Save changes to use it.', 'Removed.');+smHost.addEventListener('click', async e => {if (!e.target.closest('#sm-test')) return;try {diff --git a/static/index.html b/static/index.htmlindex 87af16d..6aacdda 100644--- a/static/index.html+++ b/static/index.html@@ -9,7 +9,7 @@<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">- <link rel="stylesheet" href="style.css?v=3">+ <link rel="stylesheet" href="style.css?v=4"></head><body><div class="shell">@@ -65,6 +65,6 @@<div id="toast" class="toast" role="status" aria-live="polite" hidden></div>- <script src="app.js?v=2"></script>+ <script src="app.js?v=3"></script></body></html>diff --git a/static/style.css b/static/style.cssindex 5f95c6e..e883182 100644--- a/static/style.css+++ b/static/style.css@@ -454,3 +454,8 @@ a.hit:hover { background: var(--panel-2); }.field-row label[for^="sm-"] { flex: 0 0 76px; }.field-row input.wide { flex: 1 1 260px; min-width: 0; max-width: 460px; width: auto; }.field-row input[type="time"] { width: auto; }++/* setup steps inside a settings card */+ol.steps { margin: 0 0 8px; padding-left: 20px; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }+.btn-row.indent, .card-meta.indent { padding-left: 26px; }+.field-row label[for^="sc-"] { flex: 0 0 96px; }