https://realpython.com/playing-and-recording-sound-python/#python-sounddevice_1
import sounddevice as sd
from scipy.io.wavfile import write
fs = 44100 # Sample rate
seconds = 3 # Duration of recording
sd.default.device = 'digital output' # Speakers full name here
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=2)
sd.wait() # Wait until recording is finished
write('output.wav', fs, myrecording) # Save as WAV file
just change the device to your speakers and you should be good to go
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…