An audio classification toolkit based on PaddlePaddle for detecting abnormal sounds
Project description
ppaudio
A simple audio classification library based on PaddlePaddle.
Features
- Easy-to-use API for audio classification tasks
- Support for various audio classification scenarios:
- Industrial noise detection
- Fan noise classification
- Engine sound analysis
- Animal sound classification
- Music genre classification
- Multiple feature extraction methods
- Various neural network architectures
- Visualization tools for audio analysis
Installation
pip install ppaudio
Quick Start
-
Prepare your data in CSV format:
- train_data.csv
- val_data.csv
- test_data.csv
Each CSV file should contain two columns: audio file path and label (0 or 1).
-
Create a configuration file (e.g.,
motor.yaml):
# Dataset parameters
dataset_conf:
dataset:
adjust_audio_length: True
use_dB_normalization: True
is_full_path: False
sampler:
batch_size: 64
shuffle: True
drop_last: True
train_data: 'dataset/train_data.csv'
val_data: 'dataset/val_data.csv'
test_data: 'dataset/test_data.csv'
# Preprocessing parameters
preprocess_conf:
feature_method: 'LogMelSpectrogram'
method_args:
sr: 48000
n_fft: 1024
hop_length: 512
win_length: 1024
window: 'hann'
f_min: 50
f_max: 14000
n_mels: 64
# Loss function configuration
loss_conf:
criterion: 'CrossEntropyLoss'
# Optimizer configuration
optimizer_conf:
optimizer: 'Adam'
optimizer_args:
learning_rate: 0.001
# System configuration
sys_conf:
use_GPU: True
max_epoch: 60
show_train_process: True
save_train_process: False
model_save_name: 'model'
- Train your model:
import ppaudio
# Train model
ppaudio.train(config_path='motor.yaml')
- Test your model:
# Test on dataset
ppaudio.test('model', 'dataset/test_data.csv')
# Test single audio file
ppaudio.test_single('model', '123.wav')
# Compare two audio files
ppaudio.compare('model', '123.wav', '456.wav', show_pic=True)
Documentation
For detailed documentation, please visit project documentation.
Examples
Here are some example use cases:
- Industrial noise detection:
import ppaudio
# Train model
ppaudio.train(config_path='motor.yaml')
# Test new samples
ppaudio.test_single('model', 'new_sample.wav')
- Music genre classification:
import ppaudio
# Train model (using a different configuration)
ppaudio.train(config_path='music.yaml')
# Compare two music samples
ppaudio.compare('model', 'rock.wav', 'jazz.wav', show_pic=True)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 ppaudio-0.1.1.tar.gz.
File metadata
- Download URL: ppaudio-0.1.1.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3811851eb5df703a06b39d791dbf8ee263b35fdd7e08c4954e44a1a39625cae
|
|
| MD5 |
80eaa638ce7d180bc82bce34fb5f175e
|
|
| BLAKE2b-256 |
8816cc0b308d25447e792bad728a98d7fd14f86eade9f9ee54cd54492fdf8134
|
File details
Details for the file ppaudio-0.1.1-py2.py3-none-any.whl.
File metadata
- Download URL: ppaudio-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 32.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
474022d60bfd5cd340c3882835b1e51000265752562fc4b756a9247e7821e6ec
|
|
| MD5 |
1c9c2931abc29f35413c386d25912b55
|
|
| BLAKE2b-256 |
44843acf802ae187d6d22204a700dc470ff1a71b6a78a2a795f35442605baf34
|