Nyeem ntawv ua lus Suav

Kuv tsa kuv tus kheej ua haujlwm ntawm kev sau lub suab ua cov ntawv nyeem hauv Suav.Qhov no yog qhov teeb meem yooj yim yog tias koj twb muaj kev paub dhau los, tab sis thaum koj pib ua nws los ntawm kos, koj yuav sau ntau yam teeb meem uas qhov kev ntshaw yuav ploj mus ntau dhau los.JavaScript yog ib hom lus ua haujlwm heev, zoo li muaj txhua yam koj lub siab xav.

Cia wb mus saib qhov kawg version uas koj tuaj yeem muab tso rau hauv DevTools thiab xyuas nws.

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 - qhov no yog li cas cov lus Suav raug xaiv nyob rau hauv lub plab ntawm tus browser.Hauv peb qhov kev pab cuam, peb tshawb nrhiav qhov browser rau lub suab ntawm cov lus Suav, thiab sim rov tsim peb cov kab lus.Nws yog xyaum tsis txawv ntawm lub suab lwm yam lus.Tab sis muaj ob peb nuances ntawm no.Lim cov array ntawm cov lus muaj peb tuaj hla 2 Suav zh-CN suab.Zero yuav yog poj niam lub suab, thiab thawj yog txiv neej lub suab.

Poj niam

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

Txiv neej

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

Tsis tas li ntawd, lub suab ua yeeb yam yuav txawv ntawm qhov browser mus rau browser thiab los ntawm ntaus ntawv mus rau lub cuab yeej.Lub Chrome browser muaj nws tus kheej lub suab, Edge browser muaj qhov sib txawv kiag li, ntau qab ntxiag, los ntawm txoj kev, thiab Opera browser tsis muaj suab txhua, yog li yuav tsis muaj lub suab ua yeeb yam.

Cov cai no tuaj yeem dai ntawm lub pob thiab lub suab qee yam ntawm koj tus kheej.

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);
}

thiab khawm code:

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

Tsis muaj lwm yam teeb meem nrog lub suab ua yeeb yam.Yog lawm, nws ua haujlwm li cas ntawm smartphones.Yog, zoo heev, tshwj xeeb tshaj yog nyob rau hauv mobile Edge browser.Los ntawm txoj kev, raws li cov thev naus laus zis no, kuv tab tom sim ua microservice rau kev kawm Suav, ntawm no nws yog:

http://jkeks.ru/china .Txhua yam yog siv raws nraim li kuv tau piav qhia ntawm no.





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