Text to Speech Converter
Text to Speech Converter
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.container {
width: 90%;
max-width: 500px;
background-color: white;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 10px;
text-align: center;
}
h1 {
margin-bottom: 20px;
color: #333;
}
textarea {
width: 100%;
height: 100px;
margin: 10px 0;
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ddd;
}
select {
width: 100%;
padding: 10px;
margin: 10px 0;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ddd;
}
button {
padding: 10px 20px;
font-size: 16px;
border: none;
border-radius: 5px;
background-color: #4CAF50;
color: white;
cursor: pointer;
margin-top: 10px;
}
button:hover {
background-color: #45a049;
}
document.addEventListener("DOMContentLoaded", function() {
const voiceSelection = document.getElementById("voiceSelection");
// Populate the voice selection dropdown
responsiveVoice.getVoices().forEach(voice => {
const option = document.createElement("option");
option.value = voice.name;
option.textContent = `${voice.name} (${voice.lang})`;
voiceSelection.appendChild(option);
});
});
function convertTextToSpeech() {
const textInput = document.getElementById("textInput").value;
const selectedVoice = document.getElementById("voiceSelection").value;
if (!textInput.trim()) {
alert("Please enter some text to convert to speech.");
return;
}
if (!selectedVoice) {
alert("Please select a voice.");
return;
}
responsiveVoice.speak(textInput, selectedVoice);
}
No comments:
Post a Comment