Last active
February 14, 2025 17:09
-
-
Save rishabhsahilll/2b01f4a4144941ef206f8c4ceb9a6ad5 to your computer and use it in GitHub Desktop.
SpeechToText.py is a Python script embedding HTML and JavaScript to enable real-time speech recognition using the Web Speech API. It allows AI Jarvis Assistant to convert speech into text seamlessly, featuring start/stop controls for hands-free interaction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HtmlCode = '''<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Speech Recognition</title> | |
</head> | |
<body> | |
<button id="start" onclick="startRecognition()">Start Recognition</button> | |
<button id="end" onclick="stopRecognition()">Stop Recognition</button> | |
<p id="output"></p> | |
<script> | |
const output = document.getElementById('output'); | |
let recognition; | |
function startRecognition() { | |
recognition = new webkitSpeechRecognition() || new SpeechRecognition(); | |
recognition.lang = ''; | |
recognition.continuous = true; | |
recognition.onresult = function(event) { | |
const transcript = event.results[event.results.length - 1][0].transcript; | |
output.textContent += transcript; | |
}; | |
recognition.onend = function() { | |
recognition.start(); | |
}; | |
recognition.start(); | |
} | |
function stopRecognition() { | |
recognition.stop(); | |
output.innerHTML = ""; | |
} | |
</script> | |
</body> | |
</html>''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment