Skip to main content

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

Project description

https://travis-ci.org/LCAV/pyroomacoustics.svg?branch=pypi-release Documentation Status

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 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

Both a pure Python implementation and a C accelerator are included for maximum speed and compatibility.

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

Dependencies

The minimal dependencies are:

numpy
scipy>=0.18.0
Cython

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.5. We try as much as possible to keep things compatible with Python 2.7 and run tests and builds under both. However, the tests code coverage is far from 100% and it might happen that we break some things in Python 2.7 from time to time. We apologize in advance for that.

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 visual 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.

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-2018 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 Distribution

pyroomacoustics-0.1.23.tar.gz (269.9 kB view details)

Uploaded Source

Built Distributions

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

pyroomacoustics-0.1.23-cp37-cp37m-win_amd64.whl (265.3 kB view details)

Uploaded CPython 3.7mWindows x86-64

pyroomacoustics-0.1.23-cp37-cp37m-win32.whl (251.1 kB view details)

Uploaded CPython 3.7mWindows x86

pyroomacoustics-0.1.23-cp37-cp37m-macosx_10_7_x86_64.whl (271.6 kB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

pyroomacoustics-0.1.23-cp36-cp36m-win_amd64.whl (265.4 kB view details)

Uploaded CPython 3.6mWindows x86-64

pyroomacoustics-0.1.23-cp36-cp36m-win32.whl (251.1 kB view details)

Uploaded CPython 3.6mWindows x86

pyroomacoustics-0.1.23-cp36-cp36m-macosx_10_7_x86_64.whl (271.3 kB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

pyroomacoustics-0.1.23-cp35-cp35m-win_amd64.whl (263.7 kB view details)

Uploaded CPython 3.5mWindows x86-64

pyroomacoustics-0.1.23-cp35-cp35m-win32.whl (249.6 kB view details)

Uploaded CPython 3.5mWindows x86

pyroomacoustics-0.1.23-cp35-cp35m-macosx_10_6_x86_64.whl (269.1 kB view details)

Uploaded CPython 3.5mmacOS 10.6+ x86-64

pyroomacoustics-0.1.23-cp27-cp27m-macosx_10_6_x86_64.whl (270.7 kB view details)

Uploaded CPython 2.7mmacOS 10.6+ x86-64

File details

Details for the file pyroomacoustics-0.1.23.tar.gz.

File metadata

  • Download URL: pyroomacoustics-0.1.23.tar.gz
  • Upload date:
  • Size: 269.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for pyroomacoustics-0.1.23.tar.gz
Algorithm Hash digest
SHA256 ae406631a059d48f41ea1bf7923331adf9f026924ec5f5d0d7a1e8456ef71611
MD5 95a39b4ca863f2f288e85c30a52a0eab
BLAKE2b-256 77b825af205a42b78eab360edd8199e9c953a292915941f712223b916eacc032

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 265.3 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pyroomacoustics-0.1.23-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 3e22b3422e6fa4044bc6218aa49377f5362e31e55d7866fe48315eb9d27ae9b1
MD5 c673c31e99f79f36030a536569dbff2d
BLAKE2b-256 8a4f977649e98dab571ca3e53bfe884cebe7907e9d70640a22921061ea781386

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp37-cp37m-win32.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 251.1 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pyroomacoustics-0.1.23-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 3555d56a714935c5aaec2a5c915a60232f6dd0f900805985b225997b8635db09
MD5 730377f71d1424ccb5bc74fc4b2f95f6
BLAKE2b-256 c31b038eab9564ee7c1b12917dee8870783ee9b4cbb8bb9e35f7a7657a21a91c

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 271.6 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pyroomacoustics-0.1.23-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 2a4880080ee112098f8c31802070d3a603881ebbf8963e0732c47626319f2d04
MD5 3a3fc37d2f4b853d4857878a84f99bfb
BLAKE2b-256 b3ef1d24a346b17091abc7b417a65331c4d181ce785db7964f9f42dd0766027f

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 265.4 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pyroomacoustics-0.1.23-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 aeb01c18e03d8ed426bfc1e16212cf31341254bb136db5815ea91a2ddbfc99af
MD5 6471a6e4d42e60a8f4a4c5326e9d99e1
BLAKE2b-256 ce6593a0fc16ccb6b8782ca383a2b5afac0e257f5803bf4b2f10be44ab68c900

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp36-cp36m-win32.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 251.1 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pyroomacoustics-0.1.23-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 b060a0273cefdcdc8d65d8ec3508611980b270fdcb4aaf56878201b9aed7b86d
MD5 5a435c3c6d965a073c87c55ea13bce31
BLAKE2b-256 47f29d861a99643dd4e3fcc90f8f0fc10ae8bb9b8eacdf983f5770a24a1fe2f1

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 271.3 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for pyroomacoustics-0.1.23-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7126a57ce5f0df14aee5e68312ff46328d909aded79b54aa0c3d77414c7a06cb
MD5 52f8814d7a57d33aee6033495dc844ef
BLAKE2b-256 002409596fd67e2caa808f31b32e753a516284a155654ca3542f2ec2704e7763

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 263.7 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pyroomacoustics-0.1.23-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 f496c6c7635fac9cdeac60893c581d734fcc255fc711419b581f09995ecb7570
MD5 52a4a6b669576994d6899f4c1ffad8c0
BLAKE2b-256 17f52910192a7c51fe63da6dc2b86f2cb44049d8b98e595c24b4a29eab60f23d

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp35-cp35m-win32.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 249.6 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for pyroomacoustics-0.1.23-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 e4f7b3a5d70b7cfaf54628a3175f8b9ef39de7585339d827dcaaf524174aafe0
MD5 f7bd10a04fa35a1792378bdaea235e18
BLAKE2b-256 5f8e0a57c06704e9c9fb7f7fddfda4f435af3f34a5310acfc0092f7967ec132e

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp35-cp35m-macosx_10_6_x86_64.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp35-cp35m-macosx_10_6_x86_64.whl
  • Upload date:
  • Size: 269.1 kB
  • Tags: CPython 3.5m, macOS 10.6+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.6

File hashes

Hashes for pyroomacoustics-0.1.23-cp35-cp35m-macosx_10_6_x86_64.whl
Algorithm Hash digest
SHA256 abe0418e5e098a2b04cb07b93be05076e4d3f95bbd2d16c80d2685d8116895a2
MD5 e218fc1c0617ba2b58eb769fe18270f1
BLAKE2b-256 816074c07757060e2fbb237e112287ea1716fa78bc14e421b41fd7c246b079f6

See more details on using hashes here.

File details

Details for the file pyroomacoustics-0.1.23-cp27-cp27m-macosx_10_6_x86_64.whl.

File metadata

  • Download URL: pyroomacoustics-0.1.23-cp27-cp27m-macosx_10_6_x86_64.whl
  • Upload date:
  • Size: 270.7 kB
  • Tags: CPython 2.7m, macOS 10.6+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

File hashes

Hashes for pyroomacoustics-0.1.23-cp27-cp27m-macosx_10_6_x86_64.whl
Algorithm Hash digest
SHA256 2457737400ccd80d0d61c3b926d775d93433c3a5f6fac4e49da141a03d8700a9
MD5 8a2f5e288ff46ba8e1be8518f274ae76
BLAKE2b-256 ef342ac3b4ce97b8f80ac9081e37432bec0de9369d1522b8ef8f542f8655e785

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