-
Notifications
You must be signed in to change notification settings - Fork 0
/
speech.html
44 lines (37 loc) · 1.32 KB
/
speech.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<title>Speech Recognition</title>
</head>
<body>
<center><h1>Voice Recognition and Display System</h1></center>
<br><br>
<center><button id="btn" onclick="recognition.start()">Start Record</button></center>
<br>
<h2 id="result"></h2>
</body>
<script>
const btn = document.getElementById("btn");
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.onstart = function()
{
console.log("You Can Start Now");
}
recognition.onresult = function(event)
{
console.log(event);
var text = event.results[0][0].transcript;
console.log(text);
document.getElementById("result").innerHTML = text;
// read(text);
read("How Are You, क्या हाल है");
}
function read(text)
{
var Speech = new SpeechSynthesisUtterance();
Speech.text = text;
window.speechSynthesis.speak(Speech);
}
</script>
</html>