From 8711f2113f10b3b8f70c28ceb7e0c9a0114206b6 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 23:43:39 +0000 Subject: [PATCH] A phone never loads the voice model or asks for the graphics card On a phone or a tablet a voiceover is said by the device's own voice, the GPU voice is not offered and the voice dialog lists only This device. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01MCuMSgEmxT6hSLKhKZ1K1F --- AGENTS.md | 6 ++++++ site/account.css | 3 +++ site/account.js | 19 +++++++++++-------- site/voice.js | 18 +++++++++++++----- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 480918af..7fc49914 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -452,6 +452,12 @@ How the page is put together: Delete; rewriting it or choosing another voice makes the reader's own copy. It downloads no model until play is pressed. `scripts/voices.mjs` writes these files with the function's own instructions (needs `OPENROUTER_API_KEY`); the first, Dinosaurs, was written by hand as a sample. +- **A phone never loads the voice model (Nov 2026, asked for, after the page crashed on a phone: "avoid those + heavy gpu usage and voiceover downloads for phone").** On a phone or a tablet (`light()` in `site/voice.js`: a + narrow screen, or one worked by touch alone) a voiceover is said by the device's own voice, whichever voice the + timeline names: the speaker makes no line and `warm()` does nothing, `gpuOk()` answers no without asking for + the graphics card, the GPU voice is not offered, the voice dialog lists only This device with a line that says + so, and an export there has no voiceover. The voice kept on the timeline is not changed by this. - **Stopping an export is asked once more (Nov 2026, asked for).** In the export dialog Stop turns the foot into "Stop the export?" with "Yes, stop" and "Keep exporting"; from the note under the pill it is a small dialog. The export goes on until the reader answers. diff --git a/site/account.css b/site/account.css index 2fb49d00..82c5fb3b 100644 --- a/site/account.css +++ b/site/account.css @@ -616,6 +616,9 @@ body.globe:has(.g-shelf:not([hidden])) #ai-live.low { bottom: 238px; } .vo-gpu b { display: block; font-size: 13.5px; font-weight: 600; } .vo-gpu small { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.45; color: var(--muted); } .vo-slow[hidden] { display: none; } +.vo-lite[hidden] { display: none; } +.vo-lite { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted, var(--text)); } +.vo-voices.cards:empty { display: none; } .vo-slow { margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.45; color: var(--text); background: color-mix(in srgb, #e8a33c 16%, transparent); } .vo-load { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--raised); font-size: 12.5px; color: var(--muted); } .vo-load b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); } diff --git a/site/account.js b/site/account.js index 82c967b6..5a3c80de 100644 --- a/site/account.js +++ b/site/account.js @@ -10,7 +10,7 @@ import { EFFORTS, MAX_ENTRIES, MODELS, findPictures, partialSpec, specToView, vi import { createEditor } from './editor.js'; // Public by design: the key only allows what the database's row level security allows. -import { VOICES, DEFAULT_VOICE, isVoice, voiceLabel, voiceOf, isSlow, gpuOk, GPU_MB, MODEL_MB, listen as hear } from './voice.js'; +import { VOICES, DEFAULT_VOICE, isVoice, voiceLabel, voiceOf, isSlow, gpuOk, GPU_MB, MODEL_MB, light, listen as hear } from './voice.js'; export const CONFIG = { url: 'https://wwgmelafchslapxiccot.supabase.co', key: 'sb_publishable_IykysSfgNLw4CfaqxP2CqA_YNcfq0SW', @@ -607,7 +607,7 @@ export function createAccount(app) { // line is spoken once now, in this browser, and kept there, so play never waits. The device's own voice has // nothing to make. A line that cannot be made is left for play, which makes it again or uses the device. async function record(voice, lines) { - if (voice === 'device' || !lines?.length) return; + if (voice === 'device' || light() || !lines?.length) return; voicing.step = 2; voicing.total = lines.length; voicing.made = 0; const tick = setInterval(() => { if (voicing) { noteOf(); draw(); } }, 400); try { @@ -737,7 +737,7 @@ export function createAccount(app) { // fetches its own small file first (asked for, Nov 2026: "it's not showing that loading"). b.classList.add('wait'); b.innerHTML = 'Loading…'; const note = b.closest('.dlg, form')?.querySelector('.vo-fetch'); - if (note && b.dataset.sample !== 'device') { note.textContent = `Getting ${voiceLabel(b.dataset.sample)} ready…`; note.hidden = false; } + if (note && b.dataset.sample !== 'device' && !light()) { note.textContent = `Getting ${voiceLabel(b.dataset.sample)} ready…`; note.hidden = false; } const quiet = () => { if (note) note.hidden = true; }; me.stop = hear(app.speaker(), b.dataset.sample, app.audio, () => { if (sample === me) hush(); }, (e) => { quiet(); if (sample === me) { hush(); fail(e.message === 'no voice' ? 'The voice could not be loaded on this device. Play will use the device’s own voice instead.' : 'The voice could not be played. Try again.'); } }, text || undefined, () => { quiet(); if (sample === me) { b.classList.replace('wait', 'on'); b.innerHTML = HALT + 'Stop'; } }); @@ -773,13 +773,16 @@ export function createAccount(app) { function voiceMenu(anchor, row) { if (voicing) return; const base = !!row.get()?.base; // the default that came with a built timeline: rewritten as the reader's own, never deleted - const has = voiceOf(row.get()), was = has?.voice || (() => { try { const v = localStorage.getItem('cg-voice-name'); return isVoice(v) ? v : null; } catch (e) { return null; } })() || DEFAULT_VOICE; + const has = voiceOf(row.get()); let was = has?.voice || (() => { try { const v = localStorage.getItem('cg-voice-name'); return isVoice(v) ? v : null; } catch (e) { return null; } })() || DEFAULT_VOICE; // Two dialogs (designs A and B, picked from three each, Nov 2026). With no voiceover yet: the voices as // cards, each with Listen, and one button that names the voice. With one: the voices at the left and the // script as it is told at the right, "this is your script", to write again or to try in another voice. - const kok = VOICES.filter(([v]) => v !== 'device'), dev = VOICES.find(([v]) => v === 'device'); + // On a phone only the phone's own voice is offered, and nothing is downloaded (asked for, Nov 2026). + const lite = light(), dev = VOICES.find(([v]) => v === 'device'), kok = lite ? [] : VOICES.filter(([v]) => v !== 'device'), all = lite ? [dev] : VOICES; + if (lite) was = 'device'; const voiceEl = ([v, name, w], cls = '') => ``; const notes = ` +

