Praat in Python, the Pythonic way

Related tags

Audio Parselmouth
Overview

Parselmouth

Parselmouth - Praat in Python, the Pythonic way

PyPI Gitter chat GitHub Actions status ReadTheDocs status License Launch Binder

Parselmouth is a Python library for the Praat software.

Though other attempts have been made at porting functionality from Praat to Python, Parselmouth is unique in its aim to provide a complete and Pythonic interface to the internal Praat code. While other projects either wrap Praat's scripting language or reimplementing parts of Praat's functionality in Python, Parselmouth directly accesses Praat's C/C++ code (which means the algorithms and their output are exactly the same as in Praat) and provides efficient access to the program's data, but also provides an interface that looks no different from any other Python library.

Drop by our Gitter chat room or post a message to our Google discussion group if you have any question, remarks, or requests!

Try out Parselmouth online, in interactive Jupyter notebooks on Binder.

Warning: Parselmouth 0.4.0 is the last version supporting Python 2. Python 2 has reached End Of Life on January 1, 2020, and is officially not supported anymore: see https://python3statement.org/. Please move to Python 3, to be able to keep using new Parselmouth functionality.

Installation

Parselmouth can be installed like any other Python library, using (a recent version of) the Python package manager pip, on Linux, macOS, and Windows:

pip install praat-parselmouth

or, to update your installed version to the latest release:

pip install -U praat-parselmouth

For more detailed instructions, please refer to the documentation.

Example usage

import parselmouth

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

sns.set() # Use seaborn's default style to make attractive graphs

# Plot nice figures using Python's "standard" matplotlib library
snd = parselmouth.Sound("docs/examples/audio/the_north_wind_and_the_sun.wav")
plt.figure()
plt.plot(snd.xs(), snd.values.T)
plt.xlim([snd.xmin, snd.xmax])
plt.xlabel("time [s]")
plt.ylabel("amplitude")
plt.show() # or plt.savefig("sound.png"), or plt.savefig("sound.pdf")

docs/images/example_sound.png

def draw_spectrogram(spectrogram, dynamic_range=70):
    X, Y = spectrogram.x_grid(), spectrogram.y_grid()
    sg_db = 10 * np.log10(spectrogram.values)
    plt.pcolormesh(X, Y, sg_db, vmin=sg_db.max() - dynamic_range, cmap='afmhot')
    plt.ylim([spectrogram.ymin, spectrogram.ymax])
    plt.xlabel("time [s]")
    plt.ylabel("frequency [Hz]")

def draw_intensity(intensity):
    plt.plot(intensity.xs(), intensity.values.T, linewidth=3, color='w')
    plt.plot(intensity.xs(), intensity.values.T, linewidth=1)
    plt.grid(False)
    plt.ylim(0)
    plt.ylabel("intensity [dB]")

intensity = snd.to_intensity()
spectrogram = snd.to_spectrogram()
plt.figure()
draw_spectrogram(spectrogram)
plt.twinx()
draw_intensity(intensity)
plt.xlim([snd.xmin, snd.xmax])
plt.show() # or plt.savefig("spectrogram.pdf")

docs/images/example_spectrogram.png

def draw_pitch(pitch):
    # Extract selected pitch contour, and
    # replace unvoiced samples by NaN to not plot
    pitch_values = pitch.selected_array['frequency']
    pitch_values[pitch_values==0] = np.nan
    plt.plot(pitch.xs(), pitch_values, 'o', markersize=5, color='w')
    plt.plot(pitch.xs(), pitch_values, 'o', markersize=2)
    plt.grid(False)
    plt.ylim(0, pitch.ceiling)
    plt.ylabel("fundamental frequency [Hz]")

pitch = snd.to_pitch()
# If desired, pre-emphasize the sound fragment before calculating the spectrogram
pre_emphasized_snd = snd.copy()
pre_emphasized_snd.pre_emphasize()
spectrogram = pre_emphasized_snd.to_spectrogram(window_length=0.03, maximum_frequency=8000)
plt.figure()
draw_spectrogram(spectrogram)
plt.twinx()
draw_pitch(pitch)
plt.xlim([snd.xmin, snd.xmax])
plt.show() # or plt.savefig("spectrogram_0.03.pdf")

docs/images/example_spectrogram_0.03.png

