A collection of python scripts for extracting and analyzing acoustics from audio files.

Related tags

Audio pyAcoustics
Overview

pyAcoustics

https://img.shields.io/badge/license-MIT-blue.svg?

A collection of python scripts for extracting and analyzing acoustics from audio files.

1   Common Use Cases

What can you do with this library?

  • Extract pitch and intensity:

    pyacoustics.intensity_and_pitch.praat_pi.getPraatPitchAndIntensity()
    
  • Extract segments of a wav file:

    pyacoustics.signals.audio_scripts.getSubwav()
    
  • Perform simple manipulations on wav files:

    pyacoustics.signals.resampleAudio()
    
    pyacoustics.signals.splitStereoAudio()
    
  • Split audio files on segments of silence or on pure tones:

    pyacoustics.speech_detection.split_on_tone.splitFileOnTone()
    
  • Programmatically manipulate pitch or duration of a file:

    pyacoustics.morph.morph_utils.praat_pitch()
    
  • Mask speech with speech shaped noise:

    pyacoustics.speech_filters.speech_shaped_noise.batchMaskSpeakerData()
    
  • And more!

2   Major revisions

Ver 1.0 (June 7, 2015)

  • first public release.

3   Features as they are added

Mask speech with speech shaped noise (March 21, 2016)

Find syllable nuclei/estimate speech rate using Uwe Reichel's matlab code (July 29, 2015)

Find the valley bottom between peaks (July 7th, 2015)

4   Requirements

Many of the individual features require different packages. If you aren't using those packages then you don't need to install the dependencies.

pyacoustics.intensity_and_pitch.praat_pi requires praat

pyacoustics.intensity_and_pitch.get_f0 requires the ESPS getF0 function as implemented by Snack although I recall having difficulty installing it.

pyacoustics.speech_rate/dictionary_estimate.py requires my library psyle

pyacoustics.signals.data_fitting.py requires SciPy, NumPy, and scikit-learn

My praatIO library is used extensively and can be downloaded here

5   Installation

If you on Windows, you can use the installer found here (check that it is up to date though) Windows installer

PyAcoustics is on pypi and can be installed or upgraded from the command-line shell with pip like so:

python -m pip install pyacoustics --upgrade

Otherwise, to manually install, after downloading the source from github, from a command-line shell, navigate to the directory containing setup.py and type:

python setup.py install

If python is not in your path, you'll need to enter the full path e.g.:

C:\Python36\python.exe setup.py install

6   Example usage

See the example folders for a few real-world examples using this library.

  • examples/split_audio_on_silence.py

    Detects the presence of speech in a recording based on acoustic intensity. Everything louder than some threshold specified by the user is considered speech.

  • examples/split_audio_on_tone.py

    Detects the presence of pure tones in a recording. One can use this to automatically segment stimuli. Beeps can be played while the speech is being recorded and then later this tool can automatically segment the speech, based on the presence of those tones.

    Also detects speech using a pitch analysis. Most syllables contain some voicing, so a stream of modulating pitch values suggests that someone is speaking. This aspect is not extensively tested but it works well for the example files.

  • examples/estimate_speech_rate.py

    Calculates the speech rate through a matlab script written by Uwe Reichel that estimates the location of syllable boundaries.

7   Citing LMEDS

PyAcoustics is general purpose coding and doesn't need to be cited but if you would like to, it can be cited like so:

Tim Mahrt. PyAcoustics. https://github.com/timmahrt/pyAcoustics, 2016.

8   Acknowledgements

PyAcoustics is an ongoing collection of code with contributions from a number of projects worked on over several years. Development of various aspects of PyAcoustics was possible thanks to NSF grant IIS 07-03624 to Jennifer Cole and Mark Hasegawa-Johnson, NSF grant BCS 12-51343 to Jennifer Cole, José Hualde, and Caroline Smith, and NSF grant IBSS SMA 14-16791 to Jennifer Cole, Nancy McElwain, and Daniel Berry.

