-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from Gaurav0203Shetty/text-speech
text to speech
- Loading branch information
Showing
8 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Text to speech- | ||
|
||
A basic text to speech converter made using HTML, CSS and JS which features different voices! | ||
|
||
Feel free to make any changes by pull request.} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Text-to-speech</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="hero"> | ||
<h1>Text to speech <span>converter</span></h1> | ||
<textarea placeholder="Write text here..."></textarea> | ||
<div class="row"> | ||
<select></select> | ||
<button><img src="./Images/play.png" alt="Error">Listen</button> | ||
</div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
let speech = new SpeechSynthesisUtterance(); | ||
let voices = []; | ||
let voiceSelect = document.querySelector("select"); | ||
|
||
window.speechSynthesis.onvoiceschanged = () => { | ||
voices = window.speechSynthesis.getVoices(); | ||
speech.voice = voices[0]; | ||
voices.forEach((voice, i) => (voiceSelect.options[i] = new Option(voice.name, i))); | ||
}; | ||
|
||
voiceSelect.addEventListener("change", () => { | ||
speech.voice = voices[voiceSelect.value]; | ||
}); | ||
|
||
document.querySelector("button").addEventListener("click", () => { | ||
speech.text = document.querySelector("textarea").value; | ||
window.speechSynthesis.speak(speech); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
font-family: 'Poppins', sans-serif; | ||
box-sizing: border-box; | ||
} | ||
|
||
.hero{ | ||
width: 100%; | ||
min-height: 100vh; | ||
background: linear-gradient(270deg, #b8e663, #4831D4); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
color: #fff; | ||
} | ||
|
||
.hero h1{ | ||
font-size: 45px; | ||
font-weight: 500; | ||
margin-top: -50px; | ||
margin-bottom: 50px; | ||
} | ||
|
||
.hero h1 span{ | ||
color: #b8e663; | ||
} | ||
|
||
textarea{ | ||
width: 600px; | ||
height: 250px; | ||
background: #403d84; | ||
color: #fff; | ||
font-size: 15px; | ||
border: 0; | ||
outline: 0; | ||
padding: 20px; | ||
border-radius: 10px; | ||
resize: none; | ||
margin-bottom: 30px; | ||
} | ||
|
||
textarea::placeholder{ | ||
font-size: 16px; | ||
color: #ddd; | ||
} | ||
|
||
.row{ | ||
width: 600px; | ||
display: flex; | ||
align-items: center; | ||
gap: 20px; | ||
} | ||
|
||
button{ | ||
background: #90dd02; | ||
color: black; | ||
font-size: 16px; | ||
padding: 10px 30px; | ||
border-radius: 35px; | ||
border: 0; | ||
outline: 0; | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
button img{ | ||
width: 25px; | ||
margin-right: 10px; | ||
} | ||
|
||
select{ | ||
flex: 1; | ||
color: black; | ||
background: #90dd02; | ||
height: 50px; | ||
padding: 0 20px; | ||
outline: 0; | ||
border: 0; | ||
border-radius: 35px; | ||
appearance: none; | ||
background-image: url(./Images/dropdown.png); | ||
background-repeat: no-repeat; | ||
background-size: 15px; | ||
background-position-x:calc(100% - 20px); | ||
background-position-y:20px; | ||
} |