Skip to content

Commit 43b8bfa

Browse files
authored
Merge pull request #717 from Sahil-K123/VoiceGenerator-Sahil-K123
feat: Adding Voice Generator App
2 parents e88c350 + 1c2c089 commit 43b8bfa

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

VoiceGenerator/Sahil-K123/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="stylesheet" href="style.css">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<div class="hero">
11+
<h1> How to make a voice generator </h1>
12+
<textarea placeholder="Write Something Here ..."></textarea>
13+
<div class="row">
14+
<select name="" id=""></select>
15+
<button>Speak</button>
16+
</div>
17+
18+
</div>
19+
<script src="script.js"></script>
20+
</body>
21+
</html>

VoiceGenerator/Sahil-K123/script.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let speech = new SpeechSynthesisUtterance();
2+
3+
let voices = [];
4+
5+
let voiceSelect = document.querySelector("select");
6+
7+
window.speechSynthesis.onvoiceschanged = () => {
8+
voices = window.speechSynthesis.getVoices();
9+
speech.voice = voices[0];
10+
11+
voices.forEach((voice , i) => (voiceSelect.options[i] = new Option(voice.name, i)));
12+
}
13+
14+
voiceSelect.addEventListener("change", () => {
15+
speech.voice = voices[voiceSelect.value];
16+
})
17+
18+
19+
document.querySelector("button").addEventListener("click" , () => {
20+
speech.text = document.querySelector("textarea").value
21+
window.speechSynthesis.speak(speech);
22+
})

VoiceGenerator/Sahil-K123/style.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
body{
2+
3+
margin: 0px;
4+
padding: 0px;
5+
box-sizing: border-box;
6+
7+
}
8+
9+
10+
11+
.hero{
12+
width: 100%;
13+
min-height: 100vh;
14+
background: linear-gradient(45deg,#010758,#490d61);
15+
display: flex;
16+
align-items: center;
17+
justify-content: center;
18+
flex-direction: column;
19+
20+
}
21+
22+
.hero h1{
23+
font-size: 45px;
24+
font-weight: 500;
25+
margin-top: -50px;
26+
margin-bottom: 50px;
27+
28+
}
29+
30+
textarea{
31+
width: 600px;
32+
height: 250px;
33+
background: #403d84;
34+
}

0 commit comments

Comments
 (0)