Merhaba JS ücretsiz speech synthesis kullanarak bir metni seslendirtiyorum. Metin ingilizce olmasına rağmen telaffuzda hello , hav can yu diyerek türkçe okuyor metni bunu nasıl çözebilirim?
// Function to speak a message
function speakText(text, lang = 'en-US') {
if ('speechSynthesis' in window) {
const utterance = new SpeechSynthesisUtterance(text);
utterance.lang = lang;
window.speechSynthesis.speak(utterance);
} else {
console.warn('SpeechSynthesis API not supported in this browser.');
}
}
Javascript Destek
5
●116
- 07-01-2025, 00:14:00
function speakText(text, lang = 'en-US') { if ('speechSynthesis' in window) { const utterance = new SpeechSynthesisUtterance(text); utterance.lang = lang; // Mevcut sesleri al const voices = window.speechSynthesis.getVoices(); // İngilizce ses seç (Microsoft David, Google US English gibi) const englishVoice = voices.find(voice => voice.lang.includes('en') && voice.name.includes('English') ); if (englishVoice) { utterance.voice = englishVoice; } // Konuşma hızı ve tonu ayarla utterance.rate = 1.0; // Normal hız utterance.pitch = 1.0; // Normal ton window.speechSynthesis.speak(utterance); } else { console.warn('SpeechSynthesis API not supported in this browser.'); } }denermisin - 07-01-2025, 00:17:10maalesef hala aynı hocam hav can yu diyerek devam ediyor ingilizce telaffuzda daMSK adlı üyeden alıntı: mesajı görüntüle
- 07-01-2025, 00:28:55yapay zeka çözebilir -claude 3.5brkctk adlı üyeden alıntı: mesajı görüntüle
- 07-01-2025, 13:41:47claude bunu verdi
function speakText(text, lang = 'en-US') { // Browser desteğini kontrol et if ('speechSynthesis' in window) { // Mevcut sesleri al const voices = window.speechSynthesis.getVoices(); // Yeni bir konuşma nesnesi oluştur const utterance = new SpeechSynthesisUtterance(text); // Dil ayarını yap utterance.lang = lang; // İngilizce ses bul const englishVoice = voices.find(voice => voice.lang.includes('en') && !voice.lang.includes('tr') && voice.localService === true ); // Eğer uygun İngilizce ses bulunduysa kullan if (englishVoice) { utterance.voice = englishVoice; } // Hız ve perde ayarları (isteğe bağlı) utterance.rate = 1.0; // Normal hız utterance.pitch = 1.0; // Normal perde // Konuşmayı başlat window.speechSynthesis.speak(utterance); // Hata durumunda utterance.onerror = (event) => { console.error('Konuşma hatası:', event.error); }; // Konuşma bittiğinde utterance.onend = (event) => { console.log('Konuşma tamamlandı'); }; } else { console.warn('SpeechSynthesis API bu tarayıcıda desteklenmiyor.'); } } // Kullanım örneği: // speakText("Hello, how are you today?", "en-US"); // Tüm mevcut sesleri listelemek için: function listAvailableVoices() { const voices = window.speechSynthesis.getVoices(); voices.forEach(voice => { console.log(`Ses: ${voice.name}, Dil: ${voice.lang}, Local: ${voice.localService}`); }); } // Seslerin yüklenmesini bekle ve listele speechSynthesis.onvoiceschanged = listAvailableVoices;