Comments
  • Getting error while running

    Getting error while running "split_audio_on_tone.py"

    Wenn I try to run the script "examples/split_audio_on_tone.py" with the wav-data attached in the folder "files" I get this error:

    Traceback (most recent call last):
      File "/Users/tamaki/Desktop/pyAcoustics/examples/split_audio_on_tone.py", line 72, in <module>
        audiosplitOnTone(_dataPath, _fn, _pitchPath, _tgPath, _wavOutputPath,
      File "/Users/tamaki/Desktop/pyAcoustics/examples/split_audio_on_tone.py", line 52, in audiosplitOnTone
        split_on_tone.extractSubwavs(timeDict, inputPath, fn, subwavPath)
      File "/Users/tamaki/miniconda3/envs/Praktikum/lib/python3.9/site-packages/pyacoustics/speech_detection/split_on_tone.py", line 83, in extractSubwavs
        audio_scripts.extractSubwav(join(path, fn),
      File "/Users/tamaki/miniconda3/envs/Praktikum/lib/python3.9/site-packages/pyacoustics/signals/audio_scripts.py", line 231, in extractSubwav
        audioFrames = getSubwav(fn, startT, endT, singleChannelFlag)
      File "/Users/tamaki/miniconda3/envs/Praktikum/lib/python3.9/site-packages/pyacoustics/signals/audio_scripts.py", line 210, in getSubwav
        audiofile.setpos(int(framerate * startT))
      File "/Users/tamaki/miniconda3/envs/Praktikum/lib/python3.9/wave.py", line 229, in setpos
        raise Error('position not in range')
    wave.Error: position not in range
    

    What am I doing wrong? I am on macOS Catalina 10.15.7 and using python 3.9.0. I also tried it with other versions and It didn't work. Thank you in advance for your answer.

    opened by otamabon1015 2
  • speech segmentation without create file

    speech segmentation without create file

    i want to analyze every segment of speech without creating file...

    i try to make a segmentation of speech with yout script.

    from pyacoustics.signals import audio_scripts as ascr
    wavfile = 'D:/Temp/speech/test.wav'
    duration = ascr.getSoundFileDuration(wavfile)
    splitwav = ascr.getSubwav(wavfile, 0, duration, True)
    
    

    the next step should be get the data for every segment. can you help me to do that?

    opened by wahyubram82 2
  • where is praat_pi.py?

    where is praat_pi.py?

    README mentions pyacoustics.intensity_and_pitch.praat_pi.getPraatPitchAndIntensity(), but there is no praat_pi.py file in that folder. Does someone need to check it in?

    opened by bhomass 2
  • The code contains invalid names

    The code contains invalid names

    openTextGrid: https://github.com/timmahrt/pyAcoustics/blob/master/examples/estimate_speech_rate.py#L100 openTextgrid: https://github.com/timmahrt/praatIO/blob/master/praatio/tgio.py#L1404

    opened by acc-to-learn 1
  • Pyacoustics v2

    Pyacoustics v2

    This PR does the following:

    • [x] standardizes the tests
    • [x] formats files using black
    • [x] drops support for python 2.7
    • [x] upgrades to praatio 5.0 (breaking api changes)
    • [ ] ?
    opened by timmahrt 0
Owner
Tim
I write tools for working with speech data.
Tim
cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python

audioread Decode audio files using whichever backend is available. The library currently supports: Gstreamer via PyGObject. Core Audio on Mac OS X via

beetbox 359 Feb 15, 2021
Audio spatialization over WebRTC and JACK Audio Connection Kit

Audio spatialization over WebRTC Spatify provides a framework for building multichannel installations using WebRTC.

Bruno Gola 34 Jun 29, 2022
Audio augmentations library for PyTorch for audio in the time-domain

Audio augmentations library for PyTorch for audio in the time-domain, with support for stochastic data augmentations as used often in self-supervised / contrastive learning.

Janne 166 Jan 8, 2023
praudio provides audio preprocessing framework for Deep Learning audio applications

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

Valerio Velardo 105 Dec 26, 2022
Automatically move or copy files based on metadata associated with the files. For example, file your photos based on EXIF metadata or use MP3 tags to file your music files.

Automatically move or copy files based on metadata associated with the files. For example, file your photos based on EXIF metadata or use MP3 tags to file your music files.

Rhet Turnbull 14 Nov 2, 2022
Python I/O for STEM audio files

stempeg = stems + ffmpeg Python package to read and write STEM audio files. Technically, stems are audio containers that combine multiple audio stream

Fabian-Robert Stöter 72 Dec 23, 2022
Using python to generate a bat script of repetitive lines of code that differ in some way but can sort out a group of audio files according to their common names

Batch Sorting Using python to generate a bat script of repetitive lines of code that differ in some way but can sort out a group of audio files accord

David Mainoo 1 Oct 29, 2021
This bot can stream audio or video files and urls in telegram voice chats

Voice Chat Streamer This bot can stream audio or video files and urls in telegram voice chats :) ?? Follow me and star this repo for more telegram bot

WiskeyWorm 4 Oct 9, 2022
Carnatic Notes Predictor for audio files

Carnatic Notes Predictor for audio files Link for live application: https://share.streamlit.io/pradeepak1/carnatic-notes-predictor-for-audio-files/mai

null 1 Nov 6, 2021
C++ library for audio and music analysis, description and synthesis, including Python bindings

Essentia Essentia is an open-source C++ library for audio analysis and audio-based music information retrieval released under the Affero GPL license.

Music Technology Group - Universitat Pompeu Fabra 2.3k Jan 3, 2023
An app made in Python using the PyTube and Tkinter libraries to download videos and MP3 audio.

yt-dl (GUI Edition) An app made in Python using the PyTube and Tkinter libraries to download videos and MP3 audio. How do I download this? Windows: Fi

null 1 Oct 23, 2021
Audio fingerprinting and recognition in Python

dejavu Audio fingerprinting and recognition algorithm implemented in Python, see the explanation here: How it works Dejavu can memorize audio by liste

Will Drevo 6k Jan 6, 2023
Python library for audio and music analysis

librosa A python package for music and audio analysis. Documentation See https://librosa.org/doc/ for a complete reference manual and introductory tut

librosa 5.6k Jan 6, 2023
Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications

A Python library for audio feature extraction, classification, segmentation and applications This doc contains general info. Click here for the comple

Theodoros Giannakopoulos 5.1k Jan 2, 2023
Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications

A Python library for audio feature extraction, classification, segmentation and applications This doc contains general info. Click here for the comple

Theodoros Giannakopoulos 3.8k Feb 17, 2021
Python audio and music signal processing library

madmom Madmom is an audio signal processing library written in Python with a strong focus on music information retrieval (MIR) tasks. The library is i

Institute of Computational Perception 1k Dec 26, 2022
A Python 3 script for capturing and recording a SDR stream to a WAV file (or serving it to a HTTP audio stream).

rfsoapyfile A Python 3 script for capturing and recording a SDR stream to a WAV file (or serving it to a HTTP audio stream). The script is threaded fo

null 4 Dec 19, 2022
Scalable audio processing framework written in Python with a RESTful API

TimeSide : scalable audio processing framework and server written in Python TimeSide is a python framework enabling low and high level audio analysis,

Parisson 340 Jan 4, 2023
Python module for handling audio metadata

Mutagen is a Python module to handle audio metadata. It supports ASF, FLAC, MP4, Monkey's Audio, MP3, Musepack, Ogg Opus, Ogg FLAC, Ogg Speex, Ogg The

Quod Libet 1.1k Dec 31, 2022