#290: Record Audio With PyAudio - Python Friday

None

Today's minor software victory involves arm-wrestling with the portaudio wrapper for Python.

The hotplug branch (referenced in https://github.com/PortAudio/portaudio/wiki/HotPlug) of the C level portaudio code seems to be a dead-end, so that's a bumner.

Experimentally I observed that calling terminate() twice on the PyAudio() object gets me a fresh list without restarting the program (a TUI) even though, as far as I can tell, I only call open() once. Some ref-count bug?

I'll take the win πŸ”Š

#Python #PyAudio #PortAudio

HotPlug

PortAudio is a cross-platform, open-source C language library for real-time audio input and output. - PortAudio/portaudio

GitHub
Writing your own #audio analyzer using pyaudio-analysis https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0144610
(possibly in combination with #pyaudio)
#python #audioanalysis
pyAudioAnalysis: An Open-Source Python Library for Audio Signal Analysis

Audio information plays a rather important role in the increasing digital content that is available today, resulting in a need for methodologies that automatically analyze such content: audio event recognition for home automations and surveillance systems, speech recognition, music information retrieval, multimodal analysis (e.g. audio-visual analysis of online videos for content-based recommendation), etc. This paper presents pyAudioAnalysis, an open-source Python library that provides a wide range of audio analysis procedures including: feature extraction, classification of audio signals, supervised and unsupervised segmentation and content visualization. pyAudioAnalysis is licensed under the Apache License and is available at GitHub (https://github.com/tyiannak/pyAudioAnalysis/). Here we present the theoretical background behind the wide range of the implemented methodologies, along with evaluation metrics for some of the methods. pyAudioAnalysis has been already used in several audio analysis research applications: smart-home functionalities through audio event detection, speech emotion recognition, depression classification based on audio-visual features, music segmentation, multimodal content-based movie recommendation and health applications (e.g. monitoring eating habits). The feedback provided from all these particular audio applications has led to practical enhancement of the library.

Both PyAudio and SoundDevice are Python libraries for audio input and output. What makes them different?

PyAudio provides direct bindings to the PortAudio library, giving you more control over audio parameters and access to lower-level functionality.

SoundDevice offers a simpler, more Pythonic interface that works seamlessly with NumPy arrays, making it convenient for processing audio data. SoundDevice is also actively maintained.

#python #pyaudio #sounddevice #NumPy

I spent a few hours on New Years Eve trying to listen to my USB microphone using Python3, PyQt5 and pyAudio. I can play WAV files using pyAudio, but fetching my microphone is becoming a bit challenging.

Lets see if I can get this working New Years Day. Time to read the documentation.
https://people.csail.mit.edu/hubert/pyaudio/docs/

#Linux #python #python3 #pyqt #pyqt5 #pyaudio #portaudio #USB #USB3 #microphone #WAV

PyAudio Documentation β€” PyAudio 0.2.14 documentation

I have created this discussion at the #py5 forum... To collect #PyAudio or other audio examples, If anyone else wants to post other experiments...

https://github.com/py5coding/py5generator/discussions/282

wink wink @kantel @TomLarrow @ericof @rzeta0
#Python #CreativeCoding

Audio for py5 Β· py5coding/py5generator Β· Discussion #282

I'm starting to read this: https://k3no.medium.com/integrating-pyaudio-pysimplegui-5fa342b1e113 It looks very promising. Despite my terrible mental model about anything sound-stream-like (so I have...

GitHub
Tomorrow or maybe during the week I should read this tutorial mixing #Python #PyAudio and #PySimpleGUI ... https://k3no.medium.com/integrating-pyaudio-pysimplegui-5fa342b1e113
Integrating PyAudio & PySimpleGUI - Keno Leon - Medium

As part of my research on Signal Processing and AI, I wanted to visually represent real time audio data from my microphone, this simple request turned out to be not so simple at all for a number of…

Medium
As usual, I have no idea of what I'm doing πŸ˜‚β€‹ #Python #Processing #py5 + #PyAudio microphone listening

Tone generation with #Python turns out to be relatively simple. I found this short code on a blog https://raw.githubusercontent.com/makermovement/3.5-Sensor2Phone/master/generate_any_audio.py [edit: the variable Fs might need to be changed to sampling_rate in the non-sine waves]

which can be tweaked fairly intuitively (er, for me, someone who has been playing music for over 20 years): change "samples" number for different length files, add more for loops for different sequences, use different functions for different waveforms.

Since the waveforms are generated by values in lists being packed into byte sequences, I imagine someone could use spike data (maybe transformed a bit to be in range [-128, 127]) instead of something that generates a sinewave or whatever.

My original idea was to have the spikes trigger a wav file to be played, to make a spiking drum machine, which seems possible with #pygame, #pyaudio, or a module called playsound, but I realized it would require stitching them together and also generating silence, so I went for the simpler method that's more like a synthesizer