Changed around line 1
- const transcript = document.getElementById('transcript');
- const summary = document.getElementById('summary');
-
- let recognition = null;
+ const transcriptionOutput = document.getElementById('transcription');
+ const summaryOutput = document.getElementById('summary');
+ const themeToggle = document.querySelector('.theme-toggle');
+ let recognition = null;
+ let isRecording = false;
+
+ // Theme handling
+ const toggleTheme = () => {
+ const isDark = document.body.getAttribute('data-theme') === 'dark';
+ document.body.setAttribute('data-theme', isDark ? 'light' : 'dark');
+ localStorage.setItem('theme', isDark ? 'light' : 'dark');
+ };
+
+ themeToggle.addEventListener('click', toggleTheme);
+
+ // Set initial theme
+ const savedTheme = localStorage.getItem('theme') || 'light';
+ document.body.setAttribute('data-theme', savedTheme);
+
+ // Speech recognition setup
- } else {
- startBtn.disabled = true;
- transcript.innerHTML = 'Speech recognition is not supported in this browser.';
- }
-
- function summarizeText(text) {
- // Simple summarization algorithm (example)
- const sentences = text.split(/[.!?]+/);
- const significantSentences = sentences
- .filter(sentence => sentence.length > 10)
- .slice(0, 3);
- return significantSentences.join('. ') + '.';
- }
- if (recognition) {
- finalTranscript += transcript + ' ';
+ finalTranscript += transcript;
- transcript.textContent = finalTranscript;
- summary.textContent = summarizeText(finalTranscript);
+ transcriptionOutput.textContent = finalTranscript;
+ generateSummary(finalTranscript);
- startBtn.addEventListener('click', () => {
- transcript.textContent = '';
- summary.textContent = '';
- recognition.start();
- startBtn.disabled = true;
- stopBtn.disabled = false;
- });
-
- stopBtn.addEventListener('click', () => {
- recognition.stop();
- startBtn.disabled = false;
- stopBtn.disabled = true;
- });
-
- startBtn.disabled = false;
- stopBtn.disabled = true;
+ stopRecording();
+
+ // Recording controls
+ const startRecording = () => {
+ if (!recognition) {
+ alert('Speech recognition is not supported in your browser.');
+ return;
+ }
+
+ recognition.start();
+ isRecording = true;
+ startBtn.disabled = true;
+ stopBtn.disabled = false;
+ startBtn.style.opacity = '0.6';
+ };
+
+ const stopRecording = () => {
+ if (recognition) {
+ recognition.stop();
+ }
+ isRecording = false;
+ startBtn.disabled = false;
+ stopBtn.disabled = true;
+ startBtn.style.opacity = '1';
+ };
+
+ // Simple summarization function (basic implementation)
+ const generateSummary = (text) => {
+ // Split into sentences
+ const sentences = text.match(/[^.!?]+[.!?]+/g) || [];
+
+ // Basic summary: take first 2 sentences or 20% of total sentences
+ const summaryLength = Math.max(2, Math.ceil(sentences.length * 0.2));
+ const summary = sentences.slice(0, summaryLength).join(' ');
+
+ summaryOutput.textContent = summary || 'Not enough content for summary';
+ };
+
+ startBtn.addEventListener('click', startRecording);
+ stopBtn.addEventListener('click', stopRecording);