test
Home
/
Store
$0.00
Quantity:
1
Add More
Add to Cart
Go to Checkout
Save this product for later
Favorite
Favorited
View Favorites
Customer reviews
Reviews only from verified customers
No reviews yet. You can buy this product and be the first to leave a review.
Share this product with your friends
Share
Share
Pin it
test
Home
/
Store
Product Details
Text to Speech Generator
-removed
Text to Speech Generator
Enter your text below and click "Generate Audio" to hear it in my voice!
0
/ 5000 characters
Generate Audio
Generating...
// Character counter const textInput = document.getElementById('textInput'); const charCount = document.getElementById('charCount'); textInput.addEventListener('input', () => { charCount.textContent = textInput.value.length; }); async function generateAudio() { const text = textInput.value.trim(); const generateBtn = document.getElementById('generateBtn'); const loading = document.getElementById('loading'); const error = document.getElementById('error'); const audioPlayer = document.getElementById('audioPlayer'); // Reset error state error.style.display = 'none'; error.textContent = ''; // Validate input if (!text) { error.textContent = 'Please enter some text'; error.style.display = 'block'; return; } // Show loading state generateBtn.disabled = true; loading.style.display = 'inline'; try { // Call your backend API const response = await fetch('/api/generate-audio', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text }) }); if (!response.ok) { throw new Error('Failed to generate audio'); } // Get audio blob const audioBlob = await response.blob(); // Create URL for audio playback const audioUrl = URL.createObjectURL(audioBlob); // Set up audio player audioPlayer.src = audioUrl; audioPlayer.style.display = 'block'; audioPlayer.play(); // Optional: Add download button addDownloadButton(audioBlob); } catch (err) { error.textContent = 'Error generating audio. Please try again.'; error.style.display = 'block'; console.error('Error:', err); } finally { generateBtn.disabled = false; loading.style.display = 'none'; } } function addDownloadButton(audioBlob) { // Remove existing download button if any const existingBtn = document.getElementById('downloadBtn'); if (existingBtn) { existingBtn.remove(); } // Create download button const downloadBtn = document.createElement('button'); downloadBtn.id = 'downloadBtn'; downloadBtn.textContent = 'Download Audio'; downloadBtn.style.marginLeft = '10px'; downloadBtn.onclick-removed = () => { const url = URL.createObjectURL(audioBlob); const a = document.createElement('a'); a.href = url; a.download = 'generated-audio.mp3'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }; document.querySelector('.controls').appendChild(downloadBtn); }
Show More
Skip to main content
HOME
STORE
FAQ
CONTACT US
Privacy policy
My account
Search
Cart
Menu