segment: Segment a sound

Description Usage Arguments Details Value Examples

View source: R/segment.R

Description

Finds syllables and bursts. Syllables are defined as continuous segments with ampiltude above threshold. Bursts are defined as local maxima in amplitude envelope that are high enough both in absolute terms (relative to the global maximum) and with respect to the surrounding region (relative to local mimima). See the vignette on acoustic analysis for details.

Usage

1
2
3
4
5
segment(x, samplingRate = NULL, windowLength = 40, overlap = 80,
  shortestSyl = 40, shortestPause = 40, sylThres = 0.9,
  interburst = NULL, interburstMult = 1, burstThres = 0.075,
  peakToTrough = 3, troughLeft = TRUE, troughRight = FALSE,
  summary = FALSE, plot = FALSE, savePath = NA, ...)

Arguments

x

path to a .wav file or a vector of amplitudes with specified samplingRate

samplingRate

sampling rate of x (only needed if x is a numeric vector, rather than a .wav file)

windowLength, overlap

length (ms) and overlap ( window used to produce the amplitude envelope, see env

shortestSyl

minimum acceptable length of syllables, ms

shortestPause

minimum acceptable break between syllables, ms. Syllables separated by less time are merged. To avoid merging, specify shortestPause = NA

sylThres

amplitude threshold for syllable detection (as a proportion of global mean amplitude of smoothed envelope)

interburst

minimum time between two consecutive bursts (ms). If specified, it overrides interburstMult

interburstMult

multiplier of the default minimum interburst interval (median syllable length or, if no syllables are detected, the same number as shortestSyl). Only used if interburst is not specified. Larger values improve detection of unusually broad shallow peaks, while smaller values improve the detection of sharp narrow peaks

burstThres

to qualify as a burst, a local maximum has to be at least burstThres times the height of the global maximum of amplitude envelope

peakToTrough

to qualify as a burst, a local maximum has to be at least peakToTrough times the local minimum on the LEFT over analysis window (which is controlled by interburst or interburstMult)

troughLeft, troughRight

should local maxima be compared to the trough on the left and/or right of it? Default to TRUE and FALSE, respectively

summary

if TRUE, returns only a summary of the number and spacing of syllables and vocal bursts. If FALSE, returns a list containing full stats on each syllable and bursts (location, duration, amplitude, ...)

plot

if TRUE, produces a segmentation plot

savePath

full path to the folder in which to save the plots. Defaults to NA

...

other graphical parameters passed to plot

Details

The algorithm is very flexible, but the parameters may be hard to optimize by hand. If you have an annotated sample of the sort of audio you are planning to analyze, with syllables and/or bursts counted manually, you can use it for automatic optimization of control parameters (see optimizePars. The defaults are the results of just such optimization against 260 human vocalizations in Anikin, A. & Persson, T. (2017). Non-linguistic vocalizations from online amateur videos for emotion research: a validated corpus. Behavior Research Methods, 49(2): 758-771.

Value

If summary = TRUE, returns only a summary of the number and spacing of syllables and vocal bursts. If summary = FALSE, returns a list containing full stats on each syllable and bursts (location, duration, amplitude, ...).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
sound = soundgen(nSyl = 8, sylLen = 50, pauseLen = 70,
  pitchAnchors = list(time = c(0, 1), value = c(368, 284)), temperature = 0.1,
  noiseAnchors = list(time = c(0, 67, 86, 186), value = c(-45, -47, -89, -120)),
  rolloff_noise = -8, amplAnchorsGlobal = list(time = c(0, 1), value = c(120, 20)))
spectrogram(sound, samplingRate = 16000, osc = TRUE)
 # playme(sound, samplingRate = 16000)

s = segment(sound, samplingRate = 16000, plot = TRUE)
# accept quicker and quieter syllables
s = segment(sound, samplingRate = 16000, plot = TRUE,
  shortestSyl = 25, shortestPause = 25, sylThres = .6)
# look for narrower, sharper bursts
s = segment(sound, samplingRate = 16000, plot = TRUE,
  shortestSyl = 25, shortestPause = 25, sylThres = .6,
  interburstMult = 1)

# just a summary
segment(sound, samplingRate = 16000, summary = TRUE)

tatters/soundgen_beta documentation built on May 14, 2019, 9 a.m.