Files
zooqueenandHanzo Dev ae4c4b3034 Give Blue a voice, a wordmark, and links that resolve
Audio: twenty-eight of the twenty-nine clips carry no audio track, so a
mute switch would have switched nothing. What the site can actually say
out loud is the answer, through the browser's own synthesiser — no
network, no key, 180 voices on this machine. The speaker is the user
gesture browsers require, so reading aloud only ever starts because
someone asked for it, and a new question stops the old one mid-sentence.

Proposal links were broken on every card: zips.zoo.ngo serves them under
/docs/<slug>/ and the generator wrote /<slug>, so all 149 pointed at a
404. Fixed, and both link shapes are now asserted — shape is the part a
test can hold, and it is the part that was wrong.

The reply path had no test at all, which is how the parser went unexamined
while the fabricated fallback hid every failure behind it. It has six now,
against a real streaming body: tokens in order, a frame split across two
reads, keep-alives and non-JSON lines skipped, and a refusal arriving as
its own words rather than as prose. Driven end to end against a stand-in
model, the loop lands: clip swaps to Interest, the caption follows, the
[feeling:] tag stays out of the visible answer, and the answer is spoken.

Look: ZOO LABS reads top left at full weight — the mark left the header
for the bottom right, where a launcher belongs, and puts the cursor in the
question box from anywhere on the site. Zen now comes from @hanzo/font,
which is where the family is authored, rather than two woff2 files copied
into public/.

Also fixed: <Paragraph> inside <Paragraph> put a <p> inside a <p> and
broke hydration on both pages; `'' && <X/>` rendered an empty text node
into a gui View, which warns on every render. Both were reported by the
browser and neither had been read.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-01 12:48:58 -07:00

47 lines
1.5 KiB
TypeScript

// Blue out loud.
//
// The clips are silent — one of the twenty-nine carries an audio track — so
// there is no sound to unmute. The voice is the browser's own synthesiser,
// which every modern one ships, needs no network and no key, and reads at
// whatever rate we ask. For a reader who is eight, that is the difference
// between a paragraph and a wall.
export const canSpeak = () =>
typeof window !== 'undefined' && typeof window.speechSynthesis !== 'undefined'
/** Strip what should not be read: markdown scaffolding and bare URLs. */
export function sayable(text: string): string {
return text
.replace(/```[\s\S]*?```/g, ' ')
.replace(/https?:\/\/\S+/g, ' ')
.replace(/[*_`#>]/g, '')
.replace(/\s+/g, ' ')
.trim()
}
/** A voice that suits the character, if the platform has one. */
function pick(): SpeechSynthesisVoice | undefined {
const voices = window.speechSynthesis.getVoices()
const english = voices.filter((v) => v.lang.startsWith('en'))
return english.find((v) => /female|samantha|karen|moira/i.test(v.name)) ?? english[0] ?? voices[0]
}
/** Reads text aloud, cancelling anything already in progress. */
export function say(text: string) {
if (!canSpeak()) return
const words = sayable(text)
if (!words) return
window.speechSynthesis.cancel()
const line = new SpeechSynthesisUtterance(words)
line.rate = 0.95
line.pitch = 1.1
const voice = pick()
if (voice) line.voice = voice
window.speechSynthesis.speak(line)
}
export function hush() {
if (canSpeak()) window.speechSynthesis.cancel()
}