{"id":6945,"library":"wavio","title":"Wavio","description":"Wavio is a Python module for reading and writing WAV files using NumPy arrays. It provides two main functions, `wavio.read` and `wavio.write`, for handling 8-, 16-, 24-, and 32-bit integer WAV files. It leverages Python's standard `wave` module and currently does not support compressed WAV files or direct floating-point WAV file output, converting floating-point input to integers. The current version is 0.0.9, with recent updates focusing on NumPy 2.0.0 compatibility.","status":"active","version":"0.0.9","language":"en","source_language":"en","source_url":"https://github.com/WarrenWeckesser/wavio","tags":["audio","wav","file-io","numpy"],"install":[{"cmd":"pip install wavio","lang":"bash","label":"Install wavio"}],"dependencies":[{"reason":"Required for array handling; version 1.21.3 or later recommended.","package":"numpy","optional":false}],"imports":[{"symbol":"wavio","correct":"import wavio"},{"note":"The primary functions are typically accessed as attributes of the imported `wavio` module, e.g., `wavio.read` and `wavio.write`.","wrong":"from wavio import read","symbol":"read","correct":"wavio.read('file.wav')"},{"note":"The primary functions are typically accessed as attributes of the imported `wavio` module, e.g., `wavio.read` and `wavio.write`.","wrong":"from wavio import write","symbol":"write","correct":"wavio.write('file.wav', data, rate)"}],"quickstart":{"code":"import numpy as np\nimport wavio\n\n# Parameters for the sine wave\nrate = 22050  # samples per second\nT = 3         # sample duration (seconds)\nf = 440.0     # sound frequency (Hz)\n\n# Create time array and sine wave data\nt = np.linspace(0, T, int(T * rate), endpoint=False)\nx = np.sin(2 * np.pi * f * t)\n\n# Write the sine wave to a 24-bit WAV file\nwavio.write(\"sine24.wav\", x, rate, sampwidth=3)\n\n# Read the WAV file back\nwav_read = wavio.read(\"sine24.wav\")\nprint(f\"Read WAV file: {wav_read.filename}\")\nprint(f\"Sample rate: {wav_read.rate} Hz\")\nprint(f\"Sample width: {wav_read.sampwidth} bytes\")\nprint(f\"Data shape: {wav_read.data.shape}\")","lang":"python","description":"This quickstart demonstrates how to generate a 3-second 440 Hz sine wave using NumPy and save it as a 24-bit WAV file, then read it back. It illustrates the basic usage of `wavio.write` and `wavio.read`."},"warnings":[{"fix":"Review the `scale` and `sampwidth` parameters in the `wavio.write` documentation for `wavio` versions 0.0.5 and later to adjust your code. Floating-point inputs now require `sampwidth` to be explicitly given.","message":"The API for `wavio.write` changed in version 0.0.5, specifically how floating-point data is scaled. Code written for 0.0.4 or earlier may produce different audio or errors.","severity":"breaking","affected_versions":"<=0.0.4"},{"fix":"Always provide the `sampwidth` parameter when writing floating-point data to control the output bit depth. Be aware of the `scale` parameter in `wavio.write` (defaulting to `[-1.0, 1.0]` mapping to the full integer range) and check for clipping warnings.","message":"Wavio does not directly support floating-point WAV files or compressed WAV files. When writing floating-point data, it is converted to integers, and if `sampwidth` is not provided, default scaling is applied. Data clipping can occur and will generate a warning.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the GitHub release notes and PyPI project description for each new version to be aware of any changes.","message":"The API of wavio functions is not considered stable, and backwards-incompatible changes may occur between releases.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Ensure your environment uses Python 3.10 or newer for `wavio` version 0.0.9. Older `wavio` versions may support earlier Python versions.","message":"The library explicitly states that it requires Python 3.10 or later as of recent updates, which is a change from older versions that supported Python 3.7+ (and even 2.7 in much older releases).","severity":"gotcha","affected_versions":"<0.0.9 (pre-NumPy 2.0.0 support)"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}