#Waveforms to Voice Message
14 messages · Page 1 of 1 (latest)
Convert Into opus Format
could you please provide me an example?
const ffmpeg = require('fluent-ffmpeg'); const inputFile = path/to/file.wave; outputFile = filename.opus`;
async function convert(message){
ffmpeg(inputFile)
.toFormat('opus')
.audioCodec('libopus')
.on('error', (err) => {
console.error(err);
})
.on('end', async () => {
const stats = fs.statSync(outputFile);
const fileSizeInBytes = stats.size;
const fileSizeInMegabytes = fileSizeInBytes / (1024 * 1024);
if (fileSizeInMegabytes <= 16) {
const media = MessageMedia.fromFilePath(outputFile);
await message.reply(media, null, { sendAudioAsVoice: true });
fs.unlinkSync(outputFile);
} else {
await message.reply('File's Too Large');
fs.unlinkSync(outputFile);
}
fs.unlinkSync(filePath);
})
.save(outputFile);
}`
nonono, i dont think u got the point that im saying. so whenever someone send me a voice message, i get the following numbers in the console:
"waveform":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0
and i want to get the original audio file which i can listen to from this numbers
(the example is just me recording nothing in a quiet room)
@abstract jungle
The WaveForm is not the audio data..., its the waveform data (the little lines that appear on audio voices)
You need to download the audio file using message.downloadMedia()
How to download and upload files
oh alright, and how do i send the "media" file to another chat?
in the docs, it only has how to send media files locally or throug hURL
If you downloaded the media you just send it to another chat
const downloadedMedia = await message.downloadMedia();
await client.sendMessage(number, downloadedMedia):