On a phone the voiceover is said by the phone’s own voice, so nothing is downloaded. The other voices are on a computer.

@@ -789,7 +792,7 @@ export function createAccount(app) { const lineEl = (l) => { const e = byId.get(l.id), edge = l.id === 'intro' ? 'Opening' : l.id === 'outro' ? 'Closing' : ''; return `${esc(edge || e?.when || '')}
${e ? `${esc(e.name)}` : ''}

${esc(l.text)}

`; }; const d = modal(has ? `

Voiceover

Voice
-
${VOICES.map((v) => voiceEl(v, 'row')).join('')}
${notes}
+
${all.map((v) => voiceEl(v, 'row')).join('')}
${notes}
Script${row.own ? '' : base ? ', the default for this timeline' : ', kept in this browser'}${esc(row.title || 'This timeline')}${base ? '' : ''}
${span.html}
Uses one of today’s requests.
    ${has.lines.map(lineEl).join('')}
@@ -809,7 +812,7 @@ export function createAccount(app) { const drawSlow = () => { slow.hidden = !isSlow(); }; // "This device" downloads nothing: the model is fetched only once a Kokoro voice is picked. let gpuFine = false; - const kokoro = () => pick() !== 'device'; + const kokoro = () => !lite && pick() !== 'device'; // The GPU voice (asked for, Nov 2026): shown with its size where the device can run it, downloaded only // when Download is pressed, and switched off and on afterwards. const drawGpu = () => { @@ -857,7 +860,7 @@ export function createAccount(app) { // the choices on the right; one button. Nothing here asks the server for anything. function videoMenu() { if (voicing) return; - const can = app.canExport(), cur = holder(), has = !!cur && voiceOf(cur.get()), dev = has && has.voice === 'device', told = !!has && !dev; + const can = app.canExport(), cur = holder(), has = !!cur && voiceOf(cur.get()), dev = has && (has.voice === 'device' || light()), told = !!has && !dev; const first = app.first() || {}, ents = app.told()?.entries || [], all0 = ents.length; // It always opens on the same choices (asked for, Nov 2026): Landscape, Default, the voiceover on where there is one, 1080p. const st = { voice: told, subs: false, shape: 'wide', scene: 'globe', short: 1080, from: 0, to: Math.max(0, all0 - 1) }; diff --git a/site/voice.js b/site/voice.js index dd9ff9f2..9c526b57 100644 --- a/site/voice.js +++ b/site/voice.js @@ -42,12 +42,19 @@ export function speedOf(gpu = gpuOn()) { try { const v = Number(localStorage.get // download, only when the user clicks download"). If it fails to load, the voice goes back to the processor. export const GPU_MB = 326; const GPU = 'cg-voice-gpu'; -export function gpuOn() { try { return localStorage.getItem(GPU) === '1'; } catch (e) { return false; } } +// A phone or a tablet never loads the model (asked for, Nov 2026, after the page crashed on a phone: "avoid +// those heavy gpu usage and voiceover downloads for phone"): there a voiceover is said by the device's own +// voice, whichever voice the timeline names, the graphics card is never asked for and the GPU voice is not +// offered. `light()` is a narrow screen, or one worked by touch alone. +export function light() { + try { return typeof matchMedia === 'function' && (matchMedia('(max-width: 699px)').matches || matchMedia('(hover: none) and (pointer: coarse)').matches); } catch (e) { return false; } +} +export function gpuOn() { try { return !light() && localStorage.getItem(GPU) === '1'; } catch (e) { return false; } } let gpuAsk = null; export function gpuOk() { return (gpuAsk ??= (async () => { try { - if (typeof navigator === 'undefined' || !navigator.gpu) return false; + if (typeof navigator === 'undefined' || !navigator.gpu || light()) return false; const a = await navigator.gpu.requestAdapter({ powerPreference: 'high-performance' }); return !!a && !(a.isFallbackAdapter || a.info?.isFallbackAdapter); } catch (e) { return false; } @@ -168,6 +175,7 @@ export function createSpeaker(status = () => {}) { let n = 0; // The sound of one line, as { audio: Float32Array, rate }. Asked for again, it is the same promise. function line(text, voice, now = false) { + if (light()) return Promise.reject(new Error('On a phone the voice is the phone’s own.')); const key = lineKey(voice, text); if (made.has(key)) { if (now) { const j = queue.find((x) => x.key === key); if (j && queue.indexOf(j) > (busy ? 1 : 0)) { queue.splice(queue.indexOf(j), 1); queue.splice(busy ? 1 : 0, 0, j); } } @@ -197,7 +205,7 @@ export function createSpeaker(status = () => {}) { } // Have the model ready before anything is said: when a timeline with a voiceover is opened. let warmed = false; - function warm() { if (warmed || booted) return; warmed = true; boot(); worker.postMessage({ id: 0 }); } + function warm() { if (warmed || booted || light()) return; warmed = true; boot(); worker.postMessage({ id: 0 }); } // Change between the processor and the graphics card: the worker starts again on the other model; lines // waiting to be made are made by it. `failed` is set when the graphics card could not load it. function engine(on, failed = false) { @@ -226,7 +234,7 @@ export function createSpeaker(status = () => {}) { // `said(text, waiting)` is told the line being spoken ('' when none), or that the voice is being got ready. export function createVoice({ ctx, said, speaker }) { const S = { sig: '', lines: new Map(), order: [], voice: DEFAULT_VOICE, cur: null, src: null, gain: null, t0: 0, off: 0, held: false, utter: null, rate: 1 }; - const device = () => S.voice === 'device'; + const device = () => S.voice === 'device' || light(); function quit() { const s = S.src; S.src = null; if (s) { s.onended = null; try { s.stop(); } catch (e) { /* not started */ } } @@ -329,7 +337,7 @@ export function listen(speaker, voice, ctx, done, fail, text = SAMPLE, began = ( const say = (k) => { if (stopped) return; if (k >= lines.length) return done(); - if (voice === 'device') { + if (voice === 'device' || light()) { if (typeof speechSynthesis === 'undefined') return fail(new Error('This browser has no voice of its own.')); u = new SpeechSynthesisUtterance(lines[k]); const en = speechSynthesis.getVoices().filter((v) => /^en/i.test(v.lang));