JS插件時(shí) wavesurfer-js 官網(wǎng)
暫時(shí)沒有深入研究颜矿,我目前是為了得到一個(gè)做圖的參考
音頻轉(zhuǎn)為聲波圖形效果
源碼
測(cè)試自己的聲音文件只需要 將 wavesurfer.load('./tts.mp3'); 中的文件改成你自己的。
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/wavesurfer.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="waveform"></div>
<script>
var wavesurfer = WaveSurfer.create({
container: '#waveform',
barWidth: 2,
barHeight: 1.2,
mediaControls: true,
});
wavesurfer.load('./tts.mp3');
wavesurfer.on('ready', function () {
wavesurfer.play();
});
</script>
</body>
</html>