diff --git a/VoiceGenerator/shanvijha/README.md b/VoiceGenerator/shanvijha/README.md new file mode 100644 index 000000000..6bb223c5a --- /dev/null +++ b/VoiceGenerator/shanvijha/README.md @@ -0,0 +1,11 @@ +## Speech Text Reader + +A text to speech app for non-verbal people. Pre-made buttons and custom text speech. This project uses the Web Speech API + +## Project Specifications + +- Create responsive UI (CSS Grid) with picture buttons +- Speaks the text when button clicked +- Drop down custom text to speech +- Speaks the text typed in +- Change voices and accents diff --git a/VoiceGenerator/shanvijha/img/angry.jpg b/VoiceGenerator/shanvijha/img/angry.jpg new file mode 100644 index 000000000..ba2234a06 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/angry.jpg differ diff --git a/VoiceGenerator/shanvijha/img/drink.jpg b/VoiceGenerator/shanvijha/img/drink.jpg new file mode 100644 index 000000000..3b83ce658 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/drink.jpg differ diff --git a/VoiceGenerator/shanvijha/img/food.jpg b/VoiceGenerator/shanvijha/img/food.jpg new file mode 100644 index 000000000..5dbd8303e Binary files /dev/null and b/VoiceGenerator/shanvijha/img/food.jpg differ diff --git a/VoiceGenerator/shanvijha/img/grandma.jpg b/VoiceGenerator/shanvijha/img/grandma.jpg new file mode 100644 index 000000000..72b133769 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/grandma.jpg differ diff --git a/VoiceGenerator/shanvijha/img/happy.jpg b/VoiceGenerator/shanvijha/img/happy.jpg new file mode 100644 index 000000000..8cc21cffc Binary files /dev/null and b/VoiceGenerator/shanvijha/img/happy.jpg differ diff --git a/VoiceGenerator/shanvijha/img/home.jpg b/VoiceGenerator/shanvijha/img/home.jpg new file mode 100644 index 000000000..e4c68e1a0 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/home.jpg differ diff --git a/VoiceGenerator/shanvijha/img/hurt.jpg b/VoiceGenerator/shanvijha/img/hurt.jpg new file mode 100644 index 000000000..aaa2ee516 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/hurt.jpg differ diff --git a/VoiceGenerator/shanvijha/img/outside.jpg b/VoiceGenerator/shanvijha/img/outside.jpg new file mode 100644 index 000000000..6efa5cbcf Binary files /dev/null and b/VoiceGenerator/shanvijha/img/outside.jpg differ diff --git a/VoiceGenerator/shanvijha/img/sad.jpg b/VoiceGenerator/shanvijha/img/sad.jpg new file mode 100644 index 000000000..8782260d8 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/sad.jpg differ diff --git a/VoiceGenerator/shanvijha/img/scared.jpg b/VoiceGenerator/shanvijha/img/scared.jpg new file mode 100644 index 000000000..f265f19d9 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/scared.jpg differ diff --git a/VoiceGenerator/shanvijha/img/school.jpg b/VoiceGenerator/shanvijha/img/school.jpg new file mode 100644 index 000000000..1dcbe555a Binary files /dev/null and b/VoiceGenerator/shanvijha/img/school.jpg differ diff --git a/VoiceGenerator/shanvijha/img/tired.jpg b/VoiceGenerator/shanvijha/img/tired.jpg new file mode 100644 index 000000000..09b1fb942 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/tired.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/angry.jpg b/VoiceGenerator/shanvijha/img/uncompressed/angry.jpg new file mode 100644 index 000000000..0ba8cbd57 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/angry.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/drink.jpg b/VoiceGenerator/shanvijha/img/uncompressed/drink.jpg new file mode 100644 index 000000000..8eba5e3d1 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/drink.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/food.jpg b/VoiceGenerator/shanvijha/img/uncompressed/food.jpg new file mode 100644 index 000000000..f22c46861 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/food.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/grandma.jpg b/VoiceGenerator/shanvijha/img/uncompressed/grandma.jpg new file mode 100644 index 000000000..26ed9402e Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/grandma.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/happy.jpg b/VoiceGenerator/shanvijha/img/uncompressed/happy.jpg new file mode 100644 index 000000000..6d3eaaaa7 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/happy.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/home.jpg b/VoiceGenerator/shanvijha/img/uncompressed/home.jpg new file mode 100644 index 000000000..14392c653 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/home.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/hurt.jpg b/VoiceGenerator/shanvijha/img/uncompressed/hurt.jpg new file mode 100644 index 000000000..22b04a28c Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/hurt.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/outside.jpg b/VoiceGenerator/shanvijha/img/uncompressed/outside.jpg new file mode 100644 index 000000000..e72292a21 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/outside.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/sad.jpg b/VoiceGenerator/shanvijha/img/uncompressed/sad.jpg new file mode 100644 index 000000000..00b683b8f Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/sad.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/scared.jpg b/VoiceGenerator/shanvijha/img/uncompressed/scared.jpg new file mode 100644 index 000000000..e6d574e18 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/scared.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/school.jpg b/VoiceGenerator/shanvijha/img/uncompressed/school.jpg new file mode 100644 index 000000000..9949e1c1a Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/school.jpg differ diff --git a/VoiceGenerator/shanvijha/img/uncompressed/tired.jpg b/VoiceGenerator/shanvijha/img/uncompressed/tired.jpg new file mode 100644 index 000000000..1d7652f25 Binary files /dev/null and b/VoiceGenerator/shanvijha/img/uncompressed/tired.jpg differ diff --git a/VoiceGenerator/shanvijha/index.html b/VoiceGenerator/shanvijha/index.html new file mode 100644 index 000000000..1e069aca1 --- /dev/null +++ b/VoiceGenerator/shanvijha/index.html @@ -0,0 +1,28 @@ + + +
+ + + + +${text}
+ `; + + box.addEventListener('click', () => { + setTextMessage(text); + speakText(); + + // Add active effect + box.classList.add('active'); + setTimeout(() => box.classList.remove('active'), 800); + }); + + main.appendChild(box); +} + +// Init speech synth +const message = new SpeechSynthesisUtterance(); + +// Store voices +let voices = []; + +function getVoices() { + voices = speechSynthesis.getVoices(); + + voices.forEach(voice => { + const option = document.createElement('option'); + + option.value = voice.name; + option.innerText = `${voice.name} ${voice.lang}`; + + voicesSelect.appendChild(option); + }); +} + +// Set text +function setTextMessage(text) { + message.text = text; +} + +// Speak text +function speakText() { + speechSynthesis.speak(message); +} + +// Set voice +function setVoice(e) { + message.voice = voices.find(voice => voice.name === e.target.value); +} + +// Voices changed +speechSynthesis.addEventListener('voiceschanged', getVoices); + +// Toggle text box +toggleBtn.addEventListener('click', () => + document.getElementById('text-box').classList.toggle('show') +); + +// Close button +closeBtn.addEventListener('click', () => + document.getElementById('text-box').classList.remove('show') +); + +// Change voice +voicesSelect.addEventListener('change', setVoice); + +// Read text button +readBtn.addEventListener('click', () => { + setTextMessage(textarea.value); + speakText(); +}); + +getVoices(); diff --git a/VoiceGenerator/shanvijha/style.css b/VoiceGenerator/shanvijha/style.css new file mode 100644 index 000000000..0eff2adf3 --- /dev/null +++ b/VoiceGenerator/shanvijha/style.css @@ -0,0 +1,148 @@ +@import url('https://fonts.googleapis.com/css?family=Lato'); + +* { + box-sizing: border-box; +} + +body { + background: #ffefea; + font-family: 'Lato', sans-serif; + min-height: 100vh; + margin: 0; +} + +h1 { + text-align: center; +} + +.container { + margin: auto; + padding: 20px; +} + +.btn { + cursor: pointer; + background-color: darksalmon; + border: 0; + border-radius: 4px; + color: #fff; + font-size: 16px; + padding: 8px; +} + +.btn:active { + transform: scale(0.98); +} + +.btn:focus, +select:focus { + outline: 0; +} + +.btn-toggle { + display: block; + margin: auto; + margin-bottom: 20px; +} + +.text-box { + width: 70%; + position: absolute; + top: 30%; + left: 50%; + transform: translate(-50%, -800px); + background-color: #333; + color: #fff; + padding: 20px; + border-radius: 5px; + transition: all 1s ease-in-out; +} + +.text-box.show { + transform: translate(-50%, 0); +} + +.text-box select { + background-color: darksalmon; + border: 0; + color: #fff; + font-size: 12px; + height: 30px; + width: 100%; +} + +.text-box textarea { + border: 1px #dadada solid; + border-radius: 4px; + font-size: 16px; + padding: 8px; + margin: 15px 0; + width: 100%; + height: 150px; +} + +.text-box .btn { + width: 100%; +} + +.text-box .close { + float: right; + text-align: right; + cursor: pointer; +} + +main { + display: grid; + grid-template-columns: repeat(4, 1fr); + grid-gap: 10px; +} + +.box { + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); + border-radius: 5px; + cursor: pointer; + display: flex; + flex-direction: column; + overflow: hidden; + transition: box-shadow 0.2s ease-out; +} + +.box.active { + box-shadow: 0 0 10px 5px darksalmon; +} + +.box img { + width: 100%; + object-fit: cover; + height: 200px; +} + +.box .info { + background-color: darksalmon; + color: #fff; + font-size: 18px; + letter-spacing: 1px; + text-transform: uppercase; + margin: 0; + padding: 10px; + text-align: center; + height: 100%; +} + +@media (max-width: 1100px) { + main { + grid-template-columns: repeat(3, 1fr); + } +} + +@media (max-width: 760px) { + main { + grid-template-columns: repeat(2, 1fr); + } +} + +@media (max-width: 500px) { + main { + grid-template-columns: 1fr; + } +}