Parselmouth

0.4.7 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import parselmouth
import numpy as np

# Create a dummy sound object (e.g., a sine wave)
sr = 44100  # Sample rate
duration = 1.0 # seconds
t = np.linspace(0, duration, int(sr * duration), endpoint=False)
frequency = 440.0 # Hz
amplitude = 0.5
dummy_wave = amplitude * np.sin(2 * np.pi * frequency * t)

# Load the sound into Parselmouth
sound = parselmouth.Sound(dummy_wave, sr)

# Perform a basic Praat operation: extract pitch
pitch = sound.to_pitch()

# Print some information
print(f"Sound duration: {sound.duration:.2f} seconds")
print(f"First pitch value (at 0.1s): {pitch.get_value_at_time(0.1):.2f} Hz")

# Example of using a Praat command directly via parselmouth.praat.call
intensity = parselmouth.praat.call(sound, "To Intensity", 100, 0, False)
print(f"Mean intensity: {intensity.get_mean():.2f} dB")

view raw JSON →