音频分析和处理工具库
Project description
WavX
WavX is a Python library for audio analysis and processing, providing a simple yet powerful API for handling various audio-related tasks.
Features
- Audio file analysis, including amplitude, loudness, and acoustic parameter measurement
- Audio processing, including RMS level normalization
- Modular design, easy to extend
- Clean and intuitive API interface
Installation
pip install wavx
Quick Start
Analyze audio file amplitude information
import wavx
# Analyze audio file and get amplitude information
amplitude_info = wavx.analysis.amplitude.analyze_amplitude("your_audio_file.wav")
# Print all amplitude information
wavx.analysis.amplitude.print_amplitude_info(amplitude_info)
# Or get specific information
print(f"Peak amplitude: {amplitude_info['peak_amplitude']} dB")
print(f"Total RMS amplitude: {amplitude_info['total_rms_amplitude']} dB")
Generate and display audio waveform
import wavx
# Simple way: Display waveform with one function call
wavx.analysis.waveform.display_waveform("your_audio_file.wav")
# Advanced way: Step by step for more control
# 1. Analyze waveform data
waveform_data = wavx.analysis.waveform.analyze_waveform(
audio_file="your_audio_file.wav",
channel=0 # 0=left channel, 1=right channel
)
# 2. Print waveform information
wavx.analysis.waveform.print_waveform_info(waveform_data)
# 3. Plot waveform with custom settings
import matplotlib.pyplot as plt
fig = wavx.analysis.waveform.plot_waveform(
waveform_data=waveform_data,
figsize=(12, 4), # figure size
save_path="waveform.png" # save to file
)
plt.show()
Generate and display audio spectrogram
import wavx
# Simple way: Display spectrogram with one function call
wavx.analysis.spectrogram.display_spectrogram("your_audio_file.wav")
# Advanced way: Step by step for more control
# 1. Analyze spectrogram data
spec_data = wavx.analysis.spectrogram.analyze_spectrogram(
audio_file="your_audio_file.wav",
channel=0, # 0=left channel, 1=right channel
window_size=None, # auto window size
overlap=0.75 # 75% window overlap
)
# 2. Print spectrogram information
wavx.analysis.spectrogram.print_spectrogram_info(spec_data)
# 3. Plot spectrogram with custom settings
import matplotlib.pyplot as plt
fig = wavx.analysis.spectrogram.plot_spectrogram(
spec_data=spec_data,
use_log_scale=True, # use dB scale
freq_limit=8000, # limit to 8kHz
figsize=(12, 4), # figure size
save_path="spectrogram.png" # save to file
)
plt.show()
Normalize audio file to target RMS level
import wavx
# Normalize audio file to -20 dB FS
result = wavx.processing.normalization.normalize_to_target(
input_file="input.wav",
output_file="output.wav",
target_rms_db=-20.0,
reference_type="square" # or "sine"
)
# Print normalization information
wavx.processing.normalization.print_normalization_info(result)
Project Structure
wavx/
├── docs/
│ ├── amplitude/
│ │ └── amplitude_analysis.md # Amplitude analysis documentation
│ ├── analysis/
│ │ └── spectrogram.md # Spectrogram analysis documentation
│ └── processing/
│ └── normalization.md # RMS normalization documentation
├── examples/
│ ├── analyze_audio.py # Example of audio analysis
│ ├── display_spectrogram.py # Example of spectrogram visualization
│ └── normalize_audio.py # Example of audio normalization
├── wavx/
│ ├── __init__.py # Package initialization
│ ├── cli.py # Command line interface
│ ├── analysis/
│ │ ├── __init__.py # Analysis module initialization
│ │ ├── amplitude.py # Amplitude analysis functionality
│ │ └── spectrogram.py # Spectrogram analysis functionality
│ ├── processing/
│ │ ├── __init__.py # Processing module initialization
│ │ └── normalization.py # RMS normalization functionality
│ ├── tests/
│ │ ├── __init__.py # Tests initialization
│ │ ├── test_amplitude.py # Amplitude analysis tests
│ │ └── test_normalization.py # Normalization tests
│ └── utils/
│ └── __init__.py # Utilities module initialization
├── README.md # English documentation
├── README_zh.md # Chinese documentation
├── requirements.txt # Project dependencies
└── setup.py # Package installation config
Command Line Usage
After installation, you can use WavX from the command line:
# Basic amplitude analysis
wavx amplitude path/to/audio.wav
# Generate and display waveform
wavx waveform path/to/audio.wav
# Waveform with custom parameters
wavx waveform path/to/audio.wav --channel 1 --save output.png
# Generate and display spectrogram
wavx spectrogram path/to/audio.wav
# Spectrogram with custom parameters
wavx spectrogram path/to/audio.wav --channel 1 --freq-limit 5000 --save output.png
# RMS normalization
wavx normalize input.wav output.wav --target -18.0
# With custom reference signal
wavx normalize input.wav output.wav --reference sine --freq 500
Future Extensions
The modular design allows easy extensions:
-
More Analysis Functions:
- Spectrum analysis
- Harmonic analysis
- Reverb and spatial analysis
-
More Audio Processing:
- Equalization
- Noise reduction
- Dynamic range compression
- Resampling and format conversion
-
Visualization:
- Waveform display
- Spectrogram
- Loudness/RMS history
Release Notes
- v0.1.0 (2025-03-20): Initial release with amplitude analysis functionality
- v0.1.1 (2025-03-20): Added docs directory and bilingual README files
- v0.1.2 (2025-03-20): Added RMS normalization functionality
- v0.1.3 (2025-03-20): Added WAVX LOGO display after pip install
- v0.1.4 (2025-03-21): Added spectrogram analysis and visualization
- v0.1.5 (2025-03-22): Added waveform visualization functionality
Contributing
Contributions to the code, questions, or suggestions are welcome!
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wavx-0.1.5.tar.gz.
File metadata
- Download URL: wavx-0.1.5.tar.gz
- Upload date:
- Size: 41.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02e513f48db637477cdf9bcf145a769b6add73b13e20113b4781414940d8bdd1
|
|
| MD5 |
fd460bd8bb407016523ec44da27a7a96
|
|
| BLAKE2b-256 |
763ebecc115a14a531ac8461e393521d9fb42427b4783ba97062632662a07c62
|
File details
Details for the file wavx-0.1.5-py2.py3-none-any.whl.
File metadata
- Download URL: wavx-0.1.5-py2.py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2386384ce0507045637bc2435638f7f05f9800ab2284b21eeba3da005eced09e
|
|
| MD5 |
862f4160cd6e59913292bf02fbac2742
|
|
| BLAKE2b-256 |
ac6f565c60aad2118d8b61e86670dae775126d01ef7438da7e8d08ba33e5b21c
|