有没有办法通过javascript编程来改变音频文件的播放速度并将其保存为新文件呢?
我能想到的唯一解决方案是通过Web Audio API节点传输音频文件,改变播放速率,并将输出记录为wav文件。但这不是理想的解决方案,因为我必须播放整个文件才能记录新版本。
我能想到的唯一解决方案是通过Web Audio API节点传输音频文件,改变播放速率,并将输出记录为wav文件。但这不是理想的解决方案,因为我必须播放整个文件才能记录新版本。
//will hold the sped up audio
var spedUpBuffer;
//Create the context
var offlineCtx = new OfflineAudioContext(2,44100*40,44100);//(channels,length,Sample rate);
//create source node and load buffer
var source = offlineCtx.createBufferSource();
source.buffer = yourBuffer;
//speed the playback up
source.playbackRate.value = 1.25;
//lines the audio for rendering
source.start(0);
//renders everything you lined up
offlineCtx.startRendering();
offlineCtx.oncomplete = function(e) {
//copies the rendered buffer into your variable.
spedUpBuffer = e.renderedBuffer;
}