Skip to content

Instantly share code, notes, and snippets.

@macdonst
Created September 4, 2013 01:25
SpeechShim Demo
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Web Speech API Demo</title>
</head>
<body>
<img id="audioIn" src="voice.jpg"/>
<div id="result">
</div>
<script type="text/javascript" src="speechshim.js"></script>
<script type="text/javascript" src="speakClient.js"></script>
<script type="text/javascript">
var audioIn = document.getElementById("audioIn");
audioIn.addEventListener("click", recognize, false);
function recognize() {
var recognition = new SpeechRecognition();
recognition.onresult = function(event) {
if (event.results.length > 0) {
var text = event.results[0][0].transcript;
document.getElementById("result").innerText = text;
var u = new SpeechSynthesisUtterance();
u.text = text;
u.lang = 'en-US';
speechSynthesis.speak(u);
}
};
recognition.start();
}
</script>
</body>
</html>
@OrtalLagziel
Copy link

Hi,
is it possible to change the voice to a male voice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment