Spaces:
Running
on
T4
Running
on
T4
<script type="module"> | |
import WaveSurfer from 'https://unpkg.com/wavesurfer.js@7/dist/wavesurfer.esm.js' | |
import RegionsPlugin from 'https://unpkg.com/wavesurfer.js@7/dist/plugins/regions.esm.js' | |
var labels=[]; | |
const wavesurfer = WaveSurfer.create({ | |
container: '#waveform', | |
barGap: 2, | |
barHeight: 3, | |
barWidth: 3, | |
barRadius: 2, | |
}); | |
const regions = wavesurfer.registerPlugin(RegionsPlugin.create()) | |
wavesurfer.load('BASE64'); | |
wavesurfer.on('ready', function () { | |
wavesurfer.play(); | |
}); | |
wavesurfer.on('decode', function () { | |
REGIONS | |
wavesurfer.play(); | |
}); | |
wavesurfer.on('click', () => { | |
play(); | |
}); | |
function play(){ | |
wavesurfer.isPlaying() ? wavesurfer.pause() : wavesurfer.play(); | |
} | |
</script> | |
<div id="waveform"></div> | |