• Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created about 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Audio preprocessing framework for Deep Learning audio applications

README

praudio provides objects and a script for performing complex preprocessing operations on entire audio datasets with one command.

praudio is implemented having Deep Learning audio/music applications in mind.

Operations are carried out on CPU. Preprocessing can also be run on-the-fly, for example, while training a model.

The library uses librosa as an audio processing backend.

How do I install the library?

You can install praudio both with pip via PyPi, and by cloning the praudio repo from GitHub.

For both approaches, it's advisable to use a dedicated Python virtual environment.

Installing from PyPi

Installing from PyPi is the easiest option. In the terminal type:

$ pip install praudio

Installing from GitHub

First, you should clone the repository from GitHub:

$ git clone [email protected]:musikalkemist/praudio.git

Then, move to the project root and, to install the package, type in the terminal:

$ pip install .

You can also use a rule in the available Makefile (see below):

$ make install 

To install the package in development mode use:

$ pip install -e .[testing]

You can also use a rule in Makefile:

$ make install_dev 

This will install all the packages necessary to run the tests, lint, type checker. It will also install the package in 'editable' mode, which is ideal for development.

Python version

praudio works in Python 3.6, 3.7, 3.8.

How do I preprocess an audio dataset?

The core of the library is the preprocess entry point. This script works with a config file. You set the type of preprocessing you want to apply in a yaml file, and then run the script. Your dataset will be entirely preprocessed and the results recursively stored in a directory of your choice that can potentially be created from scratch.

To run the entry point, ensure the library is installed and then type:

$ preprocess /path/to/config.yml

In the config.yml, you should provide the following parameters:

  • dataset_dir: Path to the directory where your audio dataset is stored
  • save_dir: Path where to save the preprocessed audio.
  • Under file_preprocessor, you should provide settings for loader and transforms_chain.
  • loader: Provide settings for the loader.
  • transforms_chain: Parameters for each transform in the sequence. of transforms which are applied to your data (i.e., TransformChain).

These config parameters are used to dinamically initialise the relative objects in the library. To learn what parameters are available at each level in the config file, please refer to the docstrings in the relative objects.

Check out test/config.sampleconfig.yml to see an example of a valid config file.

Package structure

The package is divided into a number of subpackages:

  • config
  • creation
  • io
  • preprocessors
  • transforms

config has facilities to load, save, and validate configuration files, which are used to specify the types of preprocessing pipelines to use.

creation has classes that are responsible to instantiate key objects in the library.

io contains facilities to load / save audio signals from / to files.

preprocessors features objects which are responsible to preprocess single audio files, from loading to storing, as well as, batch of files.

transforms contains a series of objects which manipulate audio signals, such as short-time Fourier transform, log, scaling.

What's the Makefile for?

The Makefile has a series of rules that can be used to ensure quality of the code, and automate repetitive tasks.

Linter

The project uses pylint. The linter helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions.

To run the linter type:

$ make lint

Typehint

The project uses mypy. mypy is an optional static type checker for Python. You can add type hints (PEP 484) to your Python programs, and use mypy to type check them statically.

To run the type checker type:

$ make typehint

Testing

The project uses pytest for unittests. Tests can be run in one go using coverage. This package suggests the percentage of code that is covered in unittests.

To run all the unittests type:

$ make test

Checklist

Checklist is a utility rule that runs the linter, type checker, and the test suite in one go:

$ make checklist

Clean

Use the clean rule to get rid of pyc files and __pychache__:

$ make clean

Dependencies

praudio has the following dependencies:

  • librosa==0.8.1
  • pyyaml==5.4.1
  • types-PyYAML==5.4.6

librosa is extensively used to extract audio features in transform objects.

Current limitations

The praudio preprocessors are capable of operating only on mono signals. This is a significant limitation if you are working in generative music. If you are using the library for audio / music analysis, this shouldn't be a problem.

