feat: Research: NotebookLM — create audio overview of SOUL.md as podcast (#293)
Refs #293 Agent: groq
This commit is contained in:
61
app.js
61
app.js
@@ -2719,33 +2719,54 @@ document.getElementById('audio-toggle').addEventListener('click', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Podcast toggle
|
||||
document.getElementById('podcast-toggle').addEventListener('click', () => {
|
||||
try {
|
||||
fetch('SOUL.md')
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error('Failed to load SOUL.md');
|
||||
return response.text();
|
||||
})
|
||||
.then(text => {
|
||||
const utterance = new SpeechSynthesisUtterance(text);
|
||||
const btn = document.getElementById('podcast-toggle');
|
||||
if (speechSynthesis.pending) return;
|
||||
|
||||
fetch('SOUL.md')
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error('Failed to load SOUL.md');
|
||||
return response.text();
|
||||
})
|
||||
.then(text => {
|
||||
// Split text into paragraphs for better speech flow
|
||||
const paragraphs = text.split('\n').filter(p => p.trim()).slice(1); // Skip title line
|
||||
|
||||
if (!paragraphs.length) {
|
||||
throw new Error('No content found in SOUL.md');
|
||||
}
|
||||
|
||||
let index = 0;
|
||||
|
||||
const speakNext = () => {
|
||||
if (index >= paragraphs.length) {
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const utterance = new SpeechSynthesisUtterance(paragraphs[index++]);
|
||||
utterance.lang = 'en-US';
|
||||
utterance.rate = 0.9;
|
||||
utterance.pitch = 0.9;
|
||||
utterance.onend = () => {
|
||||
document.getElementById('podcast-toggle').disabled = false;
|
||||
if (!utterance.error) speakNext();
|
||||
};
|
||||
document.getElementById('podcast-toggle').disabled = true;
|
||||
utterance.onerror = (e) => {
|
||||
console.error('Speech synthesis error:', e);
|
||||
btn.disabled = false;
|
||||
};
|
||||
|
||||
speechSynthesis.speak(utterance);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to load or play SOUL.md:', err);
|
||||
alert('Could not load SOUL.md for audio playback.');
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to load or play SOUL.md:', err);
|
||||
alert('Could not load SOUL.md for audio playback.');
|
||||
}
|
||||
btn.disabled = true;
|
||||
};
|
||||
|
||||
speakNext();
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Podcast failed:', err);
|
||||
alert('Failed to load SOUL.md for audio playback. Check console for details.');
|
||||
btn.disabled = false;
|
||||
});
|
||||
});
|
||||
|
||||
// === DEBUG MODE ===
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<button id="podcast-toggle" class="chat-toggle-btn" aria-label="Start podcast of SOUL.md" title="Play SOUL.md as audio">
|
||||
🎧
|
||||
</button>
|
||||
<button id="podcast-toggle" class="chat-toggle-btn" aria-label="Start podcast of SOUL.md" title="Play SOUL.md as audio podcast">
|
||||
<button id="podcast-toggle" class="chat-toggle-btn" aria-label="Start podcast of SOUL.md" title="Play SOUL.md as audio">
|
||||
🎧
|
||||
</button>
|
||||
<button id="timelapse-btn" class="chat-toggle-btn" aria-label="Start time-lapse replay" title="Time-lapse: replay today's activity in 30s [L]">
|
||||
|
||||
Reference in New Issue
Block a user