Ndizibekele umsebenzi wokubhala ilizwi elisebenza kwisicatshulwa ngesiTshayina.Lo ngumcimbi olula ngokufanelekileyo ukuba sele unamava, kodwa xa uqala ukuyenza ukusuka ekuqaleni, uya kuqokelela iingxaki ezininzi kangangokuba umnqweno unokunyamalala kwangaphambili.IJavaScript lulwimi olusebenza kakhulu, lubonakala lunayo yonke into enqwenelwa yintliziyo yakho.
Makhe sijonge inguqulelo yokugqibela onokuthi uyincamathelise kwi-DevTools kwaye uyijonge.
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 - yile ndlela ulwimi lwesiTshayina luchongwe ngayo emathunjini esiphequluli.Kwinkqubo yethu, sikhangela isikhangeli selizwi lolwimi lwesiTshayina, kwaye sizame ukuvelisa kwakhona ibinzana lethu.Akwahlukanga ekubizeni naluphi na olunye ulwimi.Kodwa kukho ii-nuances ezimbalwa apha.Ukucoca uluhlu lweelwimi ezikhoyo sidibana namazwi ama-2 aseTshayina e-zh-CN.U-Zero uya kuba lilizwi lomfazi, kwaye elokuqala lilizwi lendoda.
Owasetyhini
utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[0];
Indoda
utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[1];
Ukongeza, ukusebenza kwelizwi kuya kwahluka ukusuka kwisikhangeli ukuya kwisikhangeli kunye nakwisixhobo ukuya kwesinye.Isiphequluli se-Chrome sinamazwi aso, isiphequluli se-Edge sihluke ngokupheleleyo, sithandeka ngakumbi, ngendlela, kwaye isiphequluli se-Opera asinawo amazwi, ngoko akuyi kuba nezwi elisebenzayo.
Le khowudi inokuxhonywa kwiqhosha kwaye uthethe into yakho.
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);
}
kunye nekhowudi yeqhosha:
<button onclick="say(1)">👨🔉</button>
Azikho ezinye iingxaki ngokusebenza kwelizwi.Ewe, yonke into isebenza njani kwii-smartphones.Ewe, kuhle, ngakumbi kwi-browser ye-Edge yeselula.Ngendlela, ngokusekwe kobu buchwepheshe, ndizama ukwenza i-microservice yokufunda isiTshayina, nantsi:
http://jkeks.ru/china .Yonke into iphunyezwa kanye njengoko ndichaze apha.