一、文字转语音播放(3种实现办法)
https://blog.csdn.net/WhiteEmperor/article/details/92568232
-
1、JS中的语音合成——Speech Synthesis API(实例)
https://blog.csdn.net/cxy__s/article/details/105873691
https://blog.csdn.net/qq_16559905/article/details/78648610
https://www.cnblogs.com/lvxisha/p/9940076.html
具体字段参考:
https://blog.csdn.net/qq_40571631/article/details/89738575
https://blog.csdn.net/qq_32439381/article/details/102740109
vue写法参考:
https://blog.csdn.net/ZJ15981837003/article/details/100522515 -
2、百度——文字转语音开放API(实例)
https://blog.csdn.net/Hferje/article/details/97795446
https://blog.csdn.net/weixin_33736048/article/details/94263514
二、audio
-
1、HTML audio 播放Base64音频流
https://www.jianshu.com/p/6896ade6299b
https://my.oschina.net/u/2002769/blog/855376 -
2、js 多个audio标签,按顺序自动播放
<script type="text/javascript">
var audios = document.getElementsByTagName("audio");
for (var i = 0; i < audios.length; i++) {
// console.log("audios "+i+" SRC:" + audios[i].currentSrc);
audios[i].addEventListener('ended', function() {
// nextSibling 属性返回指定节点之后紧跟的节点,在相同的树层级中。
var nextAudio = this.nextSibling.nextSibling;
// tagName 属性返回元素的标签名。(大写)
if (nextAudio.tagName == "AUDIO") {
nextAudio.play();
}
}, false);
}
</script>
https://blog.csdn.net/diebaiying3731/article/details/102237694
- 3、如何判断audio是否在播放
var audioPlayer = document.querySelector('audio#player');
if (audioPlayer.paused) {
// 暂停中
} else {
// 播放中
}
https://www.zhihu.com/question/24692289
- 4、让audio立马结束重新开始
player.currentTime=0;
https://www.oschina.net/question/273464_49768
音频上传(elementUI)
- 1、上传音频格式限制(类型+大小+时长)
beforeAvatarUpload(file) {
// 文件类型进行判断
const isAudio = file.type === "audio/mp3" || file.type === "audio/mpeg";
// 限制上传文件大小 2M
const isLt2M = file.size / 1024 / 1024 < 2;
const isTime60S = this.audioDuration >= 60 ? true : '';
// 获取时长
this.getTimes(file);
if (!isAudio) {
this.$message.error("上传文件只能是Mp3格式!");
this.fileList = [];
} else {
if (!isLt2M) {
this.$message.error("上传文件大小不能超过 2MB!");
this.fileList = [];
} else {
if (!isTime60S) {
this.$message.error("上传文件时长不能超过60秒!");
this.fileList = [];
}
}
}
return isAudio && isLt2M && isTime60S
},
getTimes(file) {
var content = file;
//获取录音时长
var url = URL.createObjectURL(content);
//经测试,发现audio也可获取视频的时长
var audioElement = new Audio(url);
audioElement.addEventListener("loadedmetadata", (_event) => {
this.audioDuration = parseInt(audioElement.duration);
// console.log(this.audioDuration);
});
},
https://blog.csdn.net/weixin_43915587/article/details/91488764
- 2、ajax实现文件上传, illegal invocation 错误( processData:false)
$.ajax({
url:'backData.php',
data:sendData,
type:'post',
//ajax2.0可以不用设置请求头,但是jq帮我们自动设置了,这样的话需要我们自己取消掉
contentType:false,
//取消帮我们格式化数据,是什么就是什么
processData:false, // *** 解决方案
success:function(backData){
console.log(backData);
}
})
https://blog.csdn.net/qq_42181069/article/details/80333779
- 3、el-upload 在v-for里使用时 如何获取index
外层套一个div,加点击事件,获取循环后的index
https://blog.csdn.net/weixin_34163553/article/details/93212655
- 4、Access to XMLHttpRequest at ‘’rom origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok st...(jquery,ajax传参,post请求报错,跨域问题)
crossDomain: true
网友评论