Rakhra Text to Speech Converter Tool
<!DOCTYPE html>
<html>
<head>
<title>Text-to-Speech Converter</title>
<style>
.container {
max-width: 500px;
margin: 0 auto;
padding: 20px;
}
.form-group {
margin-bottom: 10px;
}
.btn {
display: inline-block;
padding: 10px 20px;
background-color: #4CAF50;
color: white;
text-decoration: none;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h1>Text-to-Speech Converter</h1>
<div class="form-group">
<label for="text">Enter Text:</label>
<textarea id="text" rows="4" cols="50"></textarea>
</div>
<div class="form-group">
<button class="btn" onclick="convertTextToSpeech()">Convert to Speech</button>
</div>
<div id="audio-container"></div>
</div>
<script>
function convertTextToSpeech() {
var text = document.getElementById("text").value;
// Create an instance of SpeechSynthesisUtterance
var speech = new SpeechSynthesisUtterance();
// Set the text to be spoken
speech.text = text;
// Use the default voice
speech.voice = speechSynthesis.getVoices()[0];
// Speak the text
speechSynthesis.speak(speech);
// Show audio controls
var audioContainer = document.getElementById("audio-container");
audioContainer.innerHTML = '<audio controls><source src="' + generateAudioUrl(text) + '" type="audio/mpeg"></audio>';
}
function generateAudioUrl(text) {
// Replace spaces and special characters with %20 for the URL
return "https://texttospeech.example.com/api?text=" + encodeURIComponent(text);
}
</script>
</body>
</html>
🎉 BRAND DAYS 🌟 Amazon Basics
– Up to 70% Off
– Last day of sale
– Monitors, tripods and more
👉 Shop Now
Comments
Post a Comment