knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" ) library(kphon)
Helper functions for the Kaytetye Phonological Database (kphon).
# If you don't have the devtools package, then do 'install.packages("devtools")' first devtools::install_github("fauxneticien/kphon")
Create standardised export CSV and wav files for kphon, which are of the form:
knitr::kable(readr::read_csv("orthography,gl_annotated,transcription,annotator,kphon_export,annotation_source,xmin,xmax atnyemilparele,south.wind-ERG,ɐcɲejmejlpɐɻələ,MP,atnyemilparele_AR_cf125a3a.wav,southwindpassage_AR_MP.TextGrid,2.1256905074478105,3.140994243207525 kape,and,kɐpə,MP,kape_AR_29cf0b23.wav,southwindpassage_AR_MP.TextGrid,3.2237406016823074,3.606705482796561 aherrkele,sun-ERG,ɐːɾkələ,MP,aherrkele_AR_4bcff7be.wav,southwindpassage_AR_MP.TextGrid,3.606705482796561,4.07538582324225 tyampe,too,cɐmpə,MP,tyampe_AR_95ac9af5.wav,southwindpassage_AR_MP.TextGrid,4.07538582324225,4.511354649921463 ahenge,fight,ɐːŋə,MP,ahenge_AR_e67432f2.wav,southwindpassage_AR_MP.TextGrid,4.660752408376567,4.950564710693483"))
Step 0: Load kphon library and set working directory
library(kphon) setwd("~/sandboxes/kphon-v2/annotations/southwind/")
Step 1: Provide TextGrid file(s) to process, with an Input/Output mapping
# Step 1: Provide input TextGrid file(s) # and an input-output 'io' mapping for TextGrid tiers to columns step1 <- textgrid_to_kphon( input_files = "southwindpassage_AR_MP.TextGrid", io_mapping = list( orthography = "word", gl_annotated = "gloss", transcription = "phon" ) )
Step 2: Derive (however appropriate) speaker and annotator columns, then feed into hash function to derive file name for export
step2 <- step1 %>% mutate( speaker = str_extract(string = annotation_source, pattern = "_[A-Z]+_") %>% str_remove_all("_"), annotator = str_extract(string = annotation_source, pattern = "[A-Z]+\\.TextGrid") %>% str_remove("\\.TextGrid"), input_wav = str_replace(string = annotation_source, pattern = "_[A-Z]+.\\TextGrid", ".wav"), output_wav = hash_kphon_wav(orthography, speaker, annotation_source, xmin) )
Step 3: After you've verified data extracted correctly in Step 1 and Step 2, write .wav and .csv files
write_kphon_exports(kphon_df = step2, path = ".", overwrite = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.