diff --git a/VoiceSearch/index.html b/VoiceSearch/index.html new file mode 100644 index 00000000..bcd55ff3 --- /dev/null +++ b/VoiceSearch/index.html @@ -0,0 +1,15 @@ + + + + + + Flipkart Voice Search + + +

Welcome to Flipkart

+ + + + + + diff --git a/VoiceSearch/voice-search.js b/VoiceSearch/voice-search.js new file mode 100644 index 00000000..6ffd79c3 --- /dev/null +++ b/VoiceSearch/voice-search.js @@ -0,0 +1,29 @@ +function startVoiceSearch() { + if ('webkitSpeechRecognition' in window) { + var recognition = new webkitSpeechRecognition(); + recognition.lang = 'en-US'; + + recognition.onstart = function() { + console.log('Voice search started...'); + }; + + recognition.onresult = function(event) { + var transcript = event.results[0][0].transcript; + document.getElementById('searchInput').value = transcript; + console.log('Voice search result:', transcript); + // Here you can trigger search based on the transcript + }; + + recognition.onerror = function(event) { + console.error('Voice search error:', event.error); + }; + + recognition.onend = function() { + console.log('Voice search ended.'); + }; + + recognition.start(); + } else { + alert('Voice search not supported in your browser.'); + } +}