{"id":7512,"library":"praat-parselmouth","title":"Parselmouth","description":"Parselmouth is a Python library that provides a Pythonic interface to Praat, a widely used program for phonetic analysis. It wraps Praat's C++ core, allowing direct access to its functionalities for speech processing, acoustic analysis, and manipulation. The current version is 0.4.7, with minor releases and bug fixes occurring frequently.","status":"active","version":"0.4.7","language":"en","source_language":"en","source_url":"https://github.com/YannickJadoul/Parselmouth","tags":["audio","speech_processing","phonetics","praat","acoustic_analysis"],"install":[{"cmd":"pip install praat-parselmouth","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for array manipulation and data representation.","package":"numpy","optional":false},{"reason":"Optional dependency for converting between Praat TextGrid objects and TextGridTools (tgt) library objects.","package":"tgt","optional":true}],"imports":[{"symbol":"parselmouth","correct":"import parselmouth"},{"symbol":"Sound","correct":"import parselmouth\nsound = parselmouth.Sound(...)"},{"symbol":"praat","correct":"import parselmouth\nparselmouth.praat.call(...)"}],"quickstart":{"code":"import parselmouth\nimport numpy as np\n\n# Create a dummy sound object (e.g., a sine wave)\nsr = 44100  # Sample rate\nduration = 1.0 # seconds\nt = np.linspace(0, duration, int(sr * duration), endpoint=False)\nfrequency = 440.0 # Hz\namplitude = 0.5\ndummy_wave = amplitude * np.sin(2 * np.pi * frequency * t)\n\n# Load the sound into Parselmouth\nsound = parselmouth.Sound(dummy_wave, sr)\n\n# Perform a basic Praat operation: extract pitch\npitch = sound.to_pitch()\n\n# Print some information\nprint(f\"Sound duration: {sound.duration:.2f} seconds\")\nprint(f\"First pitch value (at 0.1s): {pitch.get_value_at_time(0.1):.2f} Hz\")\n\n# Example of using a Praat command directly via parselmouth.praat.call\nintensity = parselmouth.praat.call(sound, \"To Intensity\", 100, 0, False)\nprint(f\"Mean intensity: {intensity.get_mean():.2f} dB\")","lang":"python","description":"This example demonstrates how to create a simple sound object from a NumPy array, perform a common acoustic analysis (pitch extraction), and use `parselmouth.praat.call` for direct Praat commands."},"warnings":[{"fix":"Ensure you have a C++ compiler and CMake installed. Check the official Parselmouth documentation for platform-specific build instructions. Installing `scikit-build-core` might also help: `pip install scikit-build-core`.","message":"Installation of `praat-parselmouth` can fail if a pre-built wheel is not available for your specific Python version and operating system, requiring compilation from source. This needs a C++ compiler (e.g., MSVC, GCC, Clang) and CMake to be installed and configured on your system.","severity":"gotcha","affected_versions":"<0.4.7"},{"fix":"Upgrade Parselmouth to version 0.4.4 or newer: `pip install --upgrade praat-parselmouth`.","message":"Versions of Parselmouth prior to 0.4.4 had compatibility issues with NumPy 2.x, leading to errors when processing audio data or accessing array properties.","severity":"breaking","affected_versions":"<0.4.4"},{"fix":"Upgrade Parselmouth to version 0.3.3 or newer to avoid these specific crash scenarios: `pip install --upgrade praat-parselmouth`.","message":"In older versions of Parselmouth (prior to 0.3.3), using `parselmouth.praat.call` or `parselmouth.praat.run` could lead to crashes when passing empty lists of objects or when returning objects that already existed in Praat's memory.","severity":"gotcha","affected_versions":"<0.3.3"},{"fix":"Always use the latest stable version of Parselmouth for optimal compatibility with recent Python interpreters: `pip install --upgrade praat-parselmouth`.","message":"While Parselmouth aims for broad Python compatibility, explicit support for newer Python versions (e.g., 3.10, 3.11) was added in specific minor releases (v0.4.1, v0.4.2). Using an older Parselmouth version with the very latest Python releases might encounter unexpected issues.","severity":"gotcha","affected_versions":"<0.4.2"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install a C++ compiler (e.g., Visual Studio Build Tools on Windows, Xcode Command Line Tools on macOS, `build-essential` on Debian/Ubuntu, or `cmake` for all platforms) and try `pip install praat-parselmouth` again.","cause":"A pre-built wheel for your specific operating system and Python version was not found, and the system lacks the necessary C++ compiler or build tools (like CMake) to compile Parselmouth from source.","error":"ERROR: Failed building wheel for praat-parselmouth"},{"fix":"Upgrade Parselmouth to version 0.4.4 or higher: `pip install --upgrade praat-parselmouth`.","cause":"This error typically occurs when using Parselmouth versions older than 0.4.4 with a NumPy 2.x installation, due to changes in NumPy's internal structure.","error":"AttributeError: module 'numpy' has no attribute 'array_api'"},{"fix":"Install the library using `pip install praat-parselmouth`. If using virtual environments, ensure the correct environment is activated before running your script.","cause":"The `praat-parselmouth` library has not been installed, or the Python environment where it was installed is not currently active.","error":"ModuleNotFoundError: No module named 'parselmouth'"},{"fix":"Review the Parselmouth documentation for the correct way to interact with objects. Use methods like `sound.to_pitch()` or pass objects to `parselmouth.praat.call(object, 'PraatCommand')`.","cause":"You are attempting to call a Parselmouth object (e.g., an instance of `Sound` or `Pitch`) as if it were a function, instead of using its methods or passing it to `parselmouth.praat.call()`.","error":"TypeError: 'Sound' object is not callable"}]}