praatpicture {praatpicture} | R Documentation |
Make Praat Picture style plots of acoustic data
Description
Generate plots of acoustic data aligned with transcriptions similar to those made with Praat Picture. The default is to produce a plot with a relatively small waveform, somewhat larger spectrogram, and the first tier of a TextGrid.
Usage
praatpicture(
sound,
start = 0,
end = 0,
tfrom0 = TRUE,
frames = c("sound", "spectrogram", "TextGrid"),
proportion = c(30, 50, 20),
mainTitle = "",
start_end_only = TRUE,
min_max_only = TRUE,
wave_channels = "all",
wave_channelNames = FALSE,
wave_color = "black",
tg_obj = NULL,
tg_file = NULL,
tg_tiers = "all",
tg_focusTier = tg_tiers[1],
tg_focusTierColor = "black",
tg_focusTierLineType = "dotted",
tg_tierNames = TRUE,
tg_alignment = "central",
tg_specialChar = FALSE,
tg_color = "black",
spec_channel = NULL,
spec_freqRange = c(0, 5000),
spec_windowLength = 0.005,
spec_dynamicRange = 50,
spec_timeStep = 1000,
spec_windowShape = "Gaussian",
spec_colors = c("white", "black"),
spec_axisLabel = "Frequency (Hz)",
pitch_timeStep = NULL,
pitch_floor = 75,
pitch_ceiling = 600,
pitch_plotType = "draw",
pitch_scale = "hz",
pitch_freqRange = NULL,
pitch_semitonesRe = 100,
pitch_color = "black",
pitch_plotOnSpec = FALSE,
pitch_ssff = NULL,
pitch_axisLabel = NULL,
formant_timeStep = NULL,
formant_maxN = 5,
formant_windowLength = 0.025,
formant_dynamicRange = 30,
formant_freqRange = c(50, 5500),
formant_plotType = "speckle",
formant_color = "black",
formant_plotOnSpec = FALSE,
formant_ssff = NULL,
formant_axisLabel = "Frequency (Hz)",
intensity_timeStep = NULL,
intensity_minPitch = 100,
intensity_range = NULL,
intensity_color = "black",
intensity_plotOnSpec = FALSE,
intensity_ssff = NULL,
intensity_axisLabel = "Intensity (dB)",
time_axisLabel = "Time (s)",
draw_lines = list("formant", h = seq(0, 10000, by = 1000), lty = "dotted"),
draw_rectangle = NULL,
draw_arrow = NULL,
annotate = NULL,
gender = "u",
...
)
Arguments
sound |
String giving the file name of a sound file with the .wav extension. |
start |
Start time (in seconds) of desired plotted area. Default is |
end |
End time (in seconds) of desired plotted area. Default is |
tfrom0 |
Logical; should time on the x-axis run from 0 or from the
original time? Default is |
frames |
String or vector of strings giving the frames that the plot
should consist of. Default is |
proportion |
Integer or vector of integers of the same size as |
mainTitle |
String giving a title to print at the top left. The default is an empty string, i.e. no title. |
start_end_only |
Logical; should there only be ticks on the x-axis
for start and end times? Default is |
min_max_only |
Logical; should only minimum and maximum values be given
on the y-axis? Default is |
wave_channels |
Vector of numbers or strings giving either numeric
identifiers of audio channels to plot of the names of audio channels to plot.
Also understands |
wave_channelNames |
Should names of audio channels be printed
on the y-axis? If |
wave_color |
String giving the name of the color to be used for plotting
the waveform. Default is |
tg_obj |
A TextGrid object returned by the |
tg_file |
Path of file to be used for plotting TextGrid. Default is
|
tg_tiers |
Vector of numbers or strings giving either numeric identifiers
of TextGrid tiers to plot or the names of TextGrid tiers to plot. Also
understands |
tg_focusTier |
For which tier(s) should lines be shown on all
acoustic plots giving the locations of boundaries? Vector of number or
strings giving either numeric identifiers
of TextGrid tiers or the names of TextGrid tiers to plot. Default is
|
tg_focusTierColor |
String or vector of strings giving the color(s) to
use for plotting focus tier lines. If multiple tiers are focused, a vector
of the same length can be passed, and the nth tier will be plotted in the
nth color. Default is |
tg_focusTierLineType |
String or vector of strings giving the line
type(s) for plotting focus tier lines. If multiple tiers are focused, a
vector of the same length can be passed, and the nth tier will be plotted in
the nth line type. Default is |
tg_tierNames |
Logical; should TextGrid tier names be printed along the
y-axis? Default is |
tg_alignment |
String giving the desired alignment of text in the
TextGrids. Default is |
tg_specialChar |
Logical; should Praat typesetting for special font types
such as italic, bold, and small caps be converted into corresponding
R-readable special font types. Default is |
tg_color |
String or vector of strings giving the name of the color(s)
to be used for the text in TextGrids. Default is |
spec_channel |
Numeric giving the channel that should be used to
generate the spectrogram. Default is |
spec_freqRange |
Vector of two integers giving the frequency range to be
used for plotting spectrograms. Default is |
spec_windowLength |
Window length in seconds for generating spectrograms.
Default is |
spec_dynamicRange |
Dynamic range in dB for generating spectrograms. The
maximum intensity minus |
spec_timeStep |
How many time steps should be calculated for spectrograms?
Default is |
spec_windowShape |
String giving the name of the window shape to be
applied to the signal when generating spectrograms. Default is |
spec_colors |
Vector of strings giving the names of colors to be used
for plotting the spectrogram; default is |
spec_axisLabel |
String giving the name of the label to print along the
y-axis when plotting a spectrogram. Default is |
pitch_timeStep |
Measurement interval in seconds for tracking pitch.
Default is |
pitch_floor |
Frequency in Hz; no pitch candidates considered below
this frequency. Default is |
pitch_ceiling |
Frequency in Hz; no pitch candidates considered above
this frequency. Default is |
pitch_plotType |
String giving the type of pitch plot to produce; default
is |
pitch_scale |
String giving the frequency scale to use when producing
pitch plots. Default is |
pitch_freqRange |
Vector of two integers giving the frequency range to be
used for producing pitch plots. Default is |
pitch_semitonesRe |
Frequency in Hz giving the reference level for
converting pitch frequency to semitones. Default is |
pitch_color |
String giving the name of the color to be used for
plotting pitch. Default is |
pitch_plotOnSpec |
Boolean; should pitch be plotted on top of
spectrogram? Default is |
pitch_ssff |
An object of class |
pitch_axisLabel |
String giving the name of the label to print along the
y-axis when printing a pitch track. Default is |
formant_timeStep |
Measurement interval in seconds for tracking formants.
Default is |
formant_maxN |
Integer giving the maximum number of formants to track.
Default is |
formant_windowLength |
The effective duration of the analysis window used for tracking formants in seconds; the actual duration of the analysis window is twice this value. |
formant_dynamicRange |
Dynamic range in dB for producing formant plots.
When a formant plot of |
formant_freqRange |
Vector of two integers giving the frequency range to
be used for producing formant plots. Default is |
formant_plotType |
String giving the type of formant plot to produce;
default is |
formant_color |
String or vector of strings giving the name(s) of
colors to be used for plotting formants. If one color is provided, all
formants will be plotted in this color. If multiple colors are provided,
different formants will be shown in different colors. Default is |
formant_plotOnSpec |
Boolean; should formants be plotted on top of
spectrogram? Default is |
formant_ssff |
An object of class |
formant_axisLabel |
String giving the name of the label to print along the
y-axis when plotting formants. Default is |
intensity_timeStep |
Measurement interval in seconds for tracking
intensity. Default is |
intensity_minPitch |
Lowest pitch in Hz used when calculating
intensity; default is |
intensity_range |
Vector of two integers giving the intensity range to be
used for producing intensity plots. Default is |
intensity_color |
String giving the name of the color to be used for
plotting intensity. Default is |
intensity_plotOnSpec |
Boolean; should intensity be plotted on top of
spectrogram? Default is |
intensity_ssff |
An object of class |
intensity_axisLabel |
String giving the name of the label to print along
the y-axis when plotting intensity. Default is |
time_axisLabel |
String giving the name of the label to print along
the x-axis. Default is |
draw_lines |
Use for drawing straight lines on plot components. Takes
an argument of type |
draw_rectangle |
Use for drawing rectangles on plot components. A vector containing a) a string giving the plot component to draw a rectangle on, and b) arguments to pass on to graphics::rect. Alternatively a list of such vectors, if more rectangles should be drawn. If multiple audio channels are plotted and a rectangle should be added to one of these, use the channel identifier instead of a string giving the frame to draw on. |
draw_arrow |
Use for drawing arrows on plot components. A vector containing a) a string giving the plot component to draw an arrow on, and b) arguments to pass on to graphics::arrows. Alternatively a list of such vectors, if more arrows should be drawn. If multiple audio channels are plotted and an arrow should be added to one of these, use the channel identifier instead of a string giving the frame to draw on. |
annotate |
Use for annotating plot components. A vector containing a) a string giving the plot component to annotate, and b) arguments to pass on to graphics::text. Alternatively a list of such vectors, if more annotations should be made. If multiple audio channels are plotted and annotations should be added to one of these, use the channel identifier instead of a string giving the frame to draw on. |
gender |
String indicating the gender of the speaker; default is
|
... |
Further global plotting arguments passed on to |
Details
When available, pitch, formant, and intensity tracks are loaded
from Praat files with the same base name as sound
; i.e., if your sound
file is called 1.wav
and there is a Praat file called 1.Formant
in the
same directory, this file is used for plotting formants. Pitch files should
have the PitchTier
extension, and intensity files should have the
IntensityTier
extension.
If no such files are available, the signal processing tools in the wrassp
package are used; pitch is tracked with the function wrassp::ksvF0,
formants are tracked with wrassp::forest, and intensity is tracked with
wrassp::rmsana. Parameters are set to mimic Praat as closely as possible,
e.g. using a Gaussian-like window shape KAISER2_0
, but results will differ
from Praat simply because the tracking algorithms differ; as far as I know,
the Burg algorithm used by Praat for tracking formants isn't implemented in R,
nor is the autocorrelation method for tracking pitch.
Spectrograms are generated with the function phonTools::spectrogram. The code portion that actually adds the spectrogram to a plot is based on phonTools::plot.spectrogram but rewritten to use a bitmap raster for rendering the image if the graphics device allows for it, which significantly speeds up rendering the spectrogram.
Value
No return value, produces a figure.
Examples
datapath <- system.file('extdata', package='praatpicture')
soundFile <- paste0(datapath, '/1.wav')
praatpicture(soundFile)