Skip to content

Commit

Permalink
messages-media: fix waveform import
Browse files Browse the repository at this point in the history
  • Loading branch information
purpshell committed Feb 16, 2025
1 parent b847006 commit aeabecd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Utils/messages-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export async function getAudioDuration(buffer: Buffer | string | Readable) {
*/
export async function getAudioWaveform(buffer: Buffer | string | Readable, logger?: Logger) {
try {
const audioDecode = (buffer: Buffer | ArrayBuffer | Uint8Array) => import('audio-decode').then(({ default: audioDecode }) => audioDecode(buffer))
const { default: decoder } = await eval('import(\'audio-decode\')')
let audioData: Buffer
if(Buffer.isBuffer(buffer)) {
audioData = buffer
Expand All @@ -220,7 +220,7 @@ export async function getAudioWaveform(buffer: Buffer | string | Readable, logge
audioData = await toBuffer(buffer)
}

const audioBuffer = await audioDecode(audioData)
const audioBuffer = await decoder(audioData)

const rawData = audioBuffer.getChannelData(0) // We only need to work with one channel of data
const samples = 64 // Number of samples we want to have in our final data set
Expand Down

0 comments on commit aeabecd

Please sign in to comment.