I want to get the current system volume, not the one that is set by the user, but the one that is actively happening, for example if I am speaking to someone in a discord chat, and he's talking quietly it will show me 10%, but if he's talking loudly, it will jump to 80. I searched everywhere but all I get is using the microphone, and I want the sounds from the system, what can I do to get it?
Asked
Active
Viewed 1,506 times
2
-
https://stackoverflow.com/questions/40138031/how-to-read-realtime-microphone-audio-volume-in-python-and-ffmpeg-or-similar – Jairus Jan 04 '21 at 14:44
-
@JairusMartin this, but with nodeJS... – neryushi Jan 04 '21 at 15:52
-
1Nodejs can run scripts, i.e. have it run a python script as a command. – Jairus Jan 04 '21 at 16:17
-
In node you can run command line commands, from command-line it should not be a problem to get real time audio. – Aalexander Jan 04 '21 at 16:29
-
@Alex and how would you do that? – neryushi Jan 04 '21 at 17:11
-
@neryushi you are on windows right? I can not test it but to pass commands you can do the following `var exec = require('child_process').exec; exec('ls -al', function (error, stdOut, stdErr) { console.log(stdOut) });` Would print in an unix enviroment the list of files in the directory In Linux you could do now something like this instead of ls-al you can write `awk -F"[][]" '/dB/ { print $2 }' <(amixer sget Master) ?` Referencing this answer https://unix.stackexchange.com/questions/89571/how-to-get-volume-level-from-the-command-line – Aalexander Jan 04 '21 at 17:17
-
For Windows I found this https://learn.microsoft.com/en-us/previous-versions//ms678715(v=vs.85)?redirectedfrom=MSDN or here is a Command Line Tool : https://sourceforge.net/projects/mplayer-edl/files/current_system_volume_vista_plus_flush.exe/download But maybe if this python script is exactly what you need it would be the best as @JairusMartin mentioned to run that python script in your node enviroment and get the output from that. – Aalexander Jan 04 '21 at 17:25
1 Answers
0
You could try the package win-audio:
const audio = require('win-audio');
// speaker volume
const speaker = audio.speaker;
// get the current volume percentage
var currentVolume = speaker.get();
// microphone volume
const microphone = audio.mic;

Aalexander
- 4,987
- 3
- 11
- 34

user13249425
- 46
- 5
-
This is not what the question asked for, I asked for how to get the actual volume that is being played by your computer. The green from the photo – neryushi Jan 04 '21 at 15:51