User:Nenavath Sunil/common.js

$(document).ready(function { const searchForm = $('#search-form');  const searchInput = $('#search-bar');  const voiceSearchButton = $('#voice-search-button');  // create a new instance of the SpeechRecognition API  const recognition = new webkitSpeechRecognition;  recognition.continuous = false;  recognition.interimResults = false;  // when the user clicks the voice search button, start listening for speech input  voiceSearchButton.click(function { recognition.start; }); // when the speech recognition engine returns a result, populate the search box with the transcribed text  recognition.addEventListener('result', function(event) { const transcript = event.results[0][0].transcript; searchInput.val(transcript); searchForm.submit; }); // if there's an error with speech recognition, log it to the console  recognition.addEventListener('error', function(event) { console.log(event.error); }); // create a search button and attach an event listener to it  const searchButton = $(' ', { id: 'search-button', text: 'Search' }); searchButton.click(function { const searchTerm = searchInput.val; // Perform search using searchTerm }); // add the search button to the page  searchForm.append(searchButton); });