-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverseSpeech.html
63 lines (63 loc) · 1.48 KB
/
reverseSpeech.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Reverse speaker</title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
.main {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.text {
width: 70vw !important;
height: 40vh;
font-size: 25px;
font-family: "Segoe UI", sans-serif;
margin-bottom: 2vh;
}
.text:focus {
border: none;
}
.say {
width: 70vw;
height: 10vh;
border: none;
font-family: "Segoe UI", sans-serif;
font-size: 40px;
background-color: #440fda;
color: white;
transition: 0.2s ease;
}
.say:hover {
background-color: #30099b;
}
</style>
<body>
<div class="main">
<textarea class="text" placeholder="Enter your text here.."></textarea>
<button class="say">Say</button>
</div>
</body>
<script>
const synth = window.speechSynthesis;
let sayButton = document.querySelector(".say");
sayButton.addEventListener("click", () => {
let t = document.querySelector(".text").value;
let l = t.split("").reverse();
r = l.join("");
utter = new SpeechSynthesisUtterance(r);
synth.speak(utter);
});
</script>
</html>