js 语音读取txt文章内容

编程入门 行业动态 更新时间:2024-10-06 12:28:44

js  语音读取txt<a href=https://www.elefans.com/category/jswz/34/1750818.html style=文章内容"/>

js 语音读取txt文章内容

h5的speechSynthesis可以用来做一个语音播报txt文章,测试了在chrome,中文也可以,火狐只能英语,看网上的说可以设置什么语音


<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title></title>
</head><body><button onclick="speak();">在线听故事</button><button onclick="zhanting();">暂停</button><button onclick="stop();">停止</button><button onclick="comon();">继续</button><!-- <div id="txt" style="visibility:hidden; "> --><div id="txt">You are Absolutely UniqueEnjoy that uniquenesss1. You do not have to pretend in order to seem more like someone else. You do not have tolie to hide the parts of you that are not like what you see in anyone else.You were meant to be different. Nowhere, in all of history, will the same things be going on in anyone’s mind,soul and spirit as are going on in yours right now.If you did not exist, there would be a hole in creation, a gap2 in history, and something missing from the planfor humankind. Treasure your uniqueness. It is a gift given only to you. Enjoy it and share it!No one can reach out to others in the same way that you can. No one can speak your words. No one can convey yourmeanings. No one can comfort others with your kind of comfort. No one can bring your kind of understanding toanother person. No one can be cheerful and light-hearted3 and joyous4 in your way. No one can smile your smile.No one else can bring the whole unique impact of you to another human being.Share your uniqueness. Let it flow out freely among your family and friends, and the people you meet in the rushand clutter of living, wherever you are. That gift of yourself was given to you to enjoy and share. Giveyourself away!See it! Receive it!Let it inform you, move you and inspire you!You are unique!</div><script src=".1.1.min.js"></script><script>var mess = $("#txt").text()function zhanting(mess) {// body...window.speechSynthesis.pause(mess);}function stop(mess) {// body...window.speechSynthesis.cancel(mess);}function comon(mess) {// body...window.speechSynthesis.resume(mess);}function speak(mess) {var mess = $("#txt").text()var msg = new SpeechSynthesisUtterance(mess)msg.volume = 100  // 声音的音量msg.rate = 1 // 语速,数值,默认值是1,范围是0.1到10msg.pitch = 1.5 // 表示说话的音高,数值,范围从0(最小)到2(最大)。默认值为1speechSynthesis.speak(msg);}</script></body></html>

更多推荐

js 语音读取txt文章内容

本文发布于:2024-02-28 07:10:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1769090.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文章内容   语音   js   txt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!