File tree 3 files changed +77
-0
lines changed
VoiceGenerator/Sahil-K123
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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
+ } )
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments