Skip to main content

A simple framework for room acoustics and audio processing in Python.

Project description

Pyroomacoustics logo
Documentation Status Test on mybinder Pyroomacoustics discord server

Summary

Pyroomacoustics is a software package aimed at the rapid development and testing of audio array processing algorithms. The content of the package can be divided into three main components:

  1. Intuitive Python object-oriented interface to quickly construct different simulation scenarios involving multiple sound sources and microphones in 2D and 3D rooms;

  2. Fast C++ implementation of the image source model and ray tracing for general polyhedral rooms to efficiently generate room impulse responses and simulate the propagation between sources and receivers;

  3. Reference implementations of popular algorithms for STFT, beamforming, direction finding, adaptive filtering, source separation, and single channel denoising.

Together, these components form a package with the potential to speed up the time to market of new algorithms by significantly reducing the implementation overhead in the performance evaluation step. Please refer to this notebook for a demonstration of the different components of this package.

Room Acoustics Simulation

Consider the following scenario.

Suppose, for example, you wanted to produce a radio crime drama, and it so happens that, according to the scriptwriter, the story line absolutely must culminate in a satanic mass that quickly degenerates into a violent shootout, all taking place right around the altar of the highly reverberant acoustic environment of Oxford’s Christ Church cathedral. To ensure that it sounds authentic, you asked the Dean of Christ Church for permission to record the final scene inside the cathedral, but somehow he fails to be convinced of the artistic merit of your production, and declines to give you permission. But recorded in a conventional studio, the scene sounds flat. So what do you do?

—Schnupp, Nelken, and King, Auditory Neuroscience, 2010

Faced with this difficult situation, pyroomacoustics can save the day by simulating the environment of the Christ Church cathedral!

At the core of the package is a room impulse response (RIR) generator based on the image source model that can handle

  • Convex and non-convex rooms

  • 2D/3D rooms

The core image source model and ray tracing modules are written in C++ for better performance.

The philosophy of the package is to abstract all necessary elements of an experiment using an object-oriented programming approach. Each of these elements is represented using a class and an experiment can be designed by combining these elements just as one would do in a real experiment.

Let’s imagine we want to simulate a delay-and-sum beamformer that uses a linear array with four microphones in a shoe box shaped room that contains only one source of sound. First, we create a room object, to which we add a microphone array object, and a sound source object. Then, the room object has methods to compute the RIR between source and receiver. The beamformer object then extends the microphone array class and has different methods to compute the weights, for example delay-and-sum weights. See the example below to get an idea of what the code looks like.

The Room class also allows one to process sound samples emitted by sources, effectively simulating the propagation of sound between sources and microphones. At the input of the microphones composing the beamformer, an STFT (short time Fourier transform) engine allows to quickly process the signals through the beamformer and evaluate the output.

Reference Implementations

In addition to its core image source model simulation, pyroomacoustics also contains a number of reference implementations of popular audio processing algorithms for

We use an object-oriented approach to abstract the details of specific algorithms, making them easy to compare. Each algorithm can be tuned through optional parameters. We have tried to pre-set values for the tuning parameters so that a run with the default values will in general produce reasonable results.

Datasets

In an effort to simplify the use of datasets, we provide a few wrappers that allow to quickly load and sort through some popular speech corpora. At the moment we support the following.

For more details, see the doc.

Quick Install

Install the package with pip:

pip install pyroomacoustics

A cookiecutter is available that generates a working simulation script for a few 2D/3D scenarios:

# if necessary install cookiecutter
pip install cookiecutter

# create the simulation script
cookiecutter gh:fakufaku/cookiecutter-pyroomacoustics-sim

# run the newly created script
python <chosen_script_name>.py

We have also provided a minimal Dockerfile example in order to install and run the package within a Docker container. Note that you should increase the memory of your containers to 4 GB. Less may also be sufficient, but this is necessary for building the C++ code extension. You can build the container with:

docker build -t pyroom_container .

And enter the container with:

docker run -it pyroom_container:latest /bin/bash

Dependencies

The minimal dependencies are:

numpy
scipy>=0.18.0
Cython
pybind11

where Cython is only needed to benefit from the compiled accelerated simulator. The simulator itself has a pure Python counterpart, so that this requirement could be ignored, but is much slower.

On top of that, some functionalities of the package depend on extra packages:

samplerate   # for resampling signals
matplotlib   # to create graphs and plots
sounddevice  # to play sound samples
mir_eval     # to evaluate performance of source separation in examples

The requirements.txt file lists all packages necessary to run all of the scripts in the examples folder.

This package is mainly developed under Python 3.6. The last supported version for Python 2.7 is 0.4.3.

Under Linux and Mac OS, the compiled accelerators require a valid compiler to be installed, typically this is GCC. When no compiler is present, the package will still install but default to the pure Python implementation which is much slower. On Windows, we provide pre-compiled Python Wheels for Python 3.5 and 3.6.

Example

Here is a quick example of how to create and visualize the response of a beamformer in a room.

import numpy as np
import matplotlib.pyplot as plt
import pyroomacoustics as pra

# Create a 4 by 6 metres shoe box room
room = pra.ShoeBox([4,6])

# Add a source somewhere in the room
room.add_source([2.5, 4.5])

# Create a linear array beamformer with 4 microphones
# with angle 0 degrees and inter mic distance 10 cm
R = pra.linear_2D_array([2, 1.5], 4, 0, 0.1)
room.add_microphone_array(pra.Beamformer(R, room.fs))

# Now compute the delay and sum weights for the beamformer
room.mic_array.rake_delay_and_sum_weights(room.sources[0][:1])

# plot the room and resulting beamformer
room.plot(freq=[1000, 2000, 4000, 8000], img_order=0)
plt.show()

More examples

A couple of detailed demos with illustrations are available.

A comprehensive set of examples covering most of the functionalities of the package can be found in the examples folder of the GitHub repository.

A video introduction to pyroomacoustics.

A video tutorial series on using pyroomacoustics covering many advanced topics.

Authors

  • Robin Scheibler

  • Ivan Dokmanić

  • Sidney Barthe

  • Eric Bezzam

  • Hanjie Pan

How to contribute

If you would like to contribute, please clone the repository and send a pull request.

For more details, see our CONTRIBUTING page.

Academic publications

This package was developed to support academic publications. The package contains implementations for DOA algorithms and acoustic beamformers introduced in the following papers.

  • H. Pan, R. Scheibler, I. Dokmanic, E. Bezzam and M. Vetterli. FRIDA: FRI-based DOA estimation for arbitrary array layout, ICASSP 2017, New Orleans, USA, 2017.

  • I. Dokmanić, R. Scheibler and M. Vetterli. Raking the Cocktail Party, in IEEE Journal of Selected Topics in Signal Processing, vol. 9, num. 5, p. 825 - 836, 2015.

  • R. Scheibler, I. Dokmanić and M. Vetterli. Raking Echoes in the Time Domain, ICASSP 2015, Brisbane, Australia, 2015.

If you use this package in your own research, please cite our paper describing it.

R. Scheibler, E. Bezzam, I. Dokmanić, Pyroomacoustics: A Python package for audio room simulations and array processing algorithms, Proc. IEEE ICASSP, Calgary, CA, 2018.

License

Copyright (c) 2014-2021 EPFL-LCAV

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pyroomacoustics-0.8.5-cp314-cp314-win_amd64.whl (34.4 MB view details)

Uploaded CPython 3.14Windows x86-64

