How to read realtime microphone audio volume in python and ffmpeg or similar
Thanks to @Matthias for the suggestion to use the sounddevice module. It's exactly what I need.
For posterity, here is a working example that prints real-time audio levels to the shell:
# Print out realtime audio volume as ascii bars
import sounddevice as sd
import numpy as np
def print_sound(indata, outdata, frames, time, status):
volume_norm = np.linalg.norm(indata)*10
print ("|" * int(volume_norm))
with sd.Stream(callback=print_sound):
sd.sleep(10000)
How to read realtime microphone audio volume in python and ffmpeg or similar
Thanks to @Matthias for the suggestion to use the sounddevice module. It's exactly what I need.
For posterity, here is a working example that prints real-time audio levels to the shell:
# Print out realtime audio volume as ascii bars
import sounddevice as sd
import numpy as np
def print_sound(indata, outdata, frames, time, status):
volume_norm = np.linalg.norm(indata)*10
print ("|" * int(volume_norm))
with sd.Stream(callback=print_sound):
sd.sleep(10000)
how to read from microphone using C
Read the developer documentation for your operating system. It is impossible to answer in general because the audio APIs are so different on each platform (DirectSound, ASIO, CoreAudio, ALSA, OSS, Jack, ...)
Related Topics
How to Use the Same Python Virtualenv on Both Windows and Linux
Assign Environment Variables from Bash Script to Current Session from Python
Sharing a Result Queue Among Several Processes
How to "Test" Nonetype in Python
How to Find Length of Digits in an Integer
Python, Typeerror: Unhashable Type: 'List'
Binning Data in Python with Scipy/Numpy
Why Does Using 'Arg=None' Fix Python's Mutable Default Argument Issue
Does SQLalchemy Have an Equivalent of Django's Get_Or_Create
The Correct Cmakelists.Txt File to Call a Maxon Libarary in a Python Script Using Pybind11
Why Isn't My Pandas 'Apply' Function Referencing Multiple Columns Working
Error: (-215) !Empty() in Function Detectmultiscale
How to Get a Value of Datetime.Today() in Python That Is "Timezone Aware"