jevstrudel.git / website / src / pages / jev-samples / lyrics.json.js
1// The words of the sample pack's sung and spoken clips, with where each
2// syllable starts: samples/<sound>/<sound>.lyrics.json, one object per sound
3// (`{ text, seconds, syllables: [[syllable, startSeconds], …] }`), gathered
4// here as one map by sound. The page shows them as subtitles while a clip
5// plays (src/jev/lyrics.mjs). Like the sample map beside it, the glob is live
6// in the dev server.
7const files = import.meta.glob('../../../../samples/*/*.lyrics.json', { eager: true, import: 'default' });
8
9export function GET() {
10  const map = {};
11  for (const [path, lyric] of Object.entries(files)) map[path.split('/').at(-2)] = lyric;
12  return new Response(JSON.stringify(map), { headers: { 'Content-Type': 'application/json' } });
13}