pyroomacoustics-0.8.5-cp314-cp314-macosx_10_15_universal2.whl (35.0 MB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

pyroomacoustics-0.8.5-cp313-cp313-win_amd64.whl (34.4 MB view details)

Uploaded CPython 3.13Windows x86-64

pyroomacoustics-0.8.5-cp313-cp313-macosx_10_13_universal2.whl (34.9 MB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

pyroomacoustics-0.8.5-cp312-cp312-win_amd64.whl (34.4 MB view details)

Uploaded CPython 3.12Windows x86-64

pyroomacoustics-0.8.5-cp312-cp312-macosx_10_13_universal2.whl (35.0 MB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

pyroomacoustics-0.8.5-cp311-cp311-win_amd64.whl (34.4 MB view details)

Uploaded CPython 3.11Windows x86-64

pyroomacoustics-0.8.5-cp311-cp311-macosx_10_9_universal2.whl (34.9 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

pyroomacoustics-0.8.5-cp310-cp310-win_amd64.whl (34.4 MB view details)

Uploaded CPython 3.10Windows x86-64

pyroomacoustics-0.8.5-cp310-cp310-macosx_13_0_x86_64.whl (34.5 MB view details)

Uploaded CPython 3.10macOS 13.0+ x86-64

pyroomacoustics-0.8.5-cp310-cp310-macosx_10_9_universal2.whl (34.9 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

pyroomacoustics-0.8.5-cp39-cp39-win_amd64.whl (34.4 MB view details)

Uploaded CPython 3.9Windows x86-64

pyroomacoustics-0.8.5-cp39-cp39-macosx_13_0_x86_64.whl (34.5 MB view details)

Uploaded CPython 3.9macOS 13.0+ x86-64

File details

Details for the file pyroomacoustics-0.8.5-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b6e9953c718bed1b08b649f1c576deea977f41f47966d028ee3473fc68a04a94
MD5 b7d4023084203024f5aa9e3103ca215f
BLAKE2b-256 8e589ccf19fde562de3f3543f060868e0ba6f1db7f54dbc3d4bf92fb73eb42fa

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 b7c5ee95e9ecc96e392ae4ac56824d05996817a01ef9d5d2f5a72ad00ed98e86
MD5 4ab1761c71a5d09993def9ad2ea35870
BLAKE2b-256 8e91ae9a83df257b97235f65bd2442cd09c515ddab8a96c290c4a60b61d12287

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 46c6bd75e5e55936344cc9a5f35517c8095569678742fc241e8b82aa42d713b5
MD5 bc6e3ecd8e6030004e770d58721908cd
BLAKE2b-256 7dcaaac027e887e3f36d4a968b969f8cb31dfef34d9f8d37a6e887da426a0438

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 76251a1f02f65b08fccf67134404f0e1d19686143e1623ccaeccfd2580495970
MD5 c222a8d74e74fdf302f75e9f941dde0e
BLAKE2b-256 45145c87db944ef59092f5b0cc7c6f20326fb5f98977a4663103259c56a6a83a

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0b7611ea559ef3be51dfdf4ef1f291b3409c38e2e817d8209b7e45c006a21d09
MD5 6d5fe5a5ab5e1a4dad946285a7d13af2
BLAKE2b-256 0721bb1239677ecc5fbfb88ce2155fed588803d67314886ef96e3466a758714c

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 8cdeb0c3609cb8bc99f65acea862564ac9e226f83faddb839e412dba87d9b3ab
MD5 11c003db62e24034f92a2317dfbbb153
BLAKE2b-256 5e83cb0c333b28ea3439c96f62984057a4b9905f087811ae8752b7d6ed42e683

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 45c15c23614d5c4d875e4dbb38c16e0c2a72760aff89853229c4fc30c01be58c
MD5 c4b2d021d5f8c1b65f18a120d358b67f
BLAKE2b-256 902f3f373fc668876e875123ba807d52a94a696d59813ef8461e87b08d536255

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 da4afbea57b66108479fc878ff0c9a3a2617922142ddbb799f0683b665b34a25
MD5 ad57bb04b49cf9ebb2f030ceab6632f6
BLAKE2b-256 aaf6c2f3b1905f4db99f8cf89727b8e2d298378820ec26c133ecd4dae53fa155

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0a49b7adddbb09c2f26004090853c131edd9ced19ef694a52e87a248ed67fc08
MD5 8d2c0b8253f9830a2f8612d47e8f0477
BLAKE2b-256 ec49ce5509254374db9e9d236daa50dada210c7d1d1264d9d157a9fc83106d83

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 88cbe2ffa652927abbb19ef7cabec59e6489ba46777a19c2a476276d21a8de3a
MD5 8eb851a0386a5a4653bdf88018ae1466
BLAKE2b-256 d36cc63b41f7d0372c03312cbe6d4800a7f924a11f724ed44fdf6cc9713281e8

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 76a1511cd70e70b7db189098c60c49e53748d05589013f2fadda2b9334f8bc49
MD5 9bdff8beca69e0a7f2c613f0825b706b
BLAKE2b-256 226b595d676717bb78688e21e35b523789d5881eb71345c4f4729c88d8ea4149

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 dc61ea72353009d305f0660663f1769d84765b883fab7413541ef16df5cff553
MD5 6a081f09bd798aa65543677af546897c
BLAKE2b-256 a0367bf8b85946edff8c3bff964a32c8a48f3363b892ca344da862746e083b88

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.8.5-cp39-cp39-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for pyroomacoustics-0.8.5-cp39-cp39-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 5d8971b8e96a3f9d812d0e534fe6e1425c1c8c9fe4826c59d116d248927096f0
MD5 3cf35d35c424314890dc07ba3d0779bd
BLAKE2b-256 d9c11f9d87180e21f6caa4db2f715a9ef99fc6b473f5b9fef462083cc9da1fbc

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