# Find all .wav files in a directory, pre-emphasize and save as new .wav and .aiff file
import parselmouth

import glob
import os.path

for wave_file in glob.glob("audio/*.wav"):
    print("Processing {}...".format(wave_file))
    s = parselmouth.Sound(wave_file)
    s.pre_emphasize()
    s.save(os.path.splitext(wave_file)[0] + "_pre.wav", 'WAV') # or parselmouth.SoundFileFormat.WAV instead of 'WAV'
    s.save(os.path.splitext(wave_file)[0] + "_pre.aiff", 'AIFF')

More examples of different use cases of Parselmouth can be found in the documentation's examples section.

Documentation

Documentation is available at ReadTheDocs, including the API reference of Parselmouth.

Development

Currently, the actual project and Parselmouth's code is not very well documented. Or well, hardly documented at all. That is planned to still change in order to allow for easier contribution to this open source project. Until that day in some undefined future, if you want to contribute to Parselmouth, do let me know on Gitter or by email, and I will very gladly guide you through the project and help you get started.

Briefly summarized, Parselmouth is built using cmake. Next to that, to manually build Parselmouth, the only requirement is a modern C++ compiler supporting the C++17 standard.

Acknowledgements

  • Parselmouth builds on the extensive code base of Praat by Paul Boersma, which actually implements the huge variety of speech processing and phonetic algorithms that can now be accessed through Parselmouth.
  • In order to do so, Parselmouth makes use of the amazing pybind11 library, allowing to expose the C/C++ functionality of Praat as a Python interface.
  • Special thanks go to Bill Thompson and Robin Jadoul for their non-visible-in-history but very valuable contributions.

License

