Building a virtual microphone using Electron? - python

I'm trying to build a virtual microphone that takes the physical microphone's input stream, modifies the audio using a neural network model written with Python, and replaces the sound stream with my program's output sound stream (in near realtime) so that other apps (e.g. Zoom, Skype, etc.) will receive my app's modified audio stream, for both Mac and Windows.
I've been reading for the last few hours and so far found several libraries that might (?) be able to work here: WebRTC, Soundflower, etc. Does anyone know if there's already a good library that can do or facilitate this? This might be wading into offtopic territory, but if this is doable entirely in Python, e.g. through eel or similar, does anyone know of any library that can do the same type of audio manipulation?
Thank you!

You can create virtual microphone device using official Core Audio APIs

Related

How to recognise a sound ‘peak’ at live system sound?

I want to make a program, which does a specific command when the system’s basic sound plays any type of sound. Like if you receive a message on facebook, you got a little alarm sound. I want to recognise this ‘peak’. How is it possible in python?
< /Hey >
Getting your audio data
I think what you are looking for is someway to loopback the system output so that you can read it as if your OS thinks its an input. There are different ways of doing this (depending on your OS).
However since in the comments you mentioned your OS is Windows 8.1, you can use a fork of PyAudio -> PyAudio_portaudio : Which is the normal PyAudio but extended to use the WASAPI to loopback your windows system output back into something you can retreive in Python.
Please see this other SO post on recording your system output with Python, if I missed anything and thanks to #mate for posting the link to the PyAudio fork.
This is a quick explanation:
The official PyAudio build isn't able to record the output. BUT with
Windows Vista and above, a new API, WASAPI was introduced, which
includes the ability to open a stream to an output device in loopback
mode. In this mode the stream will behave like an input stream, with
the ability to record the outgoing audio stream.
To set the mode, one has to set a special flag
(AUDCLNT_STREAMFLAGS_LOOPBACK,
https://msdn.microsoft.com/de-de/library/windows/desktop/dd316551(v=vs.85).aspx
). Since this flag is not supported in the official build one needs to
edit PortAudio as well as PyAudio, to add loopback support.
New option: "as_loopback":(true|false)
Analyzing your data
This will give you the data block by block (in the block size you specified). From there, you can do whatever DSP / Peak analysis you desire to calculate which sound has been played / has whatever properties.
Here is a quick example to get you started on peak detection in Python. For more accurate results maybe you could store the .wav files you want to recognize and perform cross correlation to see if the same .wav file was played.
Cross correlation 1D Arrays (Mono Audio)
Cross correlation 2D Arrays (Stereo Audio)

How can I analyze sound output in Python?

Is it possible to get the system output audio (the exact same thing that goes through the speakers) and analyze it in real time with Python? My intention is to build a sound visualizer. I know that it is possible to access the microphone with pyaudio, but I was not able to access the sound card output in any way, I'm looking for a solution that works on Windows.
Thank you for reading.
Not sure how this project is doing these days, it's been a long time since it's been updated. PyVST allows you to run python code in a VST inside a VST host, which makes it possible to handle realtime audio events.
You might want to look at http://code.google.com/p/pyo/ for some ideas about how to handle DSP data as well.

Cross-platform audio import from different sources

I am using Python, and I want to analyze audio files from internet streaming media (for example Youtube, Soundcloud, etc.)
Is there a universal way to do so? There is a pre-loading for every music or video, there must be a way to access it? How?
I want to run this script on an external server, that might be relevant to the answer.
Thanks
All sound you "hear" on your pc has to run through your soundcard, Maybe somehow write a script that "records" the sounds runnning through the device. Maybe u can use Pymedia module?

Can Gstreamer be used server-side to stream audio to multiple clients on demand?

I'm working on an audio mixing program (DAW) web app, and considering using Python and Python Gstreamer for the backend. I understand that I can contain the audio tracks of a single music project in a gst.Pipeline bin, but playback also appears to be controlled by this Pipeline.
Is it possible to create several "views" into the Pipeline representing the project? So that more than one client can grab an audio stream of this Pipeline at will, with the ability to do time seek?
If there is a better platform/library out there to use, I'd appreciate advice on that too. I'd prefer sticking to Python though, because my team members are already researching Python for other parts of this project.
Thanks very much!
You might want to look at Flumotion (www.flumotion.org). It is a python based streaming server using GStreamer, you might be able to get implementation ideas from that in terms of how you do your application. It relies heavily on the python library Twisted for its network handling.

Convert shoutcast stream to playable samples in Python?

I have a shoutcat radio station and now want to build a player for it. I know how to "get" thet stream from the server, thanks a lot to bobince , but I am not sure how to convert that stream into playable samples. How is it done?
Shoutcast streams are typically (but not always) MP3. To get playable samples, you have to decode the stream's MP3 data.
Have you seen the resource at http://codeboje.de/playing-mp3-stream-python/? Looks like a simple solution, but requires an awful lot of libraries.
There are quite a few possibilities for MP3 decoding under Python. PyMedia is one I've had some success with in the past (but for which development seems to have stopped). It's not just an MP3 decoder though, but a playback interface with support for many audio and video formats via ffmpeg. There's also pyffmpeg which seems to have come back to life recently (haven't tried it yet).
Then there's PyGame can also play MP3, though this is a pretty small part of what it does. pymad is more lightweight possibility, being a direct interface to the libmad decoder library. And then there's always the possibility of handing the task off to an external multimedia library such as DirectShow, or GStreamer (via gst-python)...
Well, from what I can read on python, try this page. If that doesn't work, try the PythonInMusic article on the python wiki.

Categories

Resources