Learn R Programming

transcribeR (version 0.0.0)

sendAudioGetJobs: Posts to HP IDOL OnDemand Speech Recognition API and Store the Resulting Job ID

Description

Main user function to POST to HP IDOL OnDemand Speech Recognition API and write Job ID to a transcribeR CSV, a filename. It posts all compatible files in the provided directory. It avoids posting any file that has already been posted according to the transcribeR CSV.

Usage

sendAudioGetJobs(wav.dir, api.key, interval = "-1", encode = "multipart", existing.csv = NULL, csv.location, language = "en-US", verbose = FALSE)

Arguments

wav.dir
the directory in which the WAV files of interest are located
api.key
the API Key used to authenticate requests to HP IDOL OnDemand; one can be obtained from making an account on HP IDOL OnDemand's website https://www.idolondemand.com/
interval
optional argument; specifies segmentation length for transcripts in milliseconds; -1 indicates no segmentation and 0 indicates segmentation by words; default is "-1"
encode
optional argument; passed directly to POST in the httr package; defaults to "multipart"
existing.csv
optional argument; specifies CSV to post; defaults to NULL
csv.location
output tag for CSV file
language
optional argument; provides language code for HP IDOL OnDemand's Speech Recognition API; defaults to "en-US"
verbose
optional argument; if TRUE, prints out messages indicating the percentage of audio files posted to HP to the console

Details

When two files share the same basename but are different file formats, only one of the files will be posted to the Speech Recognition API because after the first file is posted, the basename is logged into the transcribeR CSV. Hence, all subsequent files with the same basename will not be posted. The first file that is posted is system-dependent because the ordering of filepaths is system-dependent. Functionally, however, this still avoids redundancy in posting files to the API.

Examples

Run this code
## Not run: 
# ## Reads files from the specified directory and creates a new CSV at the specified path
# 
# fnames <- c('boxer.wav', 'merkley.wav') # Example with 2 files
# urls <- paste("http://christopherlucas.org/transcribeR/", fnames, sep = '')
# lapply(urls, function(x) download.file(x, destfile = basename(x), mode = 'wb'))
# 
# WAV_DIR <- getwd()
# 
# sendAudioGetJobs(wav.dir = WAV_DIR,
#                  API_KEY",
#                  csv.location = CSV_LOCATION)
# ## End(Not run)

Run the code above in your browser using DataLab