A Python package for voice analysis using Praat and Parselmouth.
Project description
Vocalysis
Vocalysis is a Python package that provides a simple interface for extracting a range of acoustic voice measures using Praat via the Parselmouth library.
Below is a list of all available functions, along with brief descriptions and usage examples.
measure_pitch()
Computes basic pitch statistics (in Hz) from an audio file (WAV or another format supported by Praat) or a precomputed Parselmouth object.
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A preloaded Parselmouth Sound object. Used ifpitch_objectis not provided.pitch_object(parselmouth.Pitch, optional):
A precomputed Parselmouth Pitch object. Takes precedence over bothsound_objectandaudio_path.min_pitch(float, optional):
Minimum pitch to consider in Hz. Defaults to75.max_pitch(float, optional):
Maximum pitch to consider in Hz. Defaults to500.
If more than one input is provided, the function prioritizes them in the following order:
pitch_object > sound_object > audio_path
Returns:
The function returns a dictionary with the following keys:
'median': Median pitch'mean': Mean pitch'std': Standard deviation of pitch'min': Minimum pitch'max': Maximum pitch
All values are formatted as strings with the "Hz" unit (e.g., "142.537 Hz").
Example:
from vocalysis import measure_pitch
stats = measure_pitch(audio_path="path/to/speech.wav")
print(stats["mean"]) # e.g., '142.537 Hz'
measure_pulses()
Computes pulse-related statistics from an audio file (WAV or another format supported by Praat) or a precomputed Parselmouth object.
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A preloaded ParselmouthSoundobject. Used to computepitch_objectand/orpoint_processif they are not provided.pitch_object(parselmouth.Pitch, optional):
A precomputed ParselmouthPitchobject. Used to compute thepoint_processif it is not provided.point_process(parselmouth.PointProcess, optional):
A precomputedPointProcessobject. If provided, it is used directly, andaudio_path,sound_object, andpitch_objectare ignored.min_pitch(float, optional):
Minimum pitch to consider (in Hz). Defaults to75. Used for pitch estimation ifpitch_objectis not provided.max_pitch(float, optional):
Maximum pitch to consider (in Hz). Defaults to500. Used for pitch estimation ifpitch_objectis not provided.
If multiple inputs are provided, the function prioritizes them in the following order:
point_process > pitch_object > sound_object > audio_path
Returns:
The function returns a dictionary with the following keys:
'num_pulses': Total number of glottal pulses'num_periods': Number of periods between pulses'mean_period': Mean period in seconds (e.g.,"0.0050364095 seconds"), orNoneif not computable'std_period': Standard deviation of period in seconds (formatted as string), orNone
Example:
from vocalysis import measure_pulses
stats = measure_pulses(audio_path="path/to/speech.wav")
print(stats["mean_period"]) # e.g., '0.0050364095 seconds'
measure_voicing()
Computes voicing statistics from an audio file (WAV or another format supported by Praat) or precomputed Parselmouth objects.
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A preloaded Parselmouth Sound object. Required ifaudio_pathis not given.pitch_object(parselmouth.Pitch, optional):
A precomputed Parselmouth Pitch object. Required ifpoint_processis supplied.point_process(parselmouth.PointProcess, optional):
A precomputed PointProcess object. If provided,pitch_objectmust also be given, and eithersound_objectoraudio_pathis still required (for duration).min_pitch(float, optional):
Minimum pitch to consider in Hz. Defaults to75. Used for pitch estimation ifpitch_objectis not supplied.max_pitch(float, optional):
Maximum pitch to consider in Hz. Defaults to500. Used for pitch estimation ifpitch_objectis not supplied.
Requirements Summary:
- At least one of
audio_pathorsound_objectmust be provided. - If
point_processis given,pitch_objectmust also be provided. - If both
point_processandpitch_objectare given, eithersound_objectoraudio_pathis still required to compute total signal duration.
Returns:
The function returns a dictionary with the following keys:
'unvoiced_fraction': Percentage of unvoiced frames (e.g.,"12.345%")'num_voice_breaks': Number of detected voice breaks'degree_voice_breaks': Total duration of voice breaks as a percentage of the signal duration (e.g.,"4.789%")
Example:
from vocalysis import measure_voicing
stats = measure_voicing(audio_path="path/to/speech.wav")
print(stats["num_voice_breaks"]) # e.g., 15
measure_jitter()
Measures jitter statistics from an audio file (WAV or another format supported by Praat) or precomputed Parselmouth objects.
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A precomputed Parselmouth Sound object. Used directly to compute pitch and point process ifpoint_processis not provided.pitch_object(parselmouth.Pitch, optional):
A precomputed Pitch object. Used when computing thepoint_process. If not provided, pitch will be computed automatically.point_process(parselmouth.PointProcess, optional):
A precomputed PointProcess object. If provided, it will be used directly for jitter analysis, and pitch or sound will not be recomputed.min_pitch(float, optional):
Minimum pitch value in Hz used during pitch extraction. Defaults to75.max_pitch(float, optional):
Maximum pitch value in Hz used during pitch extraction. Defaults to600.
If more than one input is provided, the function prioritizes in the following order:
point_process > sound_object > audio_path
Returns:
The function returns a dictionary with the following keys:
'jitter_local': Local jitter as a percentage (e.g.,"4.123%")'jitter_local_absolute': Local absolute jitter in seconds (e.g.,"0.000123")'jitter_rap': Relative average perturbation (RAP) jitter as a percentage'jitter_ppq5': 5-point period perturbation quotient (PPQ5) jitter as a percentage'jitter_ddp': Difference of differences of periods (DDP) jitter as a percentage
Example:
from vocalysis import measure_jitter
stats = measure_jitter(audio_path="path/to/speech.wav")
print(stats["jitter_local"]) # e.g., '4.123%'
measure_shimmer()
Measures shimmer statistics from an audio file (WAV or another format supported by Praat) or precomputed Parselmouth objects.
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A precomputed Parselmouth Sound object. Used directly to compute pitch and point process ifpoint_processis not provided, or to supplement an existingpoint_process.pitch_object(parselmouth.Pitch, optional):
A precomputed Pitch object. Used when computing thepoint_process. If not provided, pitch will be computed automatically.point_process(parselmouth.PointProcess, optional):
A precomputed PointProcess object. If provided, it will be used directly for shimmer analysis. In this case, eithersound_objectoraudio_pathmust also be provided.min_pitch(float, optional):
Minimum pitch value in Hz used during pitch extraction. Defaults to75.max_pitch(float, optional):
Maximum pitch value in Hz used during pitch extraction. Defaults to500.
If more than one input is provided, the function prioritizes them in the following order:
point_process > sound_object > audio_path
Returns:
The function returns a dictionary with the following keys:
'shimmer_local': Local shimmer as a percentage (e.g.,"8.340%")'shimmer_local_dB': Local shimmer in decibels (e.g.,"0.123 dB")'shimmer_apq3': 3-point amplitude perturbation quotient (APQ3) as a percentage'shimmer_apq5': 5-point amplitude perturbation quotient (APQ5) as a percentage'shimmer_apq11': 11-point amplitude perturbation quotient (APQ11) as a percentage'shimmer_dda': Difference of differences of amplitudes (DDA) as a percentage
Example:
from vocalysis import measure_shimmer
stats = measure_shimmer(audio_path="path/to/speech.wav")
print(stats["shimmer_local"]) # e.g., '8.340%'
measure_intensity()
Measures intensity statistics (in decibels) from an audio file (WAV or another format supported by Praat) or precomputed Parselmouth objects.
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A preloaded ParselmouthSoundobject. Used to compute theintensity_objectif it is not provided.intensity_object(parselmouth.Intensity, optional):
A precomputedIntensityobject. If provided, it is used directly, andsound_objectandaudio_pathare ignored.time_step(float, optional):
Time step used for intensity analysis, in seconds. Defaults to0.01.min_pitch(float, optional):
Minimum pitch (in Hz) used during intensity calculation. Defaults to75.0.
If multiple inputs are provided, the function prioritizes them in the following order:
intensity_object > sound_object > audio_path
Returns:
The function returns a dictionary with the following keys:
'intensity_median': Median intensity'intensity_mean': Mean intensity'intensity_std': Standard deviation of intensity'intensity_min': Minimum intensity'intensity_max': Maximum intensity
Example:
from vocalysis import measure_intensity
stats = measure_intensity(audio_path="path/to/speech.wav")
print(stats["intensity_mean"]) # e.g., '81.833 dB'
get_voice_report()
This function serves as a high-level aggregator that performs multiple acoustic analyses, similar to Praat's voice report. It internally calls dedicated measurement functions defined in this package: measure_pitch, measure_pulses, measure_voicing, measure_jitter, measure_shimmer, and measure_intensity.
Arguments:
audio_path(str):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
min_pitch(float, optional):
Minimum pitch to consider (in Hz). Defaults to75. Used for pitch estimation and voicing-related calculations.max_pitch(float, optional):
Maximum pitch to consider (in Hz). Defaults to500. Used for pitch estimation and voicing-related calculations.time_step(float, optional):
Time step (in seconds) used during intensity analysis. Defaults to0.01.
Returns:
The function returns a dictionary with the following keys:
'Pitch': Output ofmeasure_pitch()'Pulses': Output ofmeasure_pulses()'Voicing': Output ofmeasure_voicing()'Jitter': Output ofmeasure_jitter()'Shimmer': Output ofmeasure_shimmer()'Intensity': Output ofmeasure_intensity()
Example:
from vocalysis import get_voice_report
report = get_voice_report(audio_path="path/to/speech.wav")
print(report["Pitch"]["mean"]) # e.g., '142.537 Hz'
print(report["Jitter"]["local_jitter"]) # e.g., '4.123 %'
measure_spectral_shape()
This function calculates four commonly used spectral features to describe the shape of the spectrum.
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).
Recommended default usage. Most users should provide only this argument.
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A preloaded ParselmouthSoundobject. Used directly if provided;audio_pathis ignored.
Returns:
The function returns a dictionary with the following keys:
'center_of_gravity': Spectral centroid in Hz (e.g."2457.31 Hz")'std': Spectral standard deviation in Hz (e.g."1021.87 Hz")'skewness': Spectral skewness (unitless)'kurtosis': Spectral kurtosis (unitless)
Example:
from vocalysis import measure_spectral_shape
stats = measure_spectral_shape(audio_path="path/to/speech.wav")
print(stats["center_of_gravity"]) # e.g., '2457.31 Hz'
measure_formant_statistics()
This function computes six key statistics for each of the first four formants using Praat's Burg method:
Arguments:
audio_path(str, optional):
Path to an audio file supported by Parselmouth (e.g., WAV).formant_ceiling(float, optional):
Maximum formant frequency in Hz for formant analysis.
Defaults to5500.0. Adjust as needed for different speaker types (e.g., lower for adult males).
Advanced options (other arguments):
sound_object(parselmouth.Sound, optional):
A preloaded ParselmouthSoundobject. Used directly if provided;audio_pathis ignored.
Returns:
The function returns a dictionary with the following keys for each formant F1–F4:
'F1_mean','F1_std','F1_min','F1_max','F1_median','F1_bandwidth_median''F2_mean','F2_std', ...,'F4_bandwidth_median'
All values are strings formatted in Hz (e.g."563.42 Hz").
Example:
from vocalysis import measure_formant_statistics
stats = measure_formant_statistics(audio_path="path/to/speech.wav")
print(stats["F2_median"]) # e.g., '1654.88 Hz'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vocalysis-0.2.1.tar.gz.
File metadata
- Download URL: vocalysis-0.2.1.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2ec706c1e29cd87c80508f161a46b9a6260e2df75c8d3b8ecfcf86cb212b11b
|
|
| MD5 |
6fdc912276353e9f422de627557ce273
|
|
| BLAKE2b-256 |
0450518f79646e679c990f658e2aea4d4d832723afa8c582e264b1a7b2b33d18
|
File details
Details for the file vocalysis-0.2.1-py3-none-any.whl.
File metadata
- Download URL: vocalysis-0.2.1-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d32fe2e261d9d56f45e2cc4dba7029c1611e79597df24f2d5d9022a82673db4c
|
|
| MD5 |
559b4503783cce3aed5a08e34a9b2232
|
|
| BLAKE2b-256 |
71b1a2f619686e84608f2f5a918fe39ff19db0354865b9a44033616506a09136
|