{"id":13560689,"url":"https://github.com/YannickJadoul/Parselmouth","last_synced_at":"2025-04-03T16:31:06.161Z","repository":{"id":38048416,"uuid":"93536979","full_name":"YannickJadoul/Parselmouth","owner":"YannickJadoul","description":"Praat in Python, the Pythonic way","archived":false,"fork":false,"pushed_at":"2024-10-29T09:41:06.000Z","size":103214,"stargazers_count":1069,"open_issues_count":19,"forks_count":116,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-11-29T09:10:42.672Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://parselmouth.readthedocs.io/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YannickJadoul.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-06T15:57:13.000Z","updated_at":"2024-11-29T03:26:02.000Z","dependencies_parsed_at":"2024-11-19T11:18:35.324Z","dependency_job_id":null,"html_url":"https://github.com/YannickJadoul/Parselmouth","commit_stats":{"total_commits":952,"total_committers":7,"mean_commits":136.0,"dds":"0.31932773109243695","last_synced_commit":"3659394d1a1bbaff96e129894ce48bcdc60eef75"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YannickJadoul%2FParselmouth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YannickJadoul%2FParselmouth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YannickJadoul%2FParselmouth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YannickJadoul%2FParselmouth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YannickJadoul","download_url":"https://codeload.github.com/YannickJadoul/Parselmouth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246905838,"owners_count":20852818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:00:48.703Z","updated_at":"2025-04-03T16:31:06.144Z","avatar_url":"https://github.com/YannickJadoul.png","language":"C++","funding_links":[],"categories":["C++","Tooling \u0026 Infrastructure","Audio Related Packages"],"sub_categories":["Python Libraries"],"readme":"![Parselmouth](docs/images/logo-full.png)\n# Parselmouth - Praat in Python, the Pythonic way\n\n[![PyPI](https://img.shields.io/pypi/v/praat-parselmouth.svg)](https://pypi.org/project/praat-parselmouth/)\n[![Gitter chat](https://img.shields.io/gitter/room/PraatParselmouth/Lobby.svg?logo=gitter\u0026logoColor=fff\u0026colorB=51bb9b)](https://gitter.im/PraatParselmouth/Lobby)\n[![GitHub Actions status](https://img.shields.io/github/actions/workflow/status/YannickJadoul/Parselmouth/ci.yml?branch=master\u0026logo=github)](https://github.com/YannickJadoul/Parselmouth/actions?query=workflow:CI+branch:master)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/YannickJadoul/Parselmouth/master.svg)](https://results.pre-commit.ci/latest/github/YannickJadoul/Parselmouth/master)\n[![ReadTheDocs status](https://img.shields.io/readthedocs/parselmouth.svg?logo=read-the-docs\u0026logoColor=fff)](https://parselmouth.readthedocs.io/en/latest/)\n[![License](https://img.shields.io/pypi/l/praat-parselmouth.svg)](https://github.com/YannickJadoul/Parselmouth/blob/master/LICENSE)\n[![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/YannickJadoul/Parselmouth/master?urlpath=lab%2Ftree%2Fdocs%2Fexamples)\n\n**Parselmouth** is a Python library for the [Praat](http://www.praat.org) software.\n\nThough 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.\n\nDrop by our [Gitter chat room](https://gitter.im/PraatParselmouth/Lobby) or post a message to our [Google discussion group](https://groups.google.com/d/forum/parselmouth) if you have any question, remarks, or requests!\n\n*Try out* Parselmouth online, in interactive Jupyter notebooks on [Binder](https://mybinder.org/v2/gh/YannickJadoul/Parselmouth/master?urlpath=lab%2Ftree%2Fdocs%2Fexamples).\n\n## Installation\nParselmouth can be installed like any other Python library, using (a recent version of) the Python package manager `pip`, on Linux, macOS, and Windows:\n```\npip install praat-parselmouth\n```\nor, to update your installed version to the latest release:\n```\npip install -U praat-parselmouth\n```\n\nFor more detailed instructions, please refer to the [documentation](https://parselmouth.readthedocs.io/en/stable/installation.html).\n\n## Example usage\n```Python\nimport parselmouth\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nsns.set() # Use seaborn's default style to make attractive graphs\n\n# Plot nice figures using Python's \"standard\" matplotlib library\nsnd = parselmouth.Sound(\"docs/examples/audio/the_north_wind_and_the_sun.wav\")\nplt.figure()\nplt.plot(snd.xs(), snd.values.T)\nplt.xlim([snd.xmin, snd.xmax])\nplt.xlabel(\"time [s]\")\nplt.ylabel(\"amplitude\")\nplt.show() # or plt.savefig(\"sound.png\"), or plt.savefig(\"sound.pdf\")\n```\n![docs/images/example_sound.png](docs/images/example_sound.png)\n```Python\ndef draw_spectrogram(spectrogram, dynamic_range=70):\n    X, Y = spectrogram.x_grid(), spectrogram.y_grid()\n    sg_db = 10 * np.log10(spectrogram.values)\n    plt.pcolormesh(X, Y, sg_db, vmin=sg_db.max() - dynamic_range, cmap='afmhot')\n    plt.ylim([spectrogram.ymin, spectrogram.ymax])\n    plt.xlabel(\"time [s]\")\n    plt.ylabel(\"frequency [Hz]\")\n\ndef draw_intensity(intensity):\n    plt.plot(intensity.xs(), intensity.values.T, linewidth=3, color='w')\n    plt.plot(intensity.xs(), intensity.values.T, linewidth=1)\n    plt.grid(False)\n    plt.ylim(0)\n    plt.ylabel(\"intensity [dB]\")\n\nintensity = snd.to_intensity()\nspectrogram = snd.to_spectrogram()\nplt.figure()\ndraw_spectrogram(spectrogram)\nplt.twinx()\ndraw_intensity(intensity)\nplt.xlim([snd.xmin, snd.xmax])\nplt.show() # or plt.savefig(\"spectrogram.pdf\")\n```\n![docs/images/example_spectrogram.png](docs/images/example_spectrogram.png)\n```Python\ndef draw_pitch(pitch):\n    # Extract selected pitch contour, and\n    # replace unvoiced samples by NaN to not plot\n    pitch_values = pitch.selected_array['frequency']\n    pitch_values[pitch_values==0] = np.nan\n    plt.plot(pitch.xs(), pitch_values, 'o', markersize=5, color='w')\n    plt.plot(pitch.xs(), pitch_values, 'o', markersize=2)\n    plt.grid(False)\n    plt.ylim(0, pitch.ceiling)\n    plt.ylabel(\"fundamental frequency [Hz]\")\n\npitch = snd.to_pitch()\n# If desired, pre-emphasize the sound fragment before calculating the spectrogram\npre_emphasized_snd = snd.copy()\npre_emphasized_snd.pre_emphasize()\nspectrogram = pre_emphasized_snd.to_spectrogram(window_length=0.03, maximum_frequency=8000)\nplt.figure()\ndraw_spectrogram(spectrogram)\nplt.twinx()\ndraw_pitch(pitch)\nplt.xlim([snd.xmin, snd.xmax])\nplt.show() # or plt.savefig(\"spectrogram_0.03.pdf\")\n```\n![docs/images/example_spectrogram_0.03.png](docs/images/example_spectrogram_0.03.png)\n```Python\n# Find all .wav files in a directory, pre-emphasize and save as new .wav and .aiff file\nimport parselmouth\n\nimport glob\nimport os.path\n\nfor wave_file in glob.glob(\"audio/*.wav\"):\n    print(\"Processing {}...\".format(wave_file))\n    s = parselmouth.Sound(wave_file)\n    s.pre_emphasize()\n    s.save(os.path.splitext(wave_file)[0] + \"_pre.wav\", 'WAV') # or parselmouth.SoundFileFormat.WAV instead of 'WAV'\n    s.save(os.path.splitext(wave_file)[0] + \"_pre.aiff\", 'AIFF')\n```\n\nMore examples of different use cases of Parselmouth can be found in the [documentation's examples section](https://parselmouth.readthedocs.io/en/stable/examples.html).\n\n## Documentation\nDocumentation is available at [ReadTheDocs](http://parselmouth.readthedocs.io/), including the API reference of Parselmouth.\n\n## Development\nCurrently, 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.\nUntil that day in some undefined future, if you want to contribute to Parselmouth, do let me know [on Gitter](https://gitter.im/PraatParselmouth/Development) or [by email](mailto:yannick.jadoul@gmail.com), and I will very gladly guide you through the project and help you get started.\n\nBriefly summarized, Parselmouth is built using [`cmake`](https://cmake.org/). Next to that, to manually build Parselmouth, the only requirement is a modern C++ compiler supporting the C++17 standard.\n\n## Acknowledgements\n- Parselmouth builds on the extensive code base of [Praat](https://github.com/praat/praat) by Paul Boersma, which actually implements the huge variety of speech processing and phonetic algorithms that can now be accessed through Parselmouth.\n- In order to do so, Parselmouth makes use of the amazing [pybind11](https://github.com/pybind/pybind11) library, allowing to expose the C/C++ functionality of Praat as a Python interface.\n- Special thanks go to [Bill Thompson](https://billdthompson.github.io/) and [Robin Jadoul](https://github.com/RobinJadoul/) for their non-visible-in-history but very valuable contributions.\n\n## License\n* Parselmouth is released under the GNU General Public License, version 3 or later. See [the `LICENSE` file](LICENSE) for details.\n\n  A [manuscript introducing Parselmouth](https://ai.vub.ac.be/~yajadoul/jadoul_introducing-parselmouth_a-python-interface-to-praat.pdf) (and [supplementary material](https://ai.vub.ac.be/~yajadoul/jadoul_introducing-parselmouth_a-python-interface-to-praat_supplementary-material.zip)) has been [published in the Journal of Phonetics](https://www.sciencedirect.com/science/article/abs/pii/S0095447017301389). Scientific research using Parselmouth's functionality can [*cite Parselmouth*](https://parselmouth.readthedocs.io/en/stable/#citing-parselmouth) as follows:\n\n  \u003e Jadoul, Y., Thompson, B., \u0026 de Boer, B. (2018). Introducing Parselmouth: A Python interface to Praat. *Journal of Phonetics*, *71*, 1-15. https://doi.org/10.1016/j.wocn.2018.07.001\n\n* [Praat](https://github.com/praat/praat), together with [its dependencies](https://www.fon.hum.uva.nl/praat/manual/Acknowledgments.html), is released under [the GNU General Public License, version 3 or later](https://www.fon.hum.uva.nl/praat/manual/General_Public_License__version_3.html). Praat's own source code (excluding dependencies) is released under [the GNU General Public License, version 2 or later](praat/main/GNU_General_Public_License.txt). Small changes to this code base, made in the context of Parselmouth, can be found within the `git` history.\n\n  Parselmouth only exposes Praat's existing functionality and implementation of algorithms. If you use Parselmouth in your research and plan to cite it in a scientific publication, please do not forget to [*cite Praat*](https://www.fon.hum.uva.nl/praat/manual/FAQ__How_to_cite_Praat.html).\n\n  \u003e Boersma, P., \u0026 Weenink, D. (2021). Praat: doing phonetics by computer [Computer program]. Version 6.1.38, retrieved 2 January 2021 from [http://www.praat.org/](http://www.praat.org/)\n\n* [pybind11](https://github.com/pybind/pybind11) is released under [a BSD-style license](pybind11/LICENSE).\n\n* The audio fragment extracted from a recording of the Aesop fable *The North Wind and the Sun*, used as example audio in the documentation and tests, is a [Wikimedia Commons audio file](https://en.wikipedia.org/wiki/File:Recording_of_speaker_of_British_English_(Received_Pronunciation).ogg) licensed by the International Phonetic Association under the [Creative Commons Attribution-Share Alike 3.0 Unported license](https://creativecommons.org/licenses/by-sa/3.0/deed.en).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYannickJadoul%2FParselmouth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYannickJadoul%2FParselmouth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYannickJadoul%2FParselmouth/lists"}