Last active
December 5, 2017 05:48
-
-
Save fauxneticien/71715e8d30da7cbdee72d668853fe6a2 to your computer and use it in GitHub Desktop.
Pipeline test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(phonpack) | |
| library(base64enc) | |
| library(googlesheets) | |
| # Get from BitBucket pipeline environment | |
| BATCH_NO <- Sys.getenv("BITBUCKET_REPO_SLUG") | |
| AUTH_STR <- Sys.getenv("GOOGLE_AUTH") | |
| # Convert env variable to txt file, then to RDS file, then supply | |
| # to gs_auth() as RDS file | |
| base64_token <- tempfile() | |
| decoded_rds <- tempfile() | |
| writeLines(text = AUTH_STR, con = base64_token) | |
| base64decode(file = base64_token, output = decoded_rds) | |
| auth_token <- gs_auth(token = decoded_rds, cache = FALSE) | |
| kdict_trans <- gs_title("kdict-transcriptions") | |
| # Create new worksheet if not already present | |
| if(!BATCH_NO %in% gs_ws_ls(kdict_trans)) { | |
| gs_ws_new(kdict_trans, ws_title = BATCH_NO) | |
| } | |
| # List all TextGrids | |
| list.files( | |
| path = ".", | |
| pattern = ".TextGrid$", | |
| recursive = TRUE | |
| ) %>% | |
| # Read 'ipa' tier from all listed TextGrids | |
| map_df(function(tg_filename) { | |
| tg_filename %>% | |
| readTextGrid() %>% | |
| getTierByName("ipa") %>% | |
| getTierIntervals(discard_empty = TRUE) %>% | |
| mutate(source_file = tg_filename) | |
| }) %>% | |
| # Overwrite sheet with new data | |
| gs_edit_cells( | |
| ss = kdict_trans, | |
| ws = BATCH_NO, | |
| input = ., | |
| anchor = "A1", | |
| col_names = TRUE | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment