diff --git a/app.js b/app.js index 0a36c8c..c2b3687 100644 --- a/app.js +++ b/app.js @@ -3724,6 +3724,42 @@ async function initBookshelves() { { prNum: 294, title: 'Northern lights flash on PR merge' }, ]; } + document.getElementById('podcast-toggle').addEventListener('click', async () => { + const errorEl = document.getElementById('podcast-error'); + errorEl.style.display = 'none'; + errorEl.textContent = ''; + + try { + const response = await fetch('SOUL.md'); + if (!response.ok) throw new Error('Failed to load SOUL.md'); + const text = await response.text(); + const lines = text.split('\n').filter(line => line.trim() !== ''); + speakLines(lines); + } catch (err) { + errorEl.textContent = 'Failed to load SOUL.md. Check console for details.'; + errorEl.style.display = 'block'; + console.error('Podcast error:', err); + } + }); + + function speakLines(lines) { + const synth = window.speechSynthesis; + const utterances = lines.map(line => { + const u = new SpeechSynthesisUtterance(line); + u.rate = 0.85; + u.pitch = 0.9; + return u; + }); + + let index = 0; + function speakNext() { + if (index >= utterances.length) return; + synth.speak(utterances[index]); + index++; + setTimeout(speakNext, 800); + } + speakNext(); + } if (prs.length === 0) return;