Nishyiriyeho inshingano yo kwandika amajwi akora inyandiko mu gishinwa.Iki nikintu cyoroshye cyane niba usanzwe ufite uburambe, ariko mugihe utangiye kubikora guhera, uzakusanya ibibazo byinshi kuburyo icyifuzo gishobora gucika kare cyane.JavaScript ni ururimi rukora cyane, bisa nkaho bifite ibintu byose umutima wawe wifuza.
Reka turebe verisiyo yanyuma ushobora gushira muri DevTools hanyuma ukareba.
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 - nuburyo ururimi rwigishinwa rwagenwe mumara ya mushakisha.Muri gahunda yacu, dushakisha mushakisha amajwi yururimi rwigishinwa, kandi tugerageza kubyara interuro yacu.Ntabwo rwose bitandukanye no kuvuga urundi rurimi.Ariko hano hari uduce tubiri.Gushungura umurongo windimi ziboneka duhura nijwi 2 ryigishinwa zh-CN.Zeru izaba ijwi ryumugore, naho iyambere nijwi ryumugabo.
Umugore
utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[0];
Umugabo
utterance.voice = voices.filter(function(voice) { return voice.lang == 'zh-CN'; })[1];
Mubyongeyeho, gukora amajwi bizatandukana na mushakisha kuri mushakisha no kubikoresho.Mucukumbuzi ya Chrome ifite amajwi yayo bwite, mushakisha ya Edge itandukanye rwose, irashimishije cyane, nukuvuga, kandi mushakisha ya Opera nta majwi namba afite, kuburyo ntamajwi azakora.
Iyi code irashobora kumanikwa kuri buto hanyuma ukavuga ikintu cyawe wenyine.
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);
}
na kode ya buto:
<button onclick="say(1)">👨🔉</button>
Ntakindi kibazo kijyanye no gukina amajwi.Yego yego, burya byose bikora kuri terefone.Yego, bikomeye, cyane cyane muri mushakisha ya mobile ya Edge.By the way, nkurikije iri koranabuhanga, ndagerageza gukora microservice yo kwiga igishinwa, hano ni:
http://jkeks.ru/china .Ibintu byose bishyirwa mubikorwa nkuko nabisobanuye hano.