From 35c328cfe126c819a092349989605f17a51a6fb4 Mon Sep 17 00:00:00 2001 From: TroyHernandez Date: Thu, 11 Jun 2026 18:40:44 -0500 Subject: [PATCH 1/2] stt(): attach a call_record attribute to the transcription stt produces an R object rather than a media file, so its provenance rides as an attribute instead of a sidecar file (cornball_sidecar v1, matching xtx.api/tts.api): the resolved request, the backend actually used, elapsed seconds, and a timestamp. Callers that serialize the result (e.g. lc40's srt_text.RDS) keep the provenance with it. --- R/stt.R | 23 ++++++++++++++++++++++- man/stt.Rd | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/R/stt.R b/R/stt.R index c4928f5..ebee9b8 100644 --- a/R/stt.R +++ b/R/stt.R @@ -27,6 +27,10 @@ #' \item{backend}{Which backend was used ("api" or "whisper").} #' \item{raw}{The raw response from the backend.} #' } +#' The result also carries a \code{"call_record"} attribute (cornball_sidecar +#' v1, as in xtx.api/tts.api): the resolved request, elapsed seconds, and a +#' timestamp -- provenance that rides with the transcription when callers +#' serialize it. #' #' @examples #' \dontrun{ @@ -57,7 +61,8 @@ stt <- function(file, model = NULL, language = NULL, resolved_backend <- .choose_backend(backend) # Dispatch to appropriate backend - if (resolved_backend == "openai") { + started <- Sys.time() + res <- if (resolved_backend == "openai") { .via_api( file = file, model = model, @@ -68,5 +73,21 @@ stt <- function(file, model = NULL, language = NULL, } else { .via_whisper(file = file, model = model, language = language) } + # stt produces an R object, not a media file, so the call record rides as + # an attribute (cornball_sidecar v1, as in xtx.api/tts.api); callers that + # serialize the result keep its provenance with it. + attr(res, "call_record") <- list( + cornball_sidecar = 1L, package = "stt.api", + version = as.character(utils::packageVersion("stt.api")), + fn = "stt", + request = Filter(Negate(is.null), + list(file = file, model = model, + language = language, + response_format = response_format, + backend = resolved_backend, prompt = prompt)), + elapsed = round(as.numeric(difftime(Sys.time(), started, + units = "secs")), 2), + created = format(Sys.time(), "%Y-%m-%dT%H:%M:%S%z")) + res } diff --git a/man/stt.Rd b/man/stt.Rd index 2f3022e..d89cfd9 100644 --- a/man/stt.Rd +++ b/man/stt.Rd @@ -38,6 +38,10 @@ A list with components: \item{backend}{Which backend was used ("api" or "whisper").} \item{raw}{The raw response from the backend.} } +The result also carries a \code{"call_record"} attribute (cornball_sidecar +v1, as in xtx.api/tts.api): the resolved request, elapsed seconds, and a +timestamp -- provenance that rides with the transcription when callers +serialize it. } \description{ Convert an audio file to text using a local whisper backend or From 711bd9c8875102e45350a74d2b8f31c26a4699cd Mon Sep 17 00:00:00 2001 From: TroyHernandez Date: Thu, 11 Jun 2026 18:40:44 -0500 Subject: [PATCH 2/2] Bump version to 0.2.1.1 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f07c870..dcf1723 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: stt.api Title: 'OpenAI' Compatible Speech-to-Text API Client -Version: 0.2.1 +Version: 0.2.1.1 Authors@R: c( person("Troy", "Hernandez", email = "troy@cornball.ai", role = c("aut", "cre"), comment = c(ORCID = "0009-0005-4248-604X")),