Future improvements

  • Add audio augmentation / padding / cropping transforms.
  • Enable preprocessing of signals with multiple channels.
  • Turn transform parameters into full-fledged objects (e.g., STFTParams)
  • Instead of using a dictionary for configurations, instantiate parameter objects with validation
  • Implement different types of Savers / Loaders with factories to produce them.

More Repositories

1

AudioSignalProcessingForML

Code and slides of my YouTube series called "Audio Signal Proessing for Machine Learning"
Jupyter Notebook
909
star
2

DeepLearningForAudioWithPython

Code and slides for the "Deep Learning (For Audio) With Python" course on TheSoundOfAI Youtube channel.
Python
554
star
3

pytorchforaudio

Code for the "PyTorch for Audio + Music Processing" series on The Sound of AI YouTube channel.
Python
186
star
4

Deep-Learning-Audio-Application-From-Design-to-Deployment

Code and slides for the "Deep learning (audio) application: From design to deployment" tutorials.
Python
144
star
5

generating-sound-with-neural-networks

Code and slides for the "Generating Sound with Neural Network" series on The Sound of AI Youtube channel.
Python
132
star
6

paperwhisperer

Automatic voice-synthetised summaries of latest research papers on arXiv
Python
126
star
7

generating-melodies-with-rnn-lstm

Repo with code and slides for the "Generating Melodies with RNN-LSTM" YouTuve series.
Python
85
star
8

infiniteremixer

Create infinite remixes intelligently patching together groups of songs
Python
67
star
9

spotifyplaylistgenerator

A script to create custom Spotify playlists using the Spotify API, based on seed tracks.
Python
64
star
10

prophet

Python
49
star
11

generativemusicaicourse

Resources for the Generative Music AI Course on The Sound of AI YouTube channel.
Python
39
star
12

audioDataAugmentationTutorial

Repository hosting code and slides of the Audio Data Augmentation series on The Sound of AI YT channel.
Python
31
star
13

solidforml

Code and slides for the "SOLID principles for ML engineers" series on The Sound of AI YouTube channel.
Python
26
star
14

musiccollaborativefiltering

This repo features code for "" video on The Sound of AI YouTube channel
Python
17
star
15

Deep-Learning-For-Audio-Book-Repo

Code examples for the book "Deep Learning for Audio: A Comprehensive Journey From Theory to Deployment"
17
star
16

open-source-research

13
star
17

advancedpython

Code for the Advanced Python course.
Python
13
star
18

mldeployment

Repo with code used in the "Deploying ML Into Production" video tutorial on The Sound of AI channel
Python
12
star
19

brute_force_chord_generator

A script that brute forces the generation of chord progressions using major and minor triads
Python
9
star
20

How-to-Read-AI-Papers-Like-a-Rockstar

Slide decks for the "How to Read AI (Audio) Research Papers Like a Rockstar" mini-series on YouTube.
9
star
21

pythonAI

Example code of the Python AI tutorials
Python
9
star
22

PySummarizer

A Python library for automatic text summarization.
Python
8
star
23

midiget

A program that retrieves midi files from web servers.
Python
7
star
24

thesoundofaihackathon

6
star
25

how-to-write-a-research-paper-like-a-rockstar

Slides for the "How to Write a Research Paper like a Rock Start" series on The Sound of AI YouTube channel.
6
star
26

socketprogramming-tutorial

Simple client and server socket scripts in Python
Python
5
star
27

recorder

Repo for the "Recording Sound with Python" tutorial on The Sound of AI YT channel.
Python
5
star
28

PylibAI

A Python library of general Artificial Intelligence algorithms
Python
4
star
29

github-actions-for-ci

JavaScript
3
star
30

recursion-tutorial

Code for the video "How Does Recursive Music Sound Like?" on The Sound of AI YT channel.
Python
2
star
31

kaprevideo

Code for the video about Kapre (audio signal processing library) on The Sound of AI YouTube channel.
Python
1
star