File tree 1 file changed +2
-2
lines changed
src/components/MediaRecorder/transcode
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change 1
- import { Mp3Encoder } from '@breezystack/lamejs' ;
2
1
import { renderAudio , toAudioBuffer } from './audioProcessing' ;
3
2
4
3
const ENCODING_BIT_RATE = 128 ; // kbps;
@@ -22,10 +21,11 @@ const splitDataByChannel = (audioBuffer: AudioBuffer) =>
22
21
) ;
23
22
24
23
export async function encodeToMp3 ( file : File , sampleRate : number ) {
24
+ const lameJs = await import ( '@breezystack/lamejs' ) ;
25
25
const audioBuffer = await renderAudio ( await toAudioBuffer ( file ) , sampleRate ) ;
26
26
const channelCount = audioBuffer . numberOfChannels ;
27
27
const dataByChannel = splitDataByChannel ( audioBuffer ) ;
28
- const mp3Encoder = new Mp3Encoder ( channelCount , sampleRate , ENCODING_BIT_RATE ) ;
28
+ const mp3Encoder = new lameJs . Mp3Encoder ( channelCount , sampleRate , ENCODING_BIT_RATE ) ;
29
29
30
30
const dataBuffer : Int8Array [ ] = [ ] ;
31
31
let remaining = dataByChannel [ 0 ] . length ;
You can’t perform that action at this time.
0 commit comments