在线语音合成工具代码
- 语音合成软件
- 语音合成助手免费版下载
- 语音合成助手
- 语音合成技术
- 语音合成器
- 语音合成工具下载
- 语音合成软件哪个好用
- 语音合成软件免费版
- 语音合成网易有道智云
语音合成网站
<script>
new Vue({
el: "#app",
data: {
set: {
input: "山有木兮木有枝,心悦君兮君不知。",
rate: 1,
pitch: 1,
voice: 1,
voices: []
},
synth: null
},
created() {
if (window.speechSynthesis === undefined) {
$message.error("该浏览器不支持语音生成,请更换Chrome浏览器后重试");
return;
}
this.synth = window.speechSynthesis;
window.speechSynthesis.onvoiceschanged = e => {
this.set.voices = window.speechSynthesis.getVoices();
this.set.voice = this.set.voices[0].name;
};
},
methods: {
play() {
try {
const utterThis = new SpeechSynthesisUtterance(this.set.input);
this.set.voices.forEach(value => {
if (this.set.voice === value.name) {
utterThis.voice = value;
}
});
utterThis.pitch = this.set.pitch;
utterThis.rate = this.set.rate;
this.synth.cancel();
this.synth.speak(utterThis);
} catch (e) {
$message.error(e);
}
},
reset() {
this.set.input = "";
}
}
});
</script>
还没有评论,来说两句吧...