Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
utils.praat_interop.PraatInterop Class Reference

This class contains static methods that can be used to perform some basic operations in Praat. More...

Inheritance diagram for utils.praat_interop.PraatInterop:

Static Public Member Functions

def open_praat
 Opens a Praat instance. More...
 
def close_praat
 Closes an open Praat instance. More...
 
def send_commands
 Sends a list of commands to Praat. More...
 
def get_open_clip_script
 This method returns a script that opens praat and displays a spectrograph of a given section of a given wave file. More...
 
def get_sel_bounds_script
 Used in custom_scripts. More...
 
def get_octave_corrected_pitch_script
 Used in Melissa's thesis project (see custom_scripts directory) More...
 
def get_low_pass_filter_script
 This low-pass filters a clip from a wav file, and saves the clip as a new wav file. More...
 
def get_pitch_sample_vals_script
 Used in Melissa's thesis project (see custom_scripts directory) More...
 
def get_pitch_extrema
 Used in Melissa's thesis project (see custom_scripts directory) More...
 
def create_serversocket
 Creates a socket to listen for info that Praat is instructed to send. More...
 
def socket_receive
 Receives a message containing the selected boundary information from Praat. More...
 

Detailed Description

This class contains static methods that can be used to perform some basic operations in Praat.

To do this, it uses the sendpraat program, available here. The location of this program on the current machine should be available in the constant DBConstants.SETTINGS.SENDPRAAT_PATH (which is defined in the DB settings table).

Definition at line 14 of file praat_interop.py.

Member Function Documentation

def utils.praat_interop.PraatInterop.close_praat ( )
static

Closes an open Praat instance.

Definition at line 27 of file praat_interop.py.

def utils.praat_interop.PraatInterop.create_serversocket ( )
static

Creates a socket to listen for info that Praat is instructed to send.

To see how praat can be intructed to send info, see the get_sel_bounds_script() method.

Parameters
port(int) the port to listen on
Returns
(socket) a socket object from the Python socket library. This socket is set up and listening on the specified port.

Definition at line 195 of file praat_interop.py.

def utils.praat_interop.PraatInterop.get_low_pass_filter_script (   wav_filename,
  clip_filename,
  file_code,
  start_time,
  stop_time,
  filter_from,
  filter_to,
  filter_smoothing 
)
static

This low-pass filters a clip from a wav file, and saves the clip as a new wav file.

Used in relaibility project project (see custom_scripts directory)

Definition at line 115 of file praat_interop.py.

def utils.praat_interop.PraatInterop.get_octave_corrected_pitch_script ( )
static

Used in Melissa's thesis project (see custom_scripts directory)

Definition at line 91 of file praat_interop.py.

def utils.praat_interop.PraatInterop.get_open_clip_script (   start_time,
  end_time,
  wav_filename,
  open_spec_win = True 
)
static

This method returns a script that opens praat and displays a spectrograph of a given section of a given wave file.

The intention is that the user can select a portion with the mouse, and then the selection boundaries can be retreived with the close_praat() method (below).

Parameters
start_time(float) absolute start time of the clip to display
end_time(float) absolute end time of the clip to display
wav_filename(string) full path to the wave file to open
open_spec_win(boolean=True) set to False if you don't want to open a spectrogram window (this will just extract the sound clip)

Definition at line 60 of file praat_interop.py.

def utils.praat_interop.PraatInterop.get_pitch_extrema ( )
static

Used in Melissa's thesis project (see custom_scripts directory)

Definition at line 178 of file praat_interop.py.

def utils.praat_interop.PraatInterop.get_pitch_sample_vals_script (   clip_start,
  clip_end,
  wav_filename,
  step = 0.01 
)
static

Used in Melissa's thesis project (see custom_scripts directory)

Definition at line 136 of file praat_interop.py.

def utils.praat_interop.PraatInterop.get_sel_bounds_script (   wav_filename)
static

Used in custom_scripts.

Definition at line 74 of file praat_interop.py.

def utils.praat_interop.PraatInterop.open_praat ( )
static

Opens a Praat instance.

Note: Things won't work if you open more than one at a time.

Definition at line 19 of file praat_interop.py.

def utils.praat_interop.PraatInterop.send_commands (   cmds)
static

Sends a list of commands to Praat.

These commands are just Strings that manipulate the Praat UI. You can access anything clickable in the UI by its name. If you need to use Praat variables to store stuff, or other Praat scripting language functions, you'll need to open an editor window. See get_sel_bounds_script() for an example of how to do that. This idea is to generate a Praat scripts for a specific task using the get_..._script() methods below. These methods return a list of strings that can be then be passed to this method for execution. This allows us to dynamically generate Praat scripts, using values or other information from our Python scripts.

Parameters
cmds(list) list of Praat commands (String). Eg. ['Open long sound file... "mysound.wav"', 'Extract part... 0.0 10.0']
Returns
(int) 0 on success, nonzero on issue (see subprocess module in Python API for details)

Definition at line 39 of file praat_interop.py.

def utils.praat_interop.PraatInterop.socket_receive (   serversocket,
  delim = ' ' 
)
static

Receives a message containing the selected boundary information from Praat.

Parameters
serversocket(socket) Python socket library socket object to receive the message on
Returns
(list) returns a list of values sent back by Praat. Values should be separated by a space character.

Definition at line 213 of file praat_interop.py.


The documentation for this class was generated from the following file: