Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const startButton = document.getElementById('startRecording');
+ const stopButton = document.getElementById('stopRecording');
+ const transcriptionOutput = document.getElementById('transcription');
+ const summaryOutput = document.getElementById('summary');
+ const themeToggle = document.getElementById('themeToggle');
+
+ let recognition = null;
+ let isRecording = false;
+
+ // Theme handling
+ const toggleTheme = () => {
+ const currentTheme = document.documentElement.getAttribute('data-theme');
+ const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
+ document.documentElement.setAttribute('data-theme', newTheme);
+ localStorage.setItem('theme', newTheme);
+ };
+
+ themeToggle.addEventListener('click', toggleTheme);
+
+ // Load saved theme
+ const savedTheme = localStorage.getItem('theme');
+ if (savedTheme) {
+ document.documentElement.setAttribute('data-theme', savedTheme);
+ }
+
+ // Speech recognition setup
+ if ('webkitSpeechRecognition' in window) {
+ recognition = new webkitSpeechRecognition();
+ recognition.continuous = true;
+ recognition.interimResults = true;
+
+ recognition.onstart = () => {
+ isRecording = true;
+ startButton.disabled = true;
+ stopButton.disabled = false;
+ startButton.classList.add('recording');
+ };
+
+ recognition.onend = () => {
+ isRecording = false;
+ startButton.disabled = false;
+ stopButton.disabled = true;
+ startButton.classList.remove('recording');
+ generateSummary();
+ };
+
+ recognition.onresult = (event) => {
+ let interimTranscript = '';
+ let finalTranscript = '';
+
+ for (let i = event.resultIndex; i < event.results.length; i++) {
+ const transcript = event.results[i][0].transcript;
+ if (event.results[i].isFinal) {
+ finalTranscript += transcript;
+ } else {
+ interimTranscript += transcript;
+ }
+ }
+
+ transcriptionOutput.innerHTML = finalTranscript +
+ '' + interimTranscript + '';
+ };
+
+ startButton.addEventListener('click', () => {
+ transcriptionOutput.innerHTML = '';
+ summaryOutput.innerHTML = '';
+ recognition.start();
+ });
+
+ stopButton.addEventListener('click', () => {
+ recognition.stop();
+ });
+ } else {
+ startButton.disabled = true;
+ alert('Speech recognition is not supported in your browser. Please use Chrome.');
+ }
+
+ // Simple summarization function (placeholder)
+ function generateSummary() {
+ const text = transcriptionOutput.textContent;
+ if (text.length > 0) {
+ // This is a very basic summary generator
+ // In a real application, you'd want to use more sophisticated NLP
+ const sentences = text.split(/[.!?]+/).filter(sentence => sentence.trim().length > 0);
+ const summary = sentences.slice(0, 2).join('. ') + '.';
+ summaryOutput.textContent = summary;
+ }
+ }
+ });