praat_pitch: extract some pitch variables via Praat from audio (segments)

Description Usage Arguments Details Value Examples

View source: R/praat_pitch.R

Description

extract some pitch variables via Praat from audio (segments)

Usage

1
2
praat_pitch(sound_file, child = TRUE, time_range = NULL,
  pathtopraat = NULL, unit = "Hertz", pathtosox = NULL)

Arguments

sound_file

character, path to audio file

child

logical, should pitch settings be set for child (default), or adult

time_range

numeric of length 2, optional start and end time in seconds. If left blank (NULL) the entire file is processed.

pathtopraat

character, the path to the Praat binary

unit

character, the unit for the frequency measures ("Hertz", "ERB", ...)

pathtosox

character, optional path to sox binary (only required if time_range is not NULL)

Details

The output reflects measures of F0 (actually, pitch): mean, 5 percentile and 95

The pitch settings for child versus adult are the following. Child: floor = 150 Hz, ceiling = 650 Hz. Adult: floor = 75 Hz, ceiling = 400 Hz. Time step for both is 0.01 s.

For this function to work, you need Praat, and you need to know where the Praat binary is located. On a Mac the location is likely to be "/Applications/Praat.app/Contents/MacOS/Praat", and on Windows "C:/Program Files/Praat.exe".

The function produces and executes a short Praat script:

Read from file: "myfile.wav"

To Pitch: 0.01, 150, 600

Get total duration

Get mean: 0, 0, "ERB"

Get quantile: 0, 0, 0.95, "ERB"

Get quantile: 0, 0, 0.05, "ERB"

The second line is adapted according to whether the assigned speaker of the audio segment is a child (as in the example above) or an adult (in which case that line will be To Pitch: 0.01, 75, 400)

Value

a data frame with one row

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# requires Praat installed
# location to Praat on my machine:
ploc <- "/Applications/Praat.app/Contents/MacOS/Praat"
# example sound
sound_file <- system.file("synthetic_speech.wav", package = "avutils")
praat_pitch(sound_file, child = FALSE, pathtopraat = ploc)
praat_pitch(sound_file, child = TRUE, pathtopraat = ploc)
# analyse only subset requires sox installed
sloc <- "/usr/local/bin/sox"
praat_pitch(sound_file, time_range = c(0.3, 3.1), child = FALSE,
            pathtopraat = ploc, pathtosox = sloc)

## End(Not run)

gobbios/avutils documentation built on Feb. 19, 2020, 9:44 a.m.