3

I would like to know if it is possible to record internal audio using a python library, since many of the codes found on the internet and stackoverflow, are related to recording the audio from the microphone and not directly from the speakers (perhaps the soundcard). For example, you are on a Skype call and want to record that call using python (not the microphone input).


I tried to use a library in development called SoundCard, however I get an error.

import soundcard as sc

# get a list of all speakers:
speakers = sc.all_speakers()

# get the current default speaker on your system:
default_speaker = sc.default_speaker()

Traceback:
default_speaker = sc.default_speaker()
AttributeError: partially initialized module 'soundcard' has no attribute 'default_speaker' (most likely due to a circular import)
Y4RD13
  • 937
  • 1
  • 16
  • 42
  • what OS are you on ? and does your machine run pulseaudio ? – Scott Stensland Jul 24 '20 at 11:57
  • @ScottStensland I'm on windows but I want to use this idea on a web app with flask (I guess will no matter the OS) – Y4RD13 Jul 24 '20 at 23:25
  • 1
    do a google search on "Record a program's output with PulseAudio" to point at a python solution which runs fine on linux I can confirm it runs OK on Ubuntu 20.04 ... my biased opinion is any budding software engineer worth their weight in salt should initiate themselves by getting a hand me down old yet working laptop and reformat its drive and install linux just so they can enter into the world of open source in the most unfettered way ... you will thank me later – Scott Stensland Jul 24 '20 at 23:54
  • 1
    @ScottStensland I do have kali linux! I will try it, thank you for your comment Scott. – Y4RD13 Jul 25 '20 at 00:46

1 Answers1

1

I'd recommend checking out pyaudio, I haven't used it to record but it's a great library.

This blog post has details on how to use it to record.

GarAust89
  • 347
  • 1
  • 10
  • I will try to find a solution in there again, because I only found how to record the input mic – Y4RD13 Jul 23 '20 at 23:20
  • Yes, I tried pyaudio, soundcard already and only record the microphone. PulseAudio looks more promising. By the way, I just found these links maybe help me and you in the future to trance again this issue (https://gist.github.com/ramast/c47bd5e57586e9c2deb74975e27089f0#gistcomment-2978444 , https://github.com/jasperproject/jasper-client/blob/master/jasper.py) – ati ince Jun 30 '21 at 10:31