在逛gitee的时候,看到一个js工具特别适合我之前做的一个项目里语音播放功能,所以准备替换之前用的百度tts。然后为了方便记录,在这里以一个小工具的形式展示出来。
https://cdn.whwsh.cn/demo2.html
<!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://gitee.com/mail_osc
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有