What are chunks, samples and frames when using pyaudio

“RATE” is the “sampling rate”, i.e. the number of frames per second “CHUNK” is the (arbitrarily chosen) number of frames the (potentially very long) signals are split into in this example Yes, each frame will have 2 samples as “CHANNELS=2”, but the term “samples” is seldom used in this context (because it is confusing) Yes, … Read more

PyAudio Input overflowed

pyaudio.Stream.read() has a keyword parameter exception_on_overflow, set this to False. For your sample code that would look like: import pyaudio import wave import sys chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 44100 RECORD_SECONDS = 5 WAVE_OUTPUT_FILENAME = “output.wav” p = pyaudio.PyAudio() stream = p.open(format = FORMAT, channels = CHANNELS, rate = … Read more

How to install pyaudio on mac using Python 3?

I’m assuming you are on a Mac. This is a simple issue to fix. First install Xcode. Then restart your computer. Afterwards run the commands in sequence, xcode-select –install brew remove portaudio brew install portaudio pip3 install pyaudio So to clarify, Xcode is installed through the App Store. Xcode command line tools are required for … Read more

PyAudio working, but spits out error messages each time

You can try to clean up your ALSA configuration, for example, ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side are caused by /usr/share/alsa/alsa.conf: pcm.rear cards.pcm.rear pcm.center_lfe cards.pcm.center_lfe pcm.side cards.pcm.side Once you comment out these lines, those error message will be gone. You may also want … Read more

when installing pyaudio, pip cannot find portaudio.h in /usr/local/include

Since pyAudio has portAudio as a dependency, you first have to install portaudio. brew install portaudio Then try: pip install pyAudio. If the problem persists after installing portAudio, you can specify the directory path where the compiler will be able to find the source programs (e.g: portaudio.h). Since the headers should be in the /usr/local/include … Read more