PyAudio provides Python bindings for PortAudio, a cross-platform audio I/O library. It allows you to easily use Python to play and record audio on a variety of platforms. The current version is 0.2.14, and the library maintains a stable but slow release cadence.
pip install pyaudioVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize PyAudio, generate a simple sine wave, and play it back through your default audio output device. It showcases stream creation, data writing, and proper resource cleanup.
On Debian/Ubuntu: `sudo apt-get install portaudio19-dev`. On macOS: `brew install portaudio`. On Windows, pre-compiled wheels are often available, but if not, manual compilation or using specific build tools might be necessary.
Always ensure `stream.close()` is called on all open streams and `p.terminate()` is called once when you are finished using PyAudio, typically at the end of your script or in a `finally` block.
Verify that your audio hardware is correctly configured and drivers are installed. Check system audio input/output settings and permissions for your application. You might need to specify a device index manually using `p.get_device_info_by_index()`.
Always ensure your audio data is converted to `bytes` in the correct format (e.g., `paInt16` for 16-bit signed integers) and byte order before passing it to `stream.write()`. Similarly, `stream.read()` returns `bytes` that need to be parsed.
No dependency data recorded yet.