How can I record audio in Python? - python

I'm wondering if there are libraries in Python for audio recording.
Ideally, I need to get a cross-platform solution, how can I record audio through Python.
Ideally, in order that in this library I can either pause with the ability to listen to the recorded fragment and remove it from the audio recording, or record several audio files and after the program work, glue it into 1 audio file.
If someone knows such a decision, I will be happy to receive help.
Thanks in advance!

I would look into python-sounddevice.
https://python-sounddevice.readthedocs.io/en/0.3.11/
It can record and play as well as convert your music into a numpy array if that every interested you. It is a python handler of the PortAudio which is cross-platform.
http://portaudio.com

Related

How do I record PC audio output without using any external program?

I'm trying to making a screen recorder program, and I also want to record the audio output.
I found a few other questions which had the same problem as mine, and the solutions were either outdated or they didn't work on my current computer.
Most solutions I found used VB-AUDIO cable to loopback audio, but I don't want my program to rely on other applications for it to function.
Is there any library I can use which has a proper loopback function that can be used to record and save computer audio output?

Detect audio coming from microphone

Ive seen other questions similar to this, but they all involve detecting audio and then recording. I'd like my microphone connected to my computer to always be recording, and any time audio is detected it runs another part of a script. What modules would I need? How would I do this? Im pretty sure this would involve seeing when the audio volume goes above a certain point and then activating the rest of the script, because obviously there will always be some sort of sound coming from the microphone.
This might help if you want them to say something and then if they say the right word or whatever run the script.
https://pypi.org/project/SpeechRecognition/

push-to-listen-into-the-past with pyaudio

Essentially, what I want to achieve is upon triggering, the previous two seconds and further audio should be recorded, until silence.
For this, of course, the microphone has to listen all the time and record to a circular buffer. Upon triggering, current audio shall be recorded until there is a long enough span of silence. In the end, both streams should be combined to a single audio file/stream.
Unfortunately, I can't seem to wrap my head around how to achieve this with pyaudio.
I would be great if you had some advice for me.

How to record signal from soundcard in python

I want to process the audio data from sound card (i.e. USB external sound card). For example: I can record all sound while playing a Youtube clip along with PC game. However, I have tried Pyaudio which only allows me to record audio from microphone. Can someone suggest me any library to try? Thanks so much!

Python audio streaming between two computers

I want to create a "Skype" like program that records audio from one computers and streams it live to another (just like a voice conversation) yet i can't find the right way to do it
(I also don't want any saved audio files, i want it to stream the audio without saving a file to the computer).
Any ideas about which module is right for this task and how should i do it?

Categories