Search code examples
javascriptdiscorddiscord.js

Discord.js - Is there a way to check a decibels level in a discord call?


I want to make a bot that plays audios depending on the amount of decibels people are making on the call, any idea if it's possible or how to do this with discord.js?


Solution

  • I have tried this in the past.

    None of my solutions worked after tens of hours of research and testing, but it might work for you if you have more time/knowledge. Here's what I tried if you want a starting point:

    1. Decoding the audio bitstream into raw pcm, and reading the buffer to find the amplitude (little-endian vs big-endian is important).

    2. Piping the stream into ffmpeg and using a filter like ebur128 to get the audio level (using encoded and decoded audio, when I tried this, it was able to distinguish between whispering and talking, but not talking and yelling).

    Good luck if you choose to pursue this.