金蝶软件官网下载网站推广优化排名
最简单的例子,在chrome上亲测有效:
const utterThis = new SpeechSynthesisUtterance('我来试试呀');
const synth = window.speechSynthesis;
synth.speak(utterThis);
加入配置,可以配置语言、音量、语速、音高,继续玩:
const utterThis = new SpeechSynthesisUtterance();
utterThis.text = '我来试试呀';
utterThis.lang = 'zh-CN'; // 语言
// syu.lang = "en-US"; //语言
utterThis.volume = 1; // 音量:0~1,默认1
utterThis.rate = 1; // 语速:0.1~10,默认1
utterThis.pitch = 1; // 音高:0~2,默认1
const synth = window.speechSynthesis;
synth.speak(utterThis);