惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
小众软件
小众软件
S
SegmentFault 最新的问题
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
C
Check Point Blog
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
罗磊的独立博客
有赞技术团队
有赞技术团队
V
V2EX
Y
Y Combinator Blog
博客园 - 叶小钗
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
F
Fortinet All Blogs
W
WeLiveSecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
S
Security @ Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
Hugging Face - Blog
Hugging Face - Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
PCI Perspectives
PCI Perspectives
H
Heimdal Security Blog
Schneier on Security
Schneier on Security
Security Latest
Security Latest
AWS News Blog
AWS News Blog
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
博客园 - Franky
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
N
News and Events Feed by Topic
Cloudbric
Cloudbric
Scott Helme
Scott Helme
云风的 BLOG
云风的 BLOG
Attack and Defense Labs
Attack and Defense Labs

博客园 - 蜗牛的礼物

Visual Studio Install 2022安装问题 C#使用SHA256withRSA加密对接口进行访问 JsBarcode生成一维码 C#执行存储超时过长,但是数据库执行很快问题 远程服务器无法复制文件上去问题处理 SQLServer数据同步 + Nginx代理自动切换SFTP和Web网站 Html转Text SQLServer数据库邮件异常信息获取 SQLServer分批删除 CMD查询端口被占用并关闭 SQLServer循环生成文件死锁问题 查询数据库表 ASP.NET Core的Web页面调用微信的扫一扫、上传图片等功能 Vue UI创建项目问题 Html5QRCode扫描条形码+二维码+5秒没扫出后截图以文件扫描 JS放大镜 JS根据元素Id截图 Html5QRCode扫描条形码+二维码 JS分隔换行成数组+去重 C#获取邮箱邮件信息+附件下载 C#XML读取
HTML播放语音
蜗牛的礼物 · 2024-11-05 · via 博客园 - 蜗牛的礼物

1.采用有道的接口

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>语音播报</title>
    </head>
    <body>
        <button onclick='voiceBroadcast("微信收款10000000元")'>点击播放</button>
        <button onclick='voiceBroadcast("DTCTS订单号:Order1234567到货,请及时处理!")'>点击播放2</button>
        <script>
        
            function voiceBroadcast(text) {
                new Audio("https://dict.youdao.com/dictvoice?audio="+text+"&le=zh").play();
                //new Audio("https://fanyi.baidu.com/gettts?lan=zh&text="+text+"&spd=5&source=web").play();
            }
            
            /**
             * js默认播报
             * @param {Object} text
             */
            function voiceBroadcast2(text) {
                var utterThis = new SpeechSynthesisUtterance();
                utterThis.volume = 1; // 声音的音量 范围是0到1
                utterThis.lang = 'zh';// 汉语
                utterThis.rate = 0.7; // 语速,数值,默认值是1,范围是0.1到10
                utterThis.pitch = 2; // 音高,数值,范围从0(最小)到2(最大)。默认值为1
                utterThis.text = text;
                speechSynthesis.speak(utterThis);
            }
            
        </script>
    </body>
</html>

2.采用系统的

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Content-Language" content="zh-CN">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <style>
        .center-container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
    </style>
</head>
<body>
<div class="center-container">
    <button onclick="showInputPrompt()">点我后,在弹窗输入文字,然后确认就可以播放了</button>
</div>
<script src="https://cdn.whwsh.cn/js/notification.js"></script>
<script>
    function showInputPrompt() {
        var inputText = prompt("请输入要播放的文字消息", "");
        if (inputText !== null) {
            if (inputText.trim() === "") {
                alert("输入不能为空,请重新输入");
            } else {
                notification.audio.setPlayText(inputText);
                notification.audio.play();
            }
        }
    }
</script>
</body>
</html>

参阅:

https://cloud.tencent.com/developer/article/2390634

https://blog.csdn.net/weixin_43992507/article/details/131830917