I want to get the internal audio output of the speaker on macOS with python. I got it working on Windows but I can't get it running on macOS. At the beginning we used PyAudio, but I figured that SoundDevice is the better option.
This is the working script for Windows:
import sounddevice as REC
import scipy.io.wavfile
# Recording properties
SAMPLE_RATE = 48000
SECONDS = 10
# Channels
MONO = 1
STEREO = 2
print(REC.query_devices())
# Command to get all devices listed: py -m sounddevice
# Device you want to record
REC.default.device = "PC-Lautsprecher (Realtek HD Audio output with SST)"
print(f'Recording for {SECONDS} seconds')
# Starts recording
recording = REC.rec(int(SECONDS * SAMPLE_RATE), samplerate=SAMPLE_RATE, channels=STEREO)
REC.wait() # Waits for recording to finish
print("done recording")
scipy.io.wavfile.write("test.wav", SAMPLE_RATE, recording,)
Does anyone know a way this running on MacOS (Core Audio)? Are there any other Libraries that would work for MacOS?