Publication Cover
Bioacoustics
The International Journal of Animal Sound and its Recording
Volume 33, 2024 - Issue 1
1,550
Views
1
CrossRef citations to date
0
Altmetric
Articles

Parselmouth for bioacoustics: automated acoustic analysis in Python

ORCID Icon, ORCID Icon & ORCID Icon
Pages 1-19 | Received 03 May 2023, Accepted 22 Aug 2023, Published online: 13 Oct 2023

Figures & data

Figure 1. A plot of the fundamental frequency estimated through Parselmouth, overlaid on two seal call spectrograms, shows Praat’s ability to correctly track the fundamental frequency, even in the presence of noise. Automated generation of such plots was used to swiftly assess the tracking quality, as to ensure correctness of the results.

Figure 1. A plot of the fundamental frequency estimated through Parselmouth, overlaid on two seal call spectrograms, shows Praat’s ability to correctly track the fundamental frequency, even in the presence of noise. Automated generation of such plots was used to swiftly assess the tracking quality, as to ensure correctness of the results.

Code fragment 1: A short Python function wraps the functionality to estimate the median fundamental frequency using Parselmouth. Note the seamless interaction between Praat functionality (e.g. snd_part.to_pitch(…)), pure-Python syntax (e.g. the function definition or if-statement), and other Python libraries (i.e. NumPy’s np.nanmedian and SciPy’s scipy.stats.iqr) (see Supplemental online material, calculate_pitch.py, https://figshare.com/articles/dataset/Parselmouth_for_bioacoustics_automated_acoustic_analysis_in_Python/24307391?file=42678629).

Code fragment 1: A short Python function wraps the functionality to estimate the median fundamental frequency using Parselmouth. Note the seamless interaction between Praat functionality (e.g. snd_part.to_pitch(…)), pure-Python syntax (e.g. the function definition or if-statement), and other Python libraries (i.e. NumPy’s np.nanmedian and SciPy’s scipy.stats.iqr) (see Supplemental online material, calculate_pitch.py, https://figshare.com/articles/dataset/Parselmouth_for_bioacoustics_automated_acoustic_analysis_in_Python/24307391?file=42678629).

Code fragment 2: The use of Python and Parselmouth renders stimulus generation reusable and reproducible. Python functions help to compartmentalise the code, and Python’s built-in data structures (i.e. lists and dictionaries) allow the programmer to reuse existing programming experience and paradigms in combination with Parselmouth’s functionality (see Supplemental online material, generate_playbacks.py, https://figshare.com/articles/dataset/Parselmouth_for_bioacoustics_automated_acoustic_analysis_in_Python/24307391?file=42678626).

Code fragment 2: The use of Python and Parselmouth renders stimulus generation reusable and reproducible. Python functions help to compartmentalise the code, and Python’s built-in data structures (i.e. lists and dictionaries) allow the programmer to reuse existing programming experience and paradigms in combination with Parselmouth’s functionality (see Supplemental online material, generate_playbacks.py, https://figshare.com/articles/dataset/Parselmouth_for_bioacoustics_automated_acoustic_analysis_in_Python/24307391?file=42678626).

Code fragment 3: Parselmouth’s formant analysis and SciPy’s convex hull calculations are combined in a handful of lines of Python code to calculate the 2-dimensional formant range of synthesised speech fragments (see Supplemental online material, plot_for mant_triangles.py, https://figshare.com/articles/dataset/Parselmouth_for_bioacoustics_automated_acoustic_analysis_in_Python/24307391?file=42678623).

Code fragment 3: Parselmouth’s formant analysis and SciPy’s convex hull calculations are combined in a handful of lines of Python code to calculate the 2-dimensional formant range of synthesised speech fragments (see Supplemental online material, plot_for mant_triangles.py, https://figshare.com/articles/dataset/Parselmouth_for_bioacoustics_automated_acoustic_analysis_in_Python/24307391?file=42678623).

Figure 2. A scatterplot of the values of the first two formants tracked by Praat, accompanied by the convex hull encompassing all the points. A single Python script performed the formant analysis through Parselmouth, calculated the convex hull with SciPy, and plotted the result with the matplotlib library. To demonstrate the advantages of having scripted the analysis, we swiftly recreated the plots with new data and tweaked the figure’s aesthetics (cfr. Rasilo and Jadoul Citation2020).

Figure 2. A scatterplot of the values of the first two formants tracked by Praat, accompanied by the convex hull encompassing all the points. A single Python script performed the formant analysis through Parselmouth, calculated the convex hull with SciPy, and plotted the result with the matplotlib library. To demonstrate the advantages of having scripted the analysis, we swiftly recreated the plots with new data and tweaked the figure’s aesthetics (cfr. Rasilo and Jadoul Citation2020).

Table 1. A wide variety of research fields and studies have made use of Parselmouth. A majority of these studies use Parselmouth to perform acoustic feature extraction (AFE).

Supplemental material

plot_formant_triangles.py

Download (843 B)

generate_playbacks.py

Download (1.9 KB)

calculate_pitch.py

Download (727 B)