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?
Related
I am currently working on a project where I need to have a live stream video and a motion detection that when a motion is detected, the raspberry pi records a 10 second video. I have put each functionality in different python files. I am using a single Pi camera. I have also created a file that consists of all the camera functionality so that I don't need to initialize the picamera twice. In the live stream file there is a button that allows the user to activate the motion detection functionality. When the button is clicked an error is shown "Failed to enable connection: Out of Resources"(Note that the live stream is already running.). I just wanted to know if it is possible to run two programs simultaneously using a single pi camera. If it is possible, how? Any help would be appreciated. Thank you in advance.
In general, AFAIK, it is not possible to access a single Raspberry Pi camera simultaneously from 2 separate processes.
I see a couple of possibilities which I'll describe in separate sections.
Use the shell and its tee command, to duplicate your video stream to 2 separate processes like this:
raspivid ... | tee >(MotionDetectionProcess) >(LiveStreamingProcess) > /dev/null
This is a bash "process substitution".
You might use raspividyuv or ffmpeg or some other program, or even one written by yourself, to read the camera and pass the data to stdout.
This approach is very quick to set up and simple - everything just reads or writes its stdin or stdout. On the downside, everything must be started at the same time and things run in "lock-step" with each other.
Run a single video capture process, that simply writes the video frames into multiprocessing shared memory.
Write your other two programs separately, but such that they "attach" to the shared memory and get the frames from there rather than directly from the camera.
This approach is initially a bit harder to program, but things are more decoupled, so you may choose not to bother running motion detection one day, or to start it later or sooner, and your live stream will be unaffected.
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?
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/
I would like to stream the audio of a youtube video in python, youtube-dl allows me to download a video (audio in my case), but that process can take some time. My objective is to be able to stream the audio 'dynamically', like I would by going on a youtube video. I would like to start playing the audio and still download the rest of it at the same time.
I know that the youtube-dl command line program allows to stream videos to media players, like VLC for example:
youtube-dl -o - -- "[videoID]" | vlc -. I could create a subprocess and execute that command, but I would prefer to use a cleaner way, if possible.
I would expect to have some sort of data that I can transmit to an audio device later on. I don't need to store the audio in a file, but it's not a big deal if there is a temporary file.
This is unfortunately not possible. Youtube-DL does not expose an API that makes this straightforward. This is where Youtube-DL opens the file (or stdout) for writing. It's not exactly written to allow for easy switching of the output stream.
It's probably easier to just subprocess it and pipe its output if you really want this functionality.
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