feat: Research: NotebookLM — create audio overview of SOUL.md as podcast (#293)
Refs #293 Agent: groq
This commit is contained in:
36
app.js
36
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user