Skip to main content

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

  1. 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).

  2. 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'
  1. Train your model:
import ppaudio

# Train model
ppaudio.train(config_path='motor.yaml')
  1. 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:

  1. Industrial noise detection:
import ppaudio

# Train model
ppaudio.train(config_path='motor.yaml')

# Test new samples
ppaudio.test_single('model', 'new_sample.wav')
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ppaudio-0.1.1.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppaudio-0.1.1-py2.py3-none-any.whl (32.2 kB view details)

Uploaded Python 2Python 3

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

Hashes for ppaudio-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d3811851eb5df703a06b39d791dbf8ee263b35fdd7e08c4954e44a1a39625cae
MD5 80eaa638ce7d180bc82bce34fb5f175e
BLAKE2b-256 8816cc0b308d25447e792bad728a98d7fd14f86eade9f9ee54cd54492fdf8134

See more details on using hashes here.

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

Hashes for ppaudio-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 474022d60bfd5cd340c3882835b1e51000265752562fc4b756a9247e7821e6ec
MD5 1c9c2931abc29f35413c386d25912b55
BLAKE2b-256 44843acf802ae187d6d22204a700dc470ff1a71b6a78a2a795f35442605baf34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page