< !
DOCTYPE html>
<html lang= »fr »>
<head>
<meta charset= »UTF-8 »>
<meta name= »viewport » content= »width=device-width, initial-
scale=1.0 »>
<title>Lire un texte avec une voix d’homme</title>
</head>
<body>
<h1>Lire un texte avec une voix d’homme</h1>
<textarea id= »text-to-read » rows= »10 » cols= »50 »
placeholder= »Tapez votre texte ici… »></textarea><br>
<button onclick= »readText() »>Lire le texte</button>
<script>
Let voices = [] ;
// Fonction pour récupérer les voix disponibles
Function loadVoices() {
Voices = [Link]() ;
// Appel à la fonction pour charger les voix lorsque les voix sont
disponibles
[Link] = loadVoices ;
function readText() {
const text = [Link](‘text-to-read’).value ;
if (text) {
const utterance = new SpeechSynthesisUtterance(text) ;
// Sélectionner une voix masculine
For (let i = 0 ; i < [Link] ; i++) {
If (voices[i].[Link](‘Male’)) { // Recherche d’une voix
masculine
[Link] = voices[i] ;
Break ;
[Link](utterance) ;
} else {
Alert(‘Veuillez entrer un texte à lire.’) ;
</script>
</body>
</html>