vibedom 如何把網站外觀轉化為程序生成的聲景
How vibedom turns a website's look into a procedural soundscape
Germán Torres 開發的 vibedom 可掃描網站設計,並在瀏覽器即時合成相應的聲景。它把頁面色彩、字體、文字與動態訊號整理為 JSON Sound Seed,再由 Gemini(Vertex AI)或本地 composer 設定音樂參數,交由 Tone.js 合成,不使用音訊樣本。
Paste a URL into vibedom and it plays a soundtrack built from that site's design. A scraper reads the page, a JSON "Sound Seed" is produced, and Tone.js synthesises pad, drone and arpeggio in the browser: no samples, no account, no audio file to download. I built it as a CS student at the University of Málaga. The code is open source (germantes/vibedom, MIT).
From URL to seed
A scan is POST /api/scan. The server first checks the URL, including a DNS lookup, so the scraper cannot be pointed at private or reserved addresses. Every redirect and stylesheet goes through the same guard.
The scraper then fetches the HTML and up to four stylesheets with plain fetch. There is no headless browser, so it does not see computed CSS or JavaScript-rendered markup. Each fetch has an 8-second timeout, the whole scrape a 20-second budget, and bodies are capped at 2 MB. The User-Agent is VibeDomBot/1.0; a 403, 429 or 5xx is retried once with a browser-like header.
What it keeps is a compact aesthetic fingerprint:
- Semantics:
<title>,meta descriptionorog:description, up to five<h1>s, and a short text sample. - Colour: hex and
rgb()values from the CSS, plusmeta theme-color. Background comes fromhtml/body/:rootwhen those rules exist; otherwise the most frequent CSS colour. Relative luminance decidesisDark(threshold 0.4). - Type:
font-familydeclarations, grouped intoserif,sans-serif,monospaceordisplay. - Motion: whether the CSS contains
animation/@keyframesortransition.
The HTML of the scanned site is not stored. The public ranking keeps only the domain and the UTC day of the scan, never the path, query string or IP.
Those signals become a Sound Seed, from Gemini on Vertex AI or from a local composer, then pass through normalizeSeed(): invalid types and enums fail, out-of-range numbers are clipped, free text is truncated. Successful AI seeds for the same URL stay in an in-memory cache for six hours (up to 500 entries). The cache dies when the process restarts. If you do not want to send a URL, the landing still plays three static presets (Cyberpunk, Editorial, Indie pastel).
The Sound Seed
The seed is the contract between analysis and playback. This is the real Stripe seed from the Sound tests page:
{
"metadata": {
"url": "https://stripe.com/",
"detectedVibe": "Sleek, high-tech financial infrastructure",
"explanation": "The clean, bright background combined with vibrant violet accents and dynamic animations translates to a fast-paced, highly structured lydian soundscape with crisp arpeggios that open up as you scroll."
},
"uiTheme": {
"backgroundColor": "#ffffff",
"accentColor": "#533afd",
"textColor": "#161741",
"fontFamily": "sans-serif"
},
"musicalParams": {
"bpm": 92,
"rootNote": "G",
"scale": "lydian",
"octave": 4
},
"synthConfig": {
"pad": { "waveform": "triangle", "attack": 1.5, "release": 3, "filterFreq": 2500 },
"arp": { "enabled": true, "waveform": "sine", "density": 0.65, "delayWet": 0.4 },
"effects": { "reverbDecay": 4.5, "reverbWet": 0.3, "chorusDepth": 0.25 },
"interactivity": {
"scrollTarget": "filterFreq",
"scrollMultiplier": 2.5,
"hoverNoteTrigger": true
}
}
}
uiTheme is applied to the landing so the page visually becomes the site you pasted. Scales are major, minor, dorian, phrygian, lydian or pentatonic; waveforms are sine, triangle, sawtooth or square. Tempo sits between 40 and 140 BPM. The playground exposes the same JSON and live sliders.
The model, and the composer that does not need one
The translator is a short "synesthetic music director" prompt plus structured output from a Gemini model served through Vertex AI. The schema is the seed itself, so the model has to fill metadata, uiTheme, musicalParams and synthConfig. The prompt uses the same rules as the local composer: a dark background leans toward minor, phrygian or dorian, a slower tempo and a closed filter; a light one toward major or lydian and a more open filter; saturated colours get more chorus and saw/square waves; serif type gets longer reverb; animations raise tempo and arpeggio density. detectedVibe and explanation follow the language of the vibedom page (Spanish or English), not of the scanned site. Technical field names stay in English.
In production the backend talks to Vertex AI (Google Cloud) with a service account; the plain Gemini API with GEMINI_KEY is only kept as a fallback for local development. The default model list is gemini-3.5-flash, then gemini-3.5-flash-lite, then gemini-3.6-flash. Each call has a 20-second attempt timeout and a 30-second overall deadline, with exponential backoff and jitter. If one model fails, the next is tried. Thinking is set to "low" because the schema already constrains the answer.
When the key is missing, the quota is spent, or the call errors, the scan does not go silent. composeLocalSeed() applies the same rules with plain arithmetic: luminance, accent saturation, font category and motion flags decide BPM, scale, waveforms, filter, reverb and whether the arpeggio is on. A short FNV-1a hash of a stable fingerprint (final URL, title, colours, font, motion) picks the remaining variations, so the same site with the same signals always yields the same seed. The UI language never changes the music, only the visible copy. The seed is marked metadata.source: "local", and the landing says so. If a site blocks automated reads, a variation can still be derived from the URL alone, and the copy says the palette could not be read.
Playing the seed
createSoundscape() builds a small graph, tuned for modest CPUs: a sine drone; a pad (PolySynth with a fat* oscillator, two detuned voices) through a low-pass filter; and an arpeggio (Synth) through its own filter and a feedback delay. Those buses meet at a chorus, then a Freeverb (cheaper than a convolution reverb), a limiter and the master output. An analyser and an FFT feed the visualisers. The master fades in over 2.5 seconds. Tone.js is injected, not bundled, and loads only after the first click.
Harmony is generated, not read from a file. Chord degrees follow a Markov-style walk that favours fourths and fifths, soft third motions and a pull back to the tonic, and never repeats the current degree. Diminished fifths are skipped. Each new pad voicing is octave-transposed toward the centre of the previous one so the part does not leap. The arpeggio is a short random walk on the scale, weighted toward the current chord; density is a probability per eighth-note. Scroll velocity, smoothed and decayed, modulates one parameter (filterFreq, reverbWet, delayWet or arpDensity). Hovering a link or button can trigger a quiet scale tone, with a short debounce. Stripe's seed above opens the filter as you scroll. None of this audio is streamed or pre-recorded.
A widget under 5 KB, and no API calls
The embed is a single script tag:
<script src="https://vibedom.dev/widget.js" data-seed="<base64>" defer></script>
widget.js is under 5 KB. It decodes data-seed (the Sound Seed as UTF-8, then Base64), mounts a floating button in an open Shadow DOM with all: initial so it does not inherit or leak host CSS. The seed never leaves the snippet. There is no call to the model. On load, the widget sends one cookie-free ping with just the embedding domain (skipped under Do Not Track or Global Privacy Control), so I can see where it's used. No cookies, no localStorage, no IP stored. Labels follow <html lang>. Only the first click imports widget-player.js, which loads Tone.js from jsDelivr and starts the same engine, still inside the user gesture so the browser allows audio. Visitors hear the variation you baked in. See the install guide.
Privacy choices
This is a product decision, not an afterthought. vibedom has no accounts, no first-party cookies, no pixels and no third-party analytics. Music is synthesised locally. Shared long links carry the seed in the URL itself. If you copy the short link, the seed is stored for 30 days in Redis so the preview card can be served, then it expires. I would rather lose some marketing numbers than put a tracking script on a site that claims it does not profile you.
What's next
A few things I'm thinking about. Nothing is promised, and I'd love to hear which one you'd actually use:
- A browser extension, so any tab can play its own soundscape without copying the URL into vibedom.
- Audio export, to download a loop as WAV and use it in a video or a project.
-
Real instruments beyond synthesizers. Tone.js already ships
Tone.Sampler, so the idea is to let the seed pick an instrumentation (piano and strings for an editorial site, marimba or kalimba for a pastel one) using freely licensed sample banks, loaded only when you press play so the widget stays tiny.
If you have ideas, or a site you want to hear, leave a comment.
Try it
- English landing: vibedom.dev/en
- Ten real sound tests (Stripe, Apple, Wikipedia, Nike and others): vibedom.dev/en/sound-tests
- Playground with the raw seed: vibedom.dev/playground/en
- Source: github.com/germantes/vibedom
If you try it on your own site, I am curious which mapping surprised you: the scale, the filter, or the way the scroll opens the sound.
來源:DEV Community · dev.to