Create a silences textgrid
Format
A Praat script
- wav_file_in
path for the wave to read
- textgrid_out
path of the textgrid file to create
Example usage
library(tjm.praat)
library(purrr)
library(readtextgrid)
# Locate some wav files
dir <- system.file("test-wavs-a/", package = "tjm.praat")
wavs <- list.files(dir, pattern = ".wav", full.names = TRUE)
# Put the resulting textgrids into a temporary folder
tgs <- file.path(tempdir(), basename(set_textgrid_ext(wavs)))
f_create_silences_textgrid <- wrap_praat_script(
script_code_to_run = create_silences_textgrid,
return = "last-argument"
)
# Apply the function to each wav file and read into R
map2_chr(wavs, tgs, f_create_silences_textgrid) %>%
map_df(read_textgrid)
#> # A tibble: 13 x 10
#> file tier_num tier_name tier_type tier_xmin tier_xmax xmin xmax text
#> <chr> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 the_B.Tex~ 1 silences Interval~ 0 0.6 0 0.464 soun~
#> 2 the_B.Tex~ 1 silences Interval~ 0 0.6 0.464 0.6 sile~
#> 3 the_D.Tex~ 1 silences Interval~ 0 0.6 0 0.464 soun~
#> 4 the_D.Tex~ 1 silences Interval~ 0 0.6 0.464 0.6 sile~
#> 5 the_V.Tex~ 1 silences Interval~ 0 0.6 0 0.464 soun~
#> 6 the_V.Tex~ 1 silences Interval~ 0 0.6 0.464 0.6 sile~
#> 7 tidyverse~ 1 silences Interval~ 0 3.87 0 0.370 sile~
#> 8 tidyverse~ 1 silences Interval~ 0 3.87 0.370 1.88 soun~
#> 9 tidyverse~ 1 silences Interval~ 0 3.87 1.88 2.40 sile~
#> 10 tidyverse~ 1 silences Interval~ 0 3.87 2.40 3.18 soun~
#> 11 tidyverse~ 1 silences Interval~ 0 3.87 3.18 3.28 sile~
#> 12 tidyverse~ 1 silences Interval~ 0 3.87 3.28 3.50 soun~
#> 13 tidyverse~ 1 silences Interval~ 0 3.87 3.50 3.87 sile~
#> # i 1 more variable: annotation_num <int>
Praat source code
function (wav_file_in = NULL, textgrid_out = NULL)
# <wrapped_praat_script>
# returning: "last-argument"
form Make silence textgrid
sentence Wav_file_in
sentence Textgrid_out
endform: wav_file_in$
Read from fileTextGrid (silences): 100, 0, -25, 0.1, 0.1, "silent", "sounding"
To : textgrid_out$ Save as text file