Open
Description
I want to check is I am playing any audio on my PC(music, podcasts, from video, etc).
Here is the script for it:
import sounddevice as sd
import numpy as np
duration = 10
fs = 44100
myrecording = sd.rec(int(duration*fs), samplerate=fs, channels=2)
print(np.count_nonzero(myrecording > 0))
Currently my assumption is that if no audio is playing, then all elements of numpy array will be <=0
. Is this correct?
This code is also listening in on the microphone, whilst I strictly want to record audio being played directly from the PC. Is it possible to only check for that?