

体验一下 Edge 的朗读功能
source link: https://hsingko.github.io/post/2022/01/10/play-edge-tts/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

体验一下 Edge 的朗读功能
2022-01-10 · 1 分钟 · hsingko
在 Edge 浏览器中打开当前页面,在下面的文本框输入你喜欢的文本,然后点击 Play
试试:
如果一切顺利,那么你的浏览器已经开始朗读了,这个功能的原理是调用了 Edge 内置的 tts 模块,具体的 Javascript API 调用实例可以参考这里 。
简单来说,需要构造一个 SpeechSynthesisUtterance
对象,这个对象里面包装了需要进行朗读的文本,以及指定其他的朗读配置;之后再由 window.speechSynthesis.speak(utterance)
方法开始朗读,下面的 demo 可以供你参考:
var synUtterance = new SpeechSynthesisUtterance("hello, world!");
synUtterance.voice = window.speechSynthesis.getVoices()[9]
synUtterance.lang = 'zh-CN'
synUtterance.volume = 20.0;
synUtterance.rate = 1;
synUtterance.pitch = 1;
const eventList = ["start", "end", "mark", "pause", "resume", "error", "boundary"];
eventList.forEach((event) => {
synUtterance.addEventListener(event, (speechSynthesisEvent) => {
console.log(`Fired '${speechSynthesisEvent.type}' event at time '${speechSynthesisEvent.elapsedTime}' and character '${speechSynthesisEvent.charIndex}'.`);
});
});
window.speechSynthesis.speak(synUtterance);
注意 window.speechSynthesis.getVoices()[9]
这一段, getVoices
方法能获取到多个 Edge 内置的语音引擎,而 [9]
是能朗读中文的晓晓,她应该是目前为止中文 tts 中最接近真人的。当然如果你想要使用其他引擎,也可以自己从中选择。
Recommend
-
105
solidot新版网站常见问题,请点击这里查看。 提交文章 ...
-
12
使用Spvoice.speak语音朗读过程中怎么从指定的位置开始朗读?-CSDN论坛直接用汇编调用COM:用SpVoice朗读一个字符串,内详_15px...可以直接编译过,可以听到声音,其实COM在汇编中...
-
10
心经全文(附广东话和普通话朗读)及译文_生活百味_IT密码观自在菩萨,行深般若波罗蜜多时,照见五蕴皆空,度一切苦厄。舍利子,色不异空,空不异色,色即是空,空即是色,受想行识,亦复如是。舍利子,是诸法空相,不生不灭,不垢不净,不增不减。是故空中无色,...
-
5
使用word朗读功能的方法 2021年9月12日130 word 软件里有个很少有人知道的小功能,虽然不重要,但有时却真的...
-
4
能用已故亲人声音朗读的亚马逊智能助手 Alexa,只需学习不到一分钟的录音 一个孩子对亚马逊的智能语音助手 Alexa 说要听睡前故事《绿野仙踪》,从扬声器中传出的声音却不是语音助手常见的机械音,而...
-
6
V2EX › 程序员 Chrome 有办法调用微软 edge 类似的朗读系统吗?
-
4
CHEGVA让我们面对现实 让我们忠于理想 ...
-
3
最智能AI情感人声朗读软件免费下载:微软语音合成助手 https://www.chenweiliang.com/cwl-29448.html
-
4
Chrome 114 正式发布,带来全新朗读模式 发布日期:2023-05-31 分类:Edge 阅读(30) 评论(0)
-
5
通过 JS 朗读文本内容 朗读文本内容 修改 39~57 行,在 msg.text 中定义朗读内容 本案例针对 Hexo 博客进行优化,自动获取博客正文内容作为朗读内容,在其他场景下请修改 msg.text
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK