Leer texto en chino



Me di a la tarea de escribir la actuación de voz del texto en chino.Este es un asunto bastante sencillo si ya tienes experiencia, pero cuando empieces a hacerlo desde cero, acumularás tantos problemas que las ganas pueden desaparecer mucho antes.JavaScript es un lenguaje muy funcional, parece tener todo lo que tu corazón desea.

Echemos un vistazo a la versión final que puede pegar en DevTools y compruébelo.

var utterance = new SpeechSynthesisUtterance('菜');
var voices = window.speechSynthesis.getVoices();
utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[0];
window.speechSynthesis.speak(utterance);

zh-CN: así es como se designa el idioma chino en las entrañas del navegador.En nuestro programa, buscamos en el navegador la voz del idioma chino e intentamos reproducir nuestra frase.Prácticamente no es diferente de expresar cualquier otro idioma.Pero hay un par de matices aquí.Al filtrar la variedad de idiomas disponibles, nos encontramos con 2 voces chinas zh-CN.Zero será una voz femenina, y la primera es una voz masculina.

Mujer

utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[0];

Masculino

utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[1];

Además, la actuación de voz diferirá de un navegador a otro y de un dispositivo a otro.El navegador Chrome tiene sus propias voces, el navegador Edge tiene otras completamente diferentes y más agradables, por cierto, y el navegador Opera no tiene ninguna voz, por lo que no habrá actuación de voz.

Este código se puede colgar en el botón y expresar algo propio.

function say(voiceId){
    let text = document.getElementById("pole").innerHTML
    console.log (text)
    var utterance = new SpeechSynthesisUtterance(text);
    var voices = window.speechSynthesis.getVoices();
    utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[voiceId];
    window.speechSynthesis.speak(utterance);
}

y código del botón:

<button onclick="say(1)">👨🔉</button>

No hay otros problemas con la actuación de voz.Oh, sí, cómo funciona todo en los teléfonos inteligentes.Sí, genial, especialmente en el navegador móvil Edge.Por cierto, basado en esta tecnología, estoy tratando de hacer un microservicio para aprender chino, aquí está:

http://jkeks.ru/china .Todo se implementa exactamente como lo describí aquí.





bg bs ca ceb co cs cy da de el en eo es et fa fi fr fy ga gd gl gu ha haw hi hmn hr ht hu id ig is it iw ja jw ka kk km kn ko ku ky la lb lo lt lv mg mi mk ml mn mr ms mt my ne nl no ny or pa pl ps pt ro ru rw sd si sk sl sm sn so sr st su sv sw ta te tg th tk tl tr tt ug uk ur uz vi xh yi yo zh zu
Text to speech
QR-Code generator
Parsedown cheatsheet. Markdown
Filter data by column with regular expressions
Engines for creating games on LUA ?
JavaScript: draw a point
JavaScript: Speaking text in Chinese