su codigo es el siguiente
lo copean y aguardan con el nombre "voz.hta" no olviden la extensión .hta y aprobar.
Ahora, si lo quieren hacer con la extensión HTML, aquí les dejo su código.
lo copean y aguardan con el nombre "voz.html" y aqui una foto
<html>
<head>
<title>De texto a Voz</title>
</head>
<body>
<marquee>De texto a Voz By Flamer</marquee><br><br>
<center>
Texto:<br><br>
<textarea id="text" name="comentarios" rows="20" cols="50">Hola mundo</textarea><br>
<input type="button" value="Aceptar" onclick="hablar()">
</center>
<script>
function hablar()
{
var voz = new ActiveXObject("SAPI.SpVoice"); //crea un objecto SAPI
var txt = document.getElementById("text").value; //toma el valor del campo de texto text
if(txt=="")
{
alert("Campo de voz vacio");
}
else
{
voz.Speak(txt); //reproduce el texto a voz
}
}
</script>
</body>
</html>
Ahora, si lo quieren hacer con la extensión HTML, aquí les dejo su código.
<html>
<head>
<title>Texto a Voz JavaScript by Flamer</title>
</head>
<body>
<center>
<h2>Conversor de Texto a Voz</h2>
<textarea id="texto" rows="4" cols="30">Hola mundo, esto es una prueba de voz.</textarea>
<br>
<button onclick="hablar()">Hablar</button>
</center>
<script>
function hablar()
{
// 1. Obtener el texto
const texto = document.getElementById("texto").value;
// 2. Crear el objeto de síntesis de voz
const mensaje = new SpeechSynthesisUtterance(texto);
// 3. Configurar idioma y voz
mensaje.lang = 'es-ES'; // Idioma español
mensaje.rate = 1; // Velocidad (0.1 a 10)
mensaje.pitch = 1; // Tono (0 a 2)
// 4. Reproducir
window.speechSynthesis.speak(mensaje);
}
</script>
</body>
</html>
No hay comentarios.:
Publicar un comentario