Title: | Coding Sound Files for Use with NDL |
---|---|
Description: | Make acoustic cues to use with the R packages 'ndl' or 'ndl2'. The package implements functions used in the PLoS ONE paper: Denis Arnold, Fabian Tomaschek, Konstantin Sering, Florence Lopez, and R. Harald Baayen (2017). Words from spontaneous conversational speech can be recognized with human-like accuracy by an error-driven learning algorithm that discriminates between meanings straight from smart acoustic features, bypassing the phoneme as recognition unit. PLoS ONE 12(4):e0174623 <doi:10.1371/journal.pone.0174623> More details can be found in the paper and the supplement. 'ndl' is available on CRAN. 'ndl2' is available by request from <[email protected]>. |
Authors: | Denis Arnold [aut, dtc, cre], Elnaz Shafaei Bajestan [ctb] |
Maintainer: | Denis Arnold <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.2 |
Built: | 2024-11-20 03:19:03 UTC |
Source: | https://github.com/denis-arnold/acousticndlcoder |
Package to make acoustic cues to use with ndl or ndl2.
The packages main function is makeCues
. readTextGridFast
,
readTextGridRobust
, readESPSAnnotation
and
readWavesurfer
are helper functions that read the corresponding annotation
files and return a data.frame. CorpusCoder
codes a whole corpus given a vector
with the path to and names of wave files and a vector for the annotation files.
word_classification_data
provides data from Arnold et al 2017
https://doi.org/10.1371/journal.pone.0174623
Denis Arnold
Reference to to paper in accepted form.
## Not run: # assuming the corpus contains wave files and praat textgrids setwd(~/Data/MyCorpus) # assuming everything is in one place #assuming you have one wav for each annotation Waves=list.files(pattern="*.wav",recursive=T) Annotations=list.files(pattern="*.TextGrids",recursive=T) # see above # Lets assume the annotation is in UTF-8 and you want everything from a tier called words # Lets assume tha you want to dismiss everything in <|> # Lets assume that have 4 cores available # Lets assume that you want the defaut settings for the parameters Data=CorpusCoderCorpusCoder(Waves, Annotations, AnnotationType = "TextGrid", TierName = "words", Dismiss = "<|>", Encoding, Fast = F, Cores = 4, IntensitySteps = 5, Smooth = 800) ## End(Not run)
## Not run: # assuming the corpus contains wave files and praat textgrids setwd(~/Data/MyCorpus) # assuming everything is in one place #assuming you have one wav for each annotation Waves=list.files(pattern="*.wav",recursive=T) Annotations=list.files(pattern="*.TextGrids",recursive=T) # see above # Lets assume the annotation is in UTF-8 and you want everything from a tier called words # Lets assume tha you want to dismiss everything in <|> # Lets assume that have 4 cores available # Lets assume that you want the defaut settings for the parameters Data=CorpusCoderCorpusCoder(Waves, Annotations, AnnotationType = "TextGrid", TierName = "words", Dismiss = "<|>", Encoding, Fast = F, Cores = 4, IntensitySteps = 5, Smooth = 800) ## End(Not run)
Helper function for makeCues
CODE(SPEC, num)
CODE(SPEC, num)
SPEC |
Spectrum representation made in makeCues() |
num |
Number of the part |
A string containing the coding. Each band is seperated by "_".
Denis Arnold
Codes a corpus for use with NDL with vector of wavefile names and a vector of TextGrid names provided
CorpusCoder(Waves, Annotations, AnnotationType = c("TextGrid", "ESPS"), TierName = NULL, Dismiss = NULL, Encoding, Fast = F, Cores = 1, IntensitySteps, Smooth)
CorpusCoder(Waves, Annotations, AnnotationType = c("TextGrid", "ESPS"), TierName = NULL, Dismiss = NULL, Encoding, Fast = F, Cores = 1, IntensitySteps, Smooth)
Waves |
Vector with names (and full path to if not in wd) of the wave files. |
Annotations |
Vector with names (and full path to if not in wd) of the TextGrid files. |
AnnotationType |
Type of annotation files. Suported formats are praat TextGrids (set to "TextGrid") and ESPS/Wavesurfer (set to "ESPS") files. |
TierName |
Name of the tier in the TextGrid to be used. |
Dismiss |
Regular expression for Outcomes that should be removed. Uses grep. E.g. "<|>" would remove <noise>,<xxx>, etc. Default is NULL. |
Encoding |
Encoding of the annotation file. It is assumed, that all annotation files have the same encoding. |
Fast |
Switches between a fast and a robust TextGrid parser. For Fast no "\n" or "\t" may be in the transcription. Default is FALSE. |
Cores |
Number of cores that the function may use. Default is 1. |
IntensitySteps |
Number of steps that the intensity gets compressed to. Default is 5 |
Smooth |
A parameter for using the kernel smooth function provied by the package zoo. |
A data.frame with $Cues and $Outcomes for use with ndl or ndl2.
Denis Arnold
## Not run: # assuming the corpus contains wave files and praat textgrids setwd(~/Data/MyCorpus) # assuming everything is in one place #assuming you have one wav for each annotation Waves=list.files(pattern="*.wav",recursive=T) Annotations=list.files(pattern="*.TextGrids",recursive=T) # see above # Lets assume the annotation is in UTF-8 and you want everything from a tier called words # Lets assume tha you want to dismiss everything in <|> # Lets assume that have 4 cores available # Lets assume that you want the defaut settings for the parameters Data=CorpusCoderCorpusCoder(Waves, Annotations, AnnotationType = "TextGrid", TierName = "words", Dismiss = "<|>", Encoding, Fast = F, Cores = 4, IntensitySteps = 5, Smooth = 800) ## End(Not run)
## Not run: # assuming the corpus contains wave files and praat textgrids setwd(~/Data/MyCorpus) # assuming everything is in one place #assuming you have one wav for each annotation Waves=list.files(pattern="*.wav",recursive=T) Annotations=list.files(pattern="*.TextGrids",recursive=T) # see above # Lets assume the annotation is in UTF-8 and you want everything from a tier called words # Lets assume tha you want to dismiss everything in <|> # Lets assume that have 4 cores available # Lets assume that you want the defaut settings for the parameters Data=CorpusCoderCorpusCoder(Waves, Annotations, AnnotationType = "TextGrid", TierName = "words", Dismiss = "<|>", Encoding, Fast = F, Cores = 4, IntensitySteps = 5, Smooth = 800) ## End(Not run)
Helper function for makeCues that splits the signal based on the envelope of the signal
getBoundary(Wave, smooth = 800)
getBoundary(Wave, smooth = 800)
Wave |
A Wave object (see tuneR) |
smooth |
A parameter for using the kernel smooth function provied by the package zoo. |
A vector with the sample numbers of the boundaries.
Denis Arnold
## Not run: library(tuneR) Wave=readWave("MyWaveFile.wav") Boundaries=getBoundary(Wave,800) ## End(Not run)
## Not run: library(tuneR) Wave=readWave("MyWaveFile.wav") Boundaries=getBoundary(Wave,800) ## End(Not run)
Creates a string with the cues for each frequency band and segment seperated by "_"
makeCues(WAVE, IntensitySteps = 5, Smooth = 800)
makeCues(WAVE, IntensitySteps = 5, Smooth = 800)
WAVE |
A Wave object (see tuneR). Currently it is implemented for use with 16kHz sampling rate. |
IntensitySteps |
Number of steps that the intensity gets compressed to. Default is 5. |
Smooth |
A parameter for using the kernel smooth function provied by the package zoo. |
A string containing the coding. Each band and part is seperated by "_"
Denis Arnold
## Not run: library(tuneR) library(seewave) Wave=readWave("MyWaveFile.wav") if([email protected]!=16000){ Wave=resamp(Wave,[email protected],g=16000,output="Wave") } Cues=makeCues(Wave,IntensitySteps=5,Smooth=800) ## End(Not run)
## Not run: library(tuneR) library(seewave) Wave=readWave("MyWaveFile.wav") if(Wave@samp.rate!=16000){ Wave=resamp(Wave,f=Wave@samp.rate,g=16000,output="Wave") } Cues=makeCues(Wave,IntensitySteps=5,Smooth=800) ## End(Not run)
Reads a ESPS/Old Wavesurfer style annotation file and returns a data.frame with times and lables
readESPSAnnotation(File, Encoding)
readESPSAnnotation(File, Encoding)
File |
Name (with full path, if not in wd) of the annotation file |
Encoding |
Encoding of the annotation file. Typically encodings are "ACSII","UTF-8" or "UTF-16" |
A data.frame with $Output for the lable $start and $end time of the lable.
Denis Arnold
## Not run: # Assume that NameOfAnnotation is encoded in "UTF-8" Data=readESPSAnnotation("NameOfTextGrid","UTF-8") ## End(Not run)
## Not run: # Assume that NameOfAnnotation is encoded in "UTF-8" Data=readESPSAnnotation("NameOfTextGrid","UTF-8") ## End(Not run)
Reads a TextGrid made with praat and returns a list with a vector of all tier names and a data.frame for each tier.
readTextGridFast(File, Encoding)
readTextGridFast(File, Encoding)
File |
Name (with full path, if not in wd) of the TextGrid |
Encoding |
Encoding of the TextGrid. Typically encodings are "ACSII","UTF-8" or "UTF-16" |
This method has sometimes problems with certain sequences like "\n" in the annotation file. If the method fails, try readTextGridRobust()
A list containing a vectors with the names and data.frames for each tier in the TextGrid.
Denis Arnold
## Not run: # Assume that NameOfTextGrid is encoded in "UTF-8" Data=readTextGridFast("NameOfTextGrid","UTF-8") ## End(Not run)
## Not run: # Assume that NameOfTextGrid is encoded in "UTF-8" Data=readTextGridFast("NameOfTextGrid","UTF-8") ## End(Not run)
Reads a TextGrid made with praat and returns a list with a vector of all tier names and a data.frame for each tier
readTextGridRobust(File, Encoding)
readTextGridRobust(File, Encoding)
File |
Name (with full path, if not in wd) of the TextGrid |
Encoding |
Encoding of the TextGrid. Typically encodings are "ACSII","UTF-8" or "UTF-16" |
A list containing a vectors with the names and data.frames for each tier in the TextGrid.
Denis Arnold
## Not run: # Assume that NameOfTextGrid is encoded in "UTF-8" Data=readTextGridRobust("NameOfTextGrid","UTF-8") ## End(Not run)
## Not run: # Assume that NameOfTextGrid is encoded in "UTF-8" Data=readTextGridRobust("NameOfTextGrid","UTF-8") ## End(Not run)
Reads a New Wavesurfer style annotation file and returns a data.frame with times and lables
readWavesurfer(File, Encoding)
readWavesurfer(File, Encoding)
File |
Name (with full path, if not in wd) of the annotation file |
Encoding |
Encoding of the annotation file. Typically encodings are "ACSII","UTF-8" or "UTF-16" |
A data.frame with $Output for the lable $start and $end time of the lable.
Denis Arnold
## Not run: # Assume that NameOfAnnotation is encoded in "UTF-8" Data=readWavesurfer("NameOfTextGrid","UTF-8") ## End(Not run)
## Not run: # Assume that NameOfAnnotation is encoded in "UTF-8" Data=readWavesurfer("NameOfTextGrid","UTF-8") ## End(Not run)
Dataset of a subject and modeling data for an auditory word identification task.
data(word_classification_data)
data(word_classification_data)
Data from the four experiments and model estimates
ExperimentNumber
Experiment identifier
PresentationMethod
Method of presentation in the experiment: loudspeaker, headphones 3. Trial: Trial number in the experimental list
TrialScaled
scaled Trial
Subject
anonymized subject identifier
Item
word identifier -german umlaute and special character coded as 'ae' 'oe' 'ue' and 'ss'
Activation
NDL activation
LogActivation
log(activation+epsilon)
L1norm
L1-norm (lexicality)
LogL1norm
log of L1-norm
RecognitionDecision
recognition decision (yes/no)
RecognitionRT
latency for recognition decision
LogRecognitionRT
log recognition RT
DictationAccuracy
dictation accuracy (TRUE: correct word reported, FALSE otherwise) 15. DictationRT: response latency to typing onset
Denis Arnold, Fabian Tomaschek, Konstantin Sering, Florence Lopez, and R. Harald Baayen (2017). Words from spontaneous conversational speech can be recognized with human-like accuracy by an error-driven learning algorithm that discriminates between meanings straight from smart acoustic features, bypassing the phoneme as recognition unit PLoS ONE 12(4):e0174623. https://doi.org/10.1371/journal.pone.0174623