speak() { const text = this.textInput.value.trim(); if (!text) { this.showNotification('Please enter some text to speak!', 'warning'); return; } // Stop any ongoing speech this.stop(); // Create new utterance this.utterance = new SpeechSynthesisUtterance(text); // Set properties this.utterance.rate = parseFloat(this.rateSlider.value); this.utterance.pitch = parseFloat(this.pitchSlider.value); // Set voice if selected const selectedVoice = this.voiceSelect.value; if (selectedVoice) { const voices = this.synth.getVoices(); const voice = voices.find(v => v.name === selectedVoice); if (voice) this.utterance.voice = voice; } // Event handlers this.utterance.onstart = () => { this.isPlaying = true; this.speakBtn.disabled = true; this.showNotification('🔊 Speaking...', 'info'); }; this.utterance.onend = () => { this.isPlaying = false; this.speakBtn.disabled = false; this.showNotification('✅ Speech completed', 'success'); }; this.utterance.onerror = (event) => { console.error('TTS Error:', event); this.isPlaying = false; this.speakBtn.disabled = false; this.showNotification('Error occurred during speech', 'error'); }; // Speak this.synth.speak(this.utterance); }
textarea { width: 100%; padding: 15px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 16px; font-family: inherit; resize: vertical; transition: border-color 0.3s; }
.preset-btn { background: #f8f9fa; border: 1px solid #e0e0e0; padding: 8px 15px; margin: 5px; border-radius: 20px; cursor: pointer; font-size: 14px; transition: all 0.3s; } eric tts
h1 { color: #667eea; text-align: center; margin-bottom: 10px; font-size: 2.5em; }
.btn:not(.primary) { background: #f0f0f0; color: #333; } speak() { const text = this
@media (max-width: 600px) { .tts-card { padding: 20px; }
.controls { margin: 20px 0; display: grid; gap: 15px; } speak() { const text = this.textInput.value.trim()
input[type="range"] { flex: 1; }