Comments
  • Can't install the library

    Can't install the library

    I am using Linux OS (Ubuntu 16.04) and Python version 3.5.

    I have just installed the library (on my Anaconda virtenv) and I am getting an error when trying to import it:

    import parselmouth
    

    "Traceback (most recent call last): File "", line 1, in File "/home/taras/anaconda3/envs/CondaEnvPy3Tf/lib/python3.5/site-packages/parselmouth/init.py", line 22, in from parselmouth.base import Parselmouth File "/home/taras/anaconda3/envs/CondaEnvPy3Tf/lib/python3.5/site-packages/parselmouth/base.py", line 30, in from parselmouth.adapters.dfp.interface import DFPInterface File "/home/taras/anaconda3/envs/CondaEnvPy3Tf/lib/python3.5/site-packages/parselmouth/adapters/dfp/interface.py", line 17, in from urllib import quote ImportError: cannot import name 'quote' "

    opened by Svito-zar 29
  • ImportError: DLL load failed: %1 is not a valid Win32 application.

    ImportError: DLL load failed: %1 is not a valid Win32 application.

    @jyothika12 Seems your additional problem from #10 is bigger than expected. Let's continue the discussion here, in a separate issue.

    I have just tried the same on a freshly installed Python 3.7, 32-bit on a Windows installation, but I cannot reproduce the error:

    C:\Users\Yannick>powershell                                                                                                                                                                                                                                                        
    Windows PowerShell                                                                                                                                                                                                                                                                 
    Copyright (C) Microsoft Corporation. All rights reserved.                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                       
    PS C:\Users\Yannick> & 'C:\Program Files (x86)\Python37-32/python.exe'                                                                                                                                                                                                             
    Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32                                                                                                                                                                                       
    Type "help", "copyright", "credits" or "license" for more information.                                                                                                                                                                                                             
    >>> ls                                                                                                                                                                                                                                                                             
    Traceback (most recent call last):                                                                                                                                                                                                                                                 
      File "<stdin>", line 1, in <module>                                                                                                                                                                                                                                              
    NameError: name 'ls' is not defined                                                                                                                                                                                                                                                
    >>> import sys                                                                                                                                                                                                                                                                     
    >>> import subprocess                                                                                                                                                                                                                                                              
    >>> subprocess.call([sys.executable, "-m", "pip", "install", "-U", "--force-reinstall", "praat-parselmouth"])                                                                                                                                                                      
    Collecting praat-parselmouth                                                                                                                                                                                                                                                       
      Downloading https://files.pythonhosted.org/packages/3b/32/f344046db6759ed2b3939f7671caf469ad15489dfe97c56b37807d4c4232/praat_parselmouth-0.3.3-cp37-cp37m-win32.whl (6.9MB)                                                                                                      
        100% |████████████████████████████████| 6.9MB 2.0MB/s                                                                                                                                                                                                                          
    Collecting numpy>=1.7.0 (from praat-parselmouth)                                                                                                                                                                                                                                   
      Downloading https://files.pythonhosted.org/packages/07/46/656c25b39fc152ea525eef14b641993624a6325a8ae815b200de57cff0bc/numpy-1.16.4-cp37-cp37m-win32.whl (10.0MB)                                                                                                                
        100% |████████████████████████████████| 10.0MB 2.1MB/s                                                                                                                                                                                                                         
    Installing collected packages: numpy, praat-parselmouth                                                                                                                                                                                                                            
      The script f2py.exe is installed in 'C:\Program Files (x86)\Python37-32\Scripts' which is not on PATH.                                                                                                                                                                           
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.                                                                                                                                                                
    Successfully installed numpy-1.16.4 praat-parselmouth-0.3.3                                                                                                                                                                                                                        
    You are using pip version 19.0.3, however version 19.1.1 is available.                                                                                                                                                                                                             
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.                                                                                                                                                                                               
    0                                                                                                                                                                                                                                                                                  
    >>> import parselmouth                                                                                                                                                                                                                                                             
    >>>                         
    
    opened by YannickJadoul 21
  • Installation Failing when using Visual Studio 2022 and Windows 11

    Installation Failing when using Visual Studio 2022 and Windows 11

    System Information

    Operating System - Windows 11 Python Version - 3.10.0 Visual Studio - Visual Studio 2022 Package Manager - PIP

    Description

    The problem may be due to Windows 11 or VS 2022. When I try to install the package, it gives me the following error:

    Building wheels for collected packages: praat-parselmouth
      Building wheel for praat-parselmouth (PEP 517) ... error
      ERROR: Command errored out with exit status 1:
       command: 'C:\Users\soham\miniconda3\python.exe' 'C:\Users\soham\miniconda3\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\soham\AppData\Local\Temp\tmp1gyd0p55'
           cwd: C:\Users\soham\AppData\Local\Temp\pip-install-ehh6vn7e\praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e
      Complete output (343 lines):
      WARNING: '' not a valid package name; please use only .-separated package names in setup.py
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      CMake Error at CMakeLists.txt:2 (PROJECT):
        Generator
    
          Visual Studio 16 2019
    
        could not find any instance of Visual Studio.
    
    
    
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      CMake Error at CMakeLists.txt:2 (PROJECT):
        Running
    
         'nmake' '-?'
    
        failed with:
    
         The system cannot find the file specified
    
    
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      -- The C compiler identification is unknown
      CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
        The CMAKE_C_COMPILER:
    
          cl
    
        is not a full path and was not found in the PATH.
    
        To use the JOM generator with Visual C++, cmake must be run from a shell
        that can use the compiler cl from the command line.  This environment is
        unable to invoke the cl compiler.  To fix this problem, run cmake from the
        Visual Studio Command Prompt (vcvarsall.bat).
    
        Tell CMake where to find the compiler by setting either the environment
        variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
        the compiler, or to the compiler name if it is in the PATH.
    
    
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      CMake Error at CMakeLists.txt:2 (PROJECT):
        Generator
    
          Visual Studio 15 2017
    
        could not find any instance of Visual Studio.
    
    
    
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      CMake Error at CMakeLists.txt:2 (PROJECT):
        Running
    
         'nmake' '-?'
    
        failed with:
    
         The system cannot find the file specified
    
    
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      Not searching for unused variables given on the command line.
      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.
    
        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.
    
    
      -- The C compiler identification is unknown
      CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
        The CMAKE_C_COMPILER:
    
          cl
    
        is not a full path and was not found in the PATH.
    
        To use the JOM generator with Visual C++, cmake must be run from a shell
        that can use the compiler cl from the command line.  This environment is
        unable to invoke the cl compiler.  To fix this problem, run cmake from the
        Visual Studio Command Prompt (vcvarsall.bat).
    
        Tell CMake where to find the compiler by setting either the environment
        variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
        the compiler, or to the compiler name if it is in the PATH.
    
    
      -- Configuring incomplete, errors occurred!
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
      See also "C:/Users/soham/AppData/Local/Temp/pip-install-ehh6vn7e/praat-parselmouth_8aabdbb89a704e4daaa852d44164ce2e/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
    
    
      --------------------------------------------------------------------------------
      -- Trying "Ninja (Visual Studio 16 2019 x64 v141)" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "Ninja (Visual Studio 16 2019 x64 v141)" generator - failure
      --------------------------------------------------------------------------------
    
    
    
      --------------------------------------------------------------------------------
      -- Trying "Visual Studio 16 2019 x64 v141" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "Visual Studio 16 2019 x64 v141" generator - failure
      --------------------------------------------------------------------------------
    
    
    
      --------------------------------------------------------------------------------
      -- Trying "NMake Makefiles (Visual Studio 16 2019 x64 v141)" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "NMake Makefiles (Visual Studio 16 2019 x64 v141)" generator - failure
      --------------------------------------------------------------------------------
    
    
    
      --------------------------------------------------------------------------------
      -- Trying "NMake Makefiles JOM (Visual Studio 16 2019 x64 v141)" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "NMake Makefiles JOM (Visual Studio 16 2019 x64 v141)" generator - failure
      --------------------------------------------------------------------------------
    
    
    
      --------------------------------------------------------------------------------
      -- Trying "Ninja (Visual Studio 15 2017 x64 v141)" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "Ninja (Visual Studio 15 2017 x64 v141)" generator - failure
      --------------------------------------------------------------------------------
    
    
    
      --------------------------------------------------------------------------------
      -- Trying "Visual Studio 15 2017 x64 v141" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "Visual Studio 15 2017 x64 v141" generator - failure
      --------------------------------------------------------------------------------
    
    
    
      --------------------------------------------------------------------------------
      -- Trying "NMake Makefiles (Visual Studio 15 2017 x64 v141)" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "NMake Makefiles (Visual Studio 15 2017 x64 v141)" generator - failure
      --------------------------------------------------------------------------------
    
    
    
      --------------------------------------------------------------------------------
      -- Trying "NMake Makefiles JOM (Visual Studio 15 2017 x64 v141)" generator
      --------------------------------
      ---------------------------
      ----------------------
      -----------------
      ------------
      -------
      --
      --
      -------
      ------------
      -----------------
      ----------------------
      ---------------------------
      --------------------------------
      -- Trying "NMake Makefiles JOM (Visual Studio 15 2017 x64 v141)" generator - failure
      --------------------------------------------------------------------------------
    
      ********************************************************************************
      scikit-build could not get a working generator for your system. Aborting build.
    
      Building Windows wheels for requires Microsoft Visual Studio 2017 or 2019:
    
        https://visualstudio.microsoft.com/vs/
    
      ********************************************************************************
      ----------------------------------------
      ERROR: Failed building wheel for praat-parselmouth
    Failed to build praat-parselmouth
    ERROR: Could not build wheels for praat-parselmouth which use PEP 517 and cannot be installed directly
    
    opened by SohamSen15 15
  • Segfault when computing formants on stereo audio from array

    Segfault when computing formants on stereo audio from array

    Hey,

    First, i'd like to thank you again for your work on parselmouth. It's an amazing work. I ran into a small problem that can become a bit troublesome since this won't output any stacktrace. An example is worth a thousand words:

    from parselmouth import Sound
    from scipy.io.wavfile import read
    rate, array = read("some_stereo_audio.wav")
    snd = Sound(array, rate)
    snd.to_formant_burg() # <--------- this will segfault
    

    However, this works if I load the sound directly from the path (snd = Sound("some_stereo_audio.wav")).

    I'm running python 3.8 on ubuntu, but this segfaulted all the same on a python 3.7 on centos. I tested it on all parselmouth versions >= 0.3.2

    opened by hadware 13
  • Building wheel hangs on ppc64le

    Building wheel hangs on ppc64le

    When installing praat-parselmouth using pip install praat-parselmouth inside a conda environment on a power9 ppc64le system. The installation always hangs at this step

    Building wheels for collected packages: praat-parselmouth Building wheel for praat-parselmouth (pyproject.toml) ...

    opened by auspicious3000 10
  • package version 0.3.2.post2

    package version 0.3.2.post2

    I found the version in wheel meta (0.3.2) does not match the version provided on pypi (0.3.2.post2). It may cause problems when installing with version specifications like pip install praat_parselmouth==0.3.2. Hope the wheel could contain the right version (assign version="0.3.2.post2" in setup.py) or just preserve the package of version 0.3.2 on pypi.

    opened by craynic 9
  • Breaks JSON package in Python 3.7 on Arch linux

    Breaks JSON package in Python 3.7 on Arch linux

    No idea why this is the case, but importing parselmouth has caused the JSON library to stop working, I assume due to some sort of reassignment of json.load or something similar.

    Minimal case:

    import json
    import parselmouth
    with open("main_survey", "r") as f:
          survey = json.load(f)
    

    crashes, while if I run it without importing parselmouth it works fine.

    output

    Traceback (most recent call last):
      File "test.py", line 5, in <module>
        survey = json.load(f)
      File "/usr/lib/python3.7/json/__init__.py", line 293, in load
        return loads(fp.read(),
      File "/usr/lib/python3.7/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 4486: ordinal not in range(128)
    
    opened by MichaelGoodale 9
  • "parselmouth.praat.run_file" is not thread safe?

    objects = run_file(mltrnl_praat, -20, 2, 0.3, "no", wavfile, path, 80, 400, 0.01, capture_output=True)
    print(objects)
    

    The arguments is same, but sometimes return objects is not same.

    run_file can be called by different threads?

    opened by hebo1982 8
  • Bump jwlawson/actions-setup-cmake from v1.6 to v1.7

    Bump jwlawson/actions-setup-cmake from v1.6 to v1.7

    Bumps jwlawson/actions-setup-cmake from v1.6 to v1.7.

    Release notes

    Sourced from jwlawson/actions-setup-cmake's releases.

    v1.7

    • Specify GitHub API version in request headers
    • Provide fallback when Link headers are unavailable
    • Remove async from some functions
    • Update dependencies
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    dependencies github_actions 
    opened by dependabot[bot] 7
  • Memory issues when generating voice report in bulk

    Memory issues when generating voice report in bulk

    OS: Ubuntu 18.04.4 LTS python: 3.7.5

    I am running the below function in a loop iterating over audio files between 10~60 seconds long.

    def calc_voice_report(input_audio):
        sound = parselmouth.Sound(input_audio)
        pitch = sound.to_pitch()
        pulses = parselmouth.praat.call([sound, pitch], "To PointProcess (cc)")
        voice_report_str = \
            parselmouth.praat.call([sound, pitch, pulses], "Voice report", 0.0, 0.0, 75, 600, 1.3, 1.6, 0.03, 0.45)
        return voice_report_str
    

    The resulting string is then parsed and saved into a csv.

    After around 3k~8k files I ran into some sort of memory issue, either:

    • SIGFAULT 6
    • a parselmouth error stating that it's out of memory (did not save the error message will write it down if it happens again next time)
    • a computer freeze

    I had similar issues running praat voice report in a praat script (using subprocess to call it from python) which makes me think there is a memory leak caused by the voice report module.

    Is there a way to fully "clear" parselmouth of it's memory after a parselmouth.praat.call?

    opened by kkawabat 7
  • Extracting 12 Mel-frequency cepstral coefficients

    Extracting 12 Mel-frequency cepstral coefficients

    Hi Yannick, I was hoping you might be willing to help me get past just one more issue:

    I'm trying to extract 12 Mel-frequency cepstral coefficients (MFCCs) from a .wav file, and when I do the following:

    sound = parselmouth.Sound(path)
    mfcc_object = sound.to_mfcc(number_of_coefficients=12)
    mfccs = mfcc_object.extract_features()
    mfcc_arr = mfccs.as_array()
    print(mfcc_arr.shape)
    

    ...the result on 3 different .wavs are

    (4, 21)
    (4, 2439)
    (4, 114)
    

    I'm expecting the resulting arrays to be 12 by (something), not 4 by (something). Where am I going wrong?

    opened by calebstrait 7
  • Missing import praat

    Missing import praat

    Hello, I have a problem with the using of praat I tried this : from parselmouth.praat import call, run_file But I met this error Import "parselmouth.praat" could not be resolved(reportMissingImports) By the way I had installed parselmouth with pip install praat-parselmouth Have you any ideas to help me ?

    Thank you!

    opened by Guillaume-Risch 5
  • Formant calculation not as accurate as in the Praat software

    Formant calculation not as accurate as in the Praat software

    I tried to use Parselmouth's to_formant_burg(time_step=0.032) to calculate formants, but the returned values on the same audio file are very inaccurate compared to results from the Praat software. What are some potential causes for this difference in accuracy with the same software? Is it possible that Praat is using To Formant (robust) rather than To Formant (burg)?

    image

    image

    opened by hykilpikonna 2
  • Segmentation fault (core dumped) on ppc64le

    Segmentation fault (core dumped) on ppc64le

    System: power 9, linux ppc64le Anaconda version: Anaconda3-2021.11-Linux-ppc64le.sh, Anaconda3-2020.11-Linux-ppc64le.sh python version: 3.7, 3.8 parselmouth version: 0.4.0

    After successful installation using pip install, 'import parselmouth' gives Segmentation fault (core dumped). parselmouth version 0.3.3 can work but I would like to install 0.4.0.

    Are there alternative ways to install such as compiling from source?

    Thanks!

    opened by auspicious3000 3
  • parselmouth.praat.call stuck in

    parselmouth.praat.call stuck in "Change gender"

    Hello,

    I have multiple processes of a function calling the parselmouth.praat.call(...). After certain number of iterations, the program hangs forever. Is this because the praat.call() also spawns another subprocess? What would be the recommended way to use praat.call in multiprocessing?

    Thanks!

    opened by auspicious3000 13
  • case-insensitive-enums

    case-insensitive-enums

    Yannick,

    Here is a quick take on making Praat enums case-insensitive.

    Donno if this is the direction you'd like to take, but it's an easy mod. Take a look.

    P.S., test_enums.py was added more for my verification and demonstration to you. Feel free to delete it if you decide to add this feature.

    opened by hokiedsp 1
Releases(v0.4.3)
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
ianZiPu is a way to write notation for Guqin (古琴) music.

JianZiPu Font JianZiPu is a way to write notation for Guqin (古琴) music. This document will cover how to use this font, and how to contribute to its de

Nancy Yi Liang 8 Nov 25, 2022
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 419 Dec 26, 2022
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
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
nicfit 425 Jan 1, 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
Read music meta data and length of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python 2 or 3

tinytag tinytag is a library for reading music meta data of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python Install pip install tinytag

Tom Wallroth 577 Dec 26, 2022
Telegram Voice-Chat Bot Written In Python Using Pyrogram.

Telegram Voice-Chat Bot Telegram Voice-Chat Bot To Play Music From Various Sources In Your Group Support All linux based os. Windows Mac Diagram Requi

TheHamkerCat 314 Dec 29, 2022
Expressive Digital Signal Processing (DSP) package for Python

AudioLazy Development Last release PyPI status Real-Time Expressive Digital Signal Processing (DSP) Package for Python! Laziness and object representa

Danilo de Jesus da Silva Bellini 642 Dec 26, 2022
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
Python wrapper around sox.

pysox Python wrapper around sox. Read the Docs here. This library was presented in the following paper: R. M. Bittner, E. J. Humphrey and J. P. Bello,

Rachel Bittner 446 Dec 7, 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
Read music meta data and length of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python 2 or 3

tinytag tinytag is a library for reading music meta data of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python Install pip install tinytag

Tom Wallroth 435 Feb 17, 2021
Python library for handling audio datasets.

AUDIOMATE Audiomate is a library for easy access to audio datasets. It provides the datastructures for accessing/loading different datasets in a gener

Matthias 121 Nov 27, 2022
python wrapper for rubberband

pyrubberband A python wrapper for rubberband. For now, this just provides lightweight wrappers for pitch-shifting and time-stretching. All processing

Brian McFee 106 Nov 28, 2022
Expressive Digital Signal Processing (DSP) package for Python

AudioLazy Development Last release PyPI status Real-Time Expressive Digital Signal Processing (DSP) Package for Python! Laziness and object representa

Danilo de Jesus da Silva Bellini 573 Feb 8, 2021