Recording with Praat

160 views
Skip to first unread message

Mark Carr

unread,
Nov 20, 2019, 7:27:12 PM11/20/19
to Parselmouth
Did the recording functions get ported to the Python version? I am searching through the contents of the library in a Jupiter notebook. Can't find any record functionality. Thank you!

Yannick Jadoul

unread,
Nov 21, 2019, 12:58:13 PM11/21/19
to parse...@googlegroups.com
Hi Mark

No, these are not available in Parselmouth, and are not even supposed to be available through the parselmouth.praat.call interace, for two main reasons:

1) In Praat, these depend on external alsa/pulseaudio libraries that seem to be quite platform-specific. It might be possible, but I need to make more time and investigate how to make sure this will work on all platforms (Windows, macOS, different Linux distributions). Praat even has some notes on this (http://www.fon.hum.uva.nl/praat/download_linux.html), saying "5. Known possible problems, and their solution; 1. Sound not working?", so I chose to keep this can of worms closed for now.

2) Parselmouth, as Python library, is mainly meant to focus on the acoustic analysis/annotation/synthesis/... But since scripts are written in Python, they can take advantage of other Python libraries, such as a library for audio playback/recording. In your case, you might be interested in PyAudio, for example: https://people.csail.mit.edu/hubert/pyaudio/

I've successfully used PyAudio in combination with Parselmouth, before. This file from a past project might actually be helpful for you, as it demonstrates how to combine the two to record audio that can later be analyzed through Parselmouth: https://github.com/YannickJadoul/SpeechForComputers/blob/44bb7487253eb37c0f9842aeebfd6443c25d349e/sound_recorder.py

Mark Carr

unread,
Nov 21, 2019, 1:43:45 PM11/21/19
to Parselmouth
Thank you so much, Yannick, for taking the time to respond. I have used PyAudio in the past, but it does not build correctly with newer versions of Python. Sounddevice would be a good alternative, but it does not work with Jupyter Notebooks most of the time, I think because you have to give permissions to use the microphone in a browser. 

Is there a general workflow you use to see the phonetic notation using a Python visualization library? Is it better to think of this library as a feature extraction tool rather than try to create an "interface?"

Yannick Jadoul

unread,
Nov 21, 2019, 6:54:26 PM11/21/19
to parse...@googlegroups.com
Oh, right. Sorry to hear so. I haven't really got experience with that; for my PyAudio worked straight out of the box, when combined with a Bokeh server or other Python script. But it does show how fragile audio unfortunately can be between platforms, and why I avoided getting into that straight away :-( PyAudio seems quite widely used, though, so I'm surprised your problems with newer Python version haven't already been resolved or remediated by workarounds?
Maybe there are Jupyter-specific solutions, as well? A very shallow search just gave me this: https://ipywebrtc.readthedocs.io/en/latest/AudioRecorder.html, which seems like it could be useful?

For your second question: what exactly do you mean with "phonetic notation"? Are you refering to IPA symbols in Unicode (which ... I don't know, is unicode supported by matplotlib? I'd be surprised if there wasn't a solution/matplotlib extension for that) ? Or do you mean Praat TextGrid annotations (which Parselmouth can handle, and for which you also have the TextGridTools (tgt) Python library)? Or still something else that I'm not getting?

But yes, my main goal for Parselmouth is to expose the functionality that makes Praat unique (acoustic and phonetic analysis and manipulation) to Python, since it's hard to find the same quality and range of algorithms in a different software package for Python. The idea is that exposing it as a Python library allows you to combine with a bunch of other things Praat might not provide (or might not be specialized in) through Python scripting/programmng. But doing this does enable a bunch of secondary functionality, and if it can be useful, I'm definitely up for supporting this unforeseen usage. The main problem with recording and playing audio, showing visualizations and opening editors, etc. is a technical one: I need to make sure that enabling these does not stop Parselmouth from being used on some systems. Especially since these are to some degree part of a user interface, not typically part of a Python library/API, and Python has (or should have) more generic solutions: e.g., there are lots of plotting libraries for Python, with more functionality than Praat's plotting, so the need to do this with Parselmouth seems less important. But if there's a possibility to get this working (and time or help to do so), I won't object :-)
I hope that explanation makes sense, more or less?

Mark Carr

unread,
Nov 23, 2019, 5:33:02 PM11/23/19
to Parselmouth
Of course, python visualizations are one of the reasons I like Parselmouth, as well as the formant analysis, as well as the framework being based on an acoustical, physical modeling. Great set of features for ML training sets! 

I looked at that WebRTC solution a while back, but not all browsers are supporting the standard, didn't work when I tried it, so I think creating a different front end for each operating system and taking control of system audio is the answer. The backend is Flask.

Thank you very much, Yannick.

-- mc
Reply all
Reply to author
Forward
0 new messages