diff --git a/lib/yap.js b/lib/yap.js index 11bc0371..418412d3 100644 --- a/lib/yap.js +++ b/lib/yap.js @@ -1,36 +1,39 @@ import { Howl } from 'howler' let yapping = false -const yap_sounds = { - // these sounds and most of the yapping code are adapted from https://github.com/equalo-official/animalese-generator - a: new Howl({ src: 'audio/yapping/a.wav' }), - b: new Howl({ src: 'audio/yapping/b.wav' }), - c: new Howl({ src: 'audio/yapping/c.wav' }), - d: new Howl({ src: 'audio/yapping/d.wav' }), - e: new Howl({ src: 'audio/yapping/e.wav' }), - f: new Howl({ src: 'audio/yapping/f.wav' }), - g: new Howl({ src: 'audio/yapping/g.wav' }), - h: new Howl({ src: 'audio/yapping/h.wav' }), - i: new Howl({ src: 'audio/yapping/i.wav' }), - j: new Howl({ src: 'audio/yapping/j.wav' }), - k: new Howl({ src: 'audio/yapping/k.wav' }), - l: new Howl({ src: 'audio/yapping/l.wav' }), - m: new Howl({ src: 'audio/yapping/m.wav' }), - n: new Howl({ src: 'audio/yapping/n.wav' }), - o: new Howl({ src: 'audio/yapping/o.wav' }), - p: new Howl({ src: 'audio/yapping/p.wav' }), - q: new Howl({ src: 'audio/yapping/q.wav' }), - r: new Howl({ src: 'audio/yapping/r.wav' }), - s: new Howl({ src: 'audio/yapping/s.wav' }), - t: new Howl({ src: 'audio/yapping/t.wav' }), - u: new Howl({ src: 'audio/yapping/u.wav' }), - v: new Howl({ src: 'audio/yapping/v.wav' }), - w: new Howl({ src: 'audio/yapping/w.wav' }), - x: new Howl({ src: 'audio/yapping/x.wav' }), - y: new Howl({ src: 'audio/yapping/y.wav' }), - z: new Howl({ src: 'audio/yapping/z.wav' }), - th: new Howl({ src: 'audio/yapping/th.wav' }), - sh: new Howl({ src: 'audio/yapping/sh.wav' }), - _: new Howl({ src: 'audio/yapping/_.wav' }), +let yap_sounds = {} +function loadYapSounds() { + yap_sounds = { + // these sounds and most of the yapping code are adapted from https://github.com/equalo-official/animalese-generator + a: new Howl({ src: 'audio/yapping/a.wav' }), + b: new Howl({ src: 'audio/yapping/b.wav' }), + c: new Howl({ src: 'audio/yapping/c.wav' }), + d: new Howl({ src: 'audio/yapping/d.wav' }), + e: new Howl({ src: 'audio/yapping/e.wav' }), + f: new Howl({ src: 'audio/yapping/f.wav' }), + g: new Howl({ src: 'audio/yapping/g.wav' }), + h: new Howl({ src: 'audio/yapping/h.wav' }), + i: new Howl({ src: 'audio/yapping/i.wav' }), + j: new Howl({ src: 'audio/yapping/j.wav' }), + k: new Howl({ src: 'audio/yapping/k.wav' }), + l: new Howl({ src: 'audio/yapping/l.wav' }), + m: new Howl({ src: 'audio/yapping/m.wav' }), + n: new Howl({ src: 'audio/yapping/n.wav' }), + o: new Howl({ src: 'audio/yapping/o.wav' }), + p: new Howl({ src: 'audio/yapping/p.wav' }), + q: new Howl({ src: 'audio/yapping/q.wav' }), + r: new Howl({ src: 'audio/yapping/r.wav' }), + s: new Howl({ src: 'audio/yapping/s.wav' }), + t: new Howl({ src: 'audio/yapping/t.wav' }), + u: new Howl({ src: 'audio/yapping/u.wav' }), + v: new Howl({ src: 'audio/yapping/v.wav' }), + w: new Howl({ src: 'audio/yapping/w.wav' }), + x: new Howl({ src: 'audio/yapping/x.wav' }), + y: new Howl({ src: 'audio/yapping/y.wav' }), + z: new Howl({ src: 'audio/yapping/z.wav' }), + th: new Howl({ src: 'audio/yapping/th.wav' }), + sh: new Howl({ src: 'audio/yapping/sh.wav' }), + _: new Howl({ src: 'audio/yapping/_.wav' }), + } } export async function yap( @@ -43,6 +46,9 @@ export async function yap( } = {}, ) { yapping = true + if (Object.keys(yap_sounds).length === 0) { + loadYapSounds() + } return new Promise((resolve, reject) => { const yap_queue = [] diff --git a/src/app/harbor/shipyard/idea-generator/impl.js b/src/app/harbor/shipyard/idea-generator/impl.js index 63dbff61..8f3c17fb 100644 --- a/src/app/harbor/shipyard/idea-generator/impl.js +++ b/src/app/harbor/shipyard/idea-generator/impl.js @@ -7,37 +7,39 @@ import Modal from '@/components/ui/modal' import { Button } from '@/components/ui/button' import { useChat } from 'ai/react' - -const yap_sounds = { - a: new Howl({ src: 'audio/yapping/a.wav' }), - b: new Howl({ src: 'audio/yapping/b.wav' }), - c: new Howl({ src: 'audio/yapping/c.wav' }), - d: new Howl({ src: 'audio/yapping/d.wav' }), - e: new Howl({ src: 'audio/yapping/e.wav' }), - f: new Howl({ src: 'audio/yapping/f.wav' }), - g: new Howl({ src: 'audio/yapping/g.wav' }), - h: new Howl({ src: 'audio/yapping/h.wav' }), - i: new Howl({ src: 'audio/yapping/i.wav' }), - j: new Howl({ src: 'audio/yapping/j.wav' }), - k: new Howl({ src: 'audio/yapping/k.wav' }), - l: new Howl({ src: 'audio/yapping/l.wav' }), - m: new Howl({ src: 'audio/yapping/m.wav' }), - n: new Howl({ src: 'audio/yapping/n.wav' }), - o: new Howl({ src: 'audio/yapping/o.wav' }), - p: new Howl({ src: 'audio/yapping/p.wav' }), - q: new Howl({ src: 'audio/yapping/q.wav' }), - r: new Howl({ src: 'audio/yapping/r.wav' }), - s: new Howl({ src: 'audio/yapping/s.wav' }), - t: new Howl({ src: 'audio/yapping/t.wav' }), - u: new Howl({ src: 'audio/yapping/u.wav' }), - v: new Howl({ src: 'audio/yapping/v.wav' }), - w: new Howl({ src: 'audio/yapping/w.wav' }), - x: new Howl({ src: 'audio/yapping/x.wav' }), - y: new Howl({ src: 'audio/yapping/y.wav' }), - z: new Howl({ src: 'audio/yapping/z.wav' }), - th: new Howl({ src: 'audio/yapping/th.wav' }), - sh: new Howl({ src: 'audio/yapping/sh.wav' }), - _: new Howl({ src: 'audio/yapping/_.wav' }), +let yap_sounds = {} +function loadYapSounds() { + yap_sounds = { + a: new Howl({ src: 'audio/yapping/a.wav' }), + b: new Howl({ src: 'audio/yapping/b.wav' }), + c: new Howl({ src: 'audio/yapping/c.wav' }), + d: new Howl({ src: 'audio/yapping/d.wav' }), + e: new Howl({ src: 'audio/yapping/e.wav' }), + f: new Howl({ src: 'audio/yapping/f.wav' }), + g: new Howl({ src: 'audio/yapping/g.wav' }), + h: new Howl({ src: 'audio/yapping/h.wav' }), + i: new Howl({ src: 'audio/yapping/i.wav' }), + j: new Howl({ src: 'audio/yapping/j.wav' }), + k: new Howl({ src: 'audio/yapping/k.wav' }), + l: new Howl({ src: 'audio/yapping/l.wav' }), + m: new Howl({ src: 'audio/yapping/m.wav' }), + n: new Howl({ src: 'audio/yapping/n.wav' }), + o: new Howl({ src: 'audio/yapping/o.wav' }), + p: new Howl({ src: 'audio/yapping/p.wav' }), + q: new Howl({ src: 'audio/yapping/q.wav' }), + r: new Howl({ src: 'audio/yapping/r.wav' }), + s: new Howl({ src: 'audio/yapping/s.wav' }), + t: new Howl({ src: 'audio/yapping/t.wav' }), + u: new Howl({ src: 'audio/yapping/u.wav' }), + v: new Howl({ src: 'audio/yapping/v.wav' }), + w: new Howl({ src: 'audio/yapping/w.wav' }), + x: new Howl({ src: 'audio/yapping/x.wav' }), + y: new Howl({ src: 'audio/yapping/y.wav' }), + z: new Howl({ src: 'audio/yapping/z.wav' }), + th: new Howl({ src: 'audio/yapping/th.wav' }), + sh: new Howl({ src: 'audio/yapping/sh.wav' }), + _: new Howl({ src: 'audio/yapping/_.wav' }), + } } const soundKeys = Object.keys(yap_sounds) @@ -52,6 +54,9 @@ async function yap( } = {}, ) { const yap_queue = [] + if (Object.keys(yap_sounds).length === 0) { + loadYapSounds() + } for (let i = 0; i < text.length; i++) { const char = text[i] const lowerChar = char?.toLowerCase()