0

I tried to record audio with this code:

import sounddevice
from scipy.io.wavfile import write
fs = 44100
second = 3
file = sounddevice.rec(int(second * fs), samplerate=fs, channels=2)
sounddevice.wait()
write('output.wav', fs, file)

but it only records output of mic while i want to record system media sound

2 Answers 2

0

Most operating systems do not offer default output as source to record. You need to do use audio routing tools to archive that.

For example, in MacOS, one could install a tool called Soundflower or some later alternatives. Then on OS level, send all output to that soundflower "device" and then you would be able to record those after you select that soundflower device as the source via; https://python-sounddevice.readthedocs.io/en/0.4.5/usage.html#device-selection

On Linux, JACK probably can do the same as MacOS soundflower counterpart. On Windows, no idea...

Sign up to request clarification or add additional context in comments.

Comments

0

sounddevice did not work directly. it needed an intermedite virtual device. I used Voicemeeter https://voicemeeter.com/ After instalation the output of print(sd.query_devices()) will include the Voicemeeter devices.
Setup your machine sound Output to Voicemeeter Input (VB-Audio Voicemeeter VAIO)
In Voicemeeter Click Hardware out and select Speakers. Now in Python you select "Voicemeeter Out" device number (9 on my Windows Desktop)
sound will be routed through voicemeeter, now run your code with sounddevice library

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.