
Example: Audio transcription and analysis
example_audio.RmdThis example demonstrates two ways of analyzing audio content. The
first is a two-step process: (1) transcribing audio to text with
qlm_transcribe(), and (2) extracting structured information
from the transcripts using qlm_code(), which records how
the transcripts were made. The second, added in quallmer 0.5, codes the
recordings directly: a codebook with input_type = "audio"
sends each file to a multimodal model, which transcribes and codes it in
one pass. Both workflows enable large-scale analysis of speeches,
interviews, and other audio content, and the final section compares
their results.
Loading packages and data
First, we identify the audio files to analyze:
# Get all audio files from the data folder
audio_files <- list.files("data/audio/",
pattern = "\\.(wav|mp3)$",
full.names = TRUE)
cat("Found", length(audio_files), "audio files:\n")## Found 6 audio files:
for (f in audio_files) {
size_mb <- file.size(f) / 1024^2
duration_sec <- NA # Would require audio package to calculate
cat(sprintf(" %s (%.2f MB)\n", basename(f), size_mb))
}## F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 (0.50 MB)
## harvard.wav (3.10 MB)
## OSR_cn_000_0072_8k.wav (0.30 MB)
## OSR_cn_000_0075_8k.wav (0.38 MB)
## OSR_fr_000_0041_8k.wav (1.22 MB)
## OSR_in_000_0064_8k.wav (0.57 MB)
These audio files contain speech samples in multiple languages from the Open Speech Repository and other sources.
Step 1: Transcribing the recordings
qlm_transcribe() sends each recording to a
speech-to-text model and returns the transcripts as a character vector
that carries its own provenance: the file each transcript came from and
its SHA-256 hash, the model, the time, and the usage the provider
reported. The default model is OpenAI’s
gpt-4o-mini-transcribe; whisper-1 and
gpt-4o-transcribe are reached the same way, and a Gemini
chat model can transcribe too
(model = "google_gemini/gemini-2.5-flash"). The requests
run in parallel with a progress bar. Unnamed files are named by their
basenames, and those names become the .id of each unit when
the transcripts are coded.
transcripts <- qlm_transcribe(audio_files)
# Save transcripts, provenance included
saveRDS(transcripts, "data/transcripts.rds")Viewing the transcripts
Printing the object shows the first line of each transcript under its name:
transcripts## <qlm_transcript: 6 transcripts; model openai/gpt-4o-mini-transcribe>
## F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3: And this is such an important topic...
## harvard.wav: The stale smell of old beer lingers. It takes heat to bring out ...
## OSR_cn_000_0072_8k.wav: 院子门口不远处就是一个地铁站,这是一个美丽而神奇的景象,树上长满了又大又甜的桃子,海豚和鲸鱼的表演是很好看...
## OSR_cn_000_0075_8k.wav: 天文望远镜可以用来观察天空。他到过很多地方观光旅游,山间的小道蜿蜒曲折。春天来了,山上开满了樱花;下雪以后...
## OSR_fr_000_0041_8k.wav: Pourrais-je avoir un verre d'eau ? La SNCF assurera u...
## OSR_in_000_0064_8k.wav: शालिनी के पास सौ रुपये हैं। सीता और सुनील का लड़का बह...
The provenance table has one row per recording. It is what
qlm_code() will record with the coded run, so that the
audit trail says which transcription process produced the text:
attr(transcripts, "provenance") %>%
select(.id, status, source, size, sha256, model) %>%
mutate(sha256 = paste0(substr(sha256, 1, 12), "...")) %>%
kable(caption = "Provenance of each transcript")| .id | status | source | size | sha256 | model |
|---|---|---|---|---|---|
| F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | ok | F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | 524288 | 4a7f23c350e0… | openai/gpt-4o-mini-transcribe |
| harvard.wav | ok | harvard.wav | 3249924 | 971b41636704… | openai/gpt-4o-mini-transcribe |
| OSR_cn_000_0072_8k.wav | ok | OSR_cn_000_0072_8k.wav | 319526 | a7e2e6c7a047… | openai/gpt-4o-mini-transcribe |
| OSR_cn_000_0075_8k.wav | ok | OSR_cn_000_0075_8k.wav | 398442 | 3fd3b56518d3… | openai/gpt-4o-mini-transcribe |
| OSR_fr_000_0041_8k.wav | ok | OSR_fr_000_0041_8k.wav | 1275156 | 381d49ce7f50… | openai/gpt-4o-mini-transcribe |
| OSR_in_000_0064_8k.wav | ok | OSR_in_000_0064_8k.wav | 599896 | 24955a6fcaa4… | openai/gpt-4o-mini-transcribe |
The usage column holds what the endpoint reported, here audio and
text tokens; whisper-1 reports seconds of audio instead. No
dollar cost is computed for a transcription, since ellmer has no rates
for transcription models, but the usage is there to cost by hand:
usage <- attr(transcripts, "provenance")$usage
cat("Audio tokens transcribed:",
sum(sapply(usage, function(u) u$input_token_details$audio_tokens)), "\n")## Audio tokens transcribed: 1964
A count of words per transcript, for a sense of scale:
word_counts <- map_int(transcripts, ~length(strsplit(.x, "\\s+")[[1]]))
data.frame(file = names(transcripts), words = word_counts, row.names = NULL) %>%
kable(caption = "Transcript length")| file | words |
|---|---|
| F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | 52 |
| harvard.wav | 43 |
| OSR_cn_000_0072_8k.wav | 2 |
| OSR_cn_000_0075_8k.wav | 1 |
| OSR_fr_000_0041_8k.wav | 119 |
| OSR_in_000_0064_8k.wav | 74 |
Recordings on the web
qlm_transcribe() also takes a URL, which it downloads to
a temporary file, transcribes, and removes. The hash recorded is of the
downloaded bytes, so a transcript is tied to the recording itself rather
than to a path. The Chinese clip above is a copy of one in the Open
Speech Repository; transcribing the web copy records the same hash as
the local file:
web <- qlm_transcribe(
c(web_copy = "https://www.voiptroubleshooter.com/open_speech/chinese/OSR_cn_000_0072_8k.wav")
)
saveRDS(web, "data/transcript_web.rds")
local_row <- attr(transcripts, "provenance") %>% filter(source == "OSR_cn_000_0072_8k.wav")
web_row <- attr(web, "provenance")
cat("Local copy: ", local_row$sha256, "\n")## Local copy: a7e2e6c7a0476d0286c6b1df92d15ab938888dfecd73efb29e4a0b82740fa761
cat("Web copy: ", web_row$sha256, "\n")## Web copy: a7e2e6c7a0476d0286c6b1df92d15ab938888dfecd73efb29e4a0b82740fa761
## Same recording: TRUE
A second transcriber
The transcript is an instrument of its own, and two transcribers can
be set beside each other on the same recordings. A Gemini chat model
transcribes through the same function: qlm_transcribe()
uploads each recording and asks the model for a verbatim transcript, and
the same names, hashes and provenance come back. The route is chosen by
the provider prefix, not by a list of models known to transcribe:
openai/ and any provider registered with
qlm_register_provider() go to a transcription endpoint,
every other provider gets the recording through a chat, and a model that
cannot hear it is refused by its provider at no cost. Gemini’s dedicated
transcription model, gemini-3.5-transcribe, cannot be
reached through ellmer yet (it rejects the system instruction ellmer
always sends), so a chat model in the flash or
pro family is the Gemini route.
transcripts_gemini <- qlm_transcribe(audio_files, model = "google_gemini/gemini-2.5-flash")
saveRDS(transcripts_gemini, "data/transcripts_gemini.rds")The two transcribers heard the same Mandarin clip differently: one writes Simplified characters and the other Traditional, and in the fourth sentence one hears 鲸鱼 (whale) where the other hears 金魚 (goldfish), a homophone. Either transcript can be coded; the point is that the coded run says which one was.
clip <- "OSR_cn_000_0072_8k.wav"
cat("gpt-4o-mini-transcribe:\n", transcripts[[clip]], "\n\n")## gpt-4o-mini-transcribe:
## 院子门口不远处就是一个地铁站,这是一个美丽而神奇的景象,树上长满了又大又甜的桃子,海豚和鲸鱼的表演是很好看的节目。 邮局门前的人行道上有一个蓝色的邮箱。
cat("gemini-2.5-flash:\n", transcripts_gemini[[clip]], "\n")## gemini-2.5-flash:
## 院子門口不遠處就是一個地鐵站。 這是一個美麗而神奇的景象。 樹上長滿了又大又甜的桃子。 海豚和金魚的表演是很好看的節目。 郵局門前的人行道上有一個藍色的郵箱。
For the Gemini route the usage is ellmer’s token count and cost, with the qualification that ellmer prices audio tokens at the text rate:
usage_gemini <- attr(transcripts_gemini, "provenance")$usage
cat("Input tokens:", sum(sapply(usage_gemini, function(u) u$tokens$input)),
" Cost at the text rate: $", round(sum(sapply(usage_gemini, function(u) u$cost)), 4), "\n")## Input tokens: 6540 Cost at the text rate: $ 0.0035
Step 2: Defining the transcript analysis codebook
Now we create a codebook to extract structured information from the transcripts. This codebook analyzes language, topics, tone, and content:
# Define a comprehensive transcript analysis codebook
codebook_transcripts <- qlm_codebook(
name = "Speech Transcript Analysis",
instructions = paste(
"You are a research assistant analyzing transcribed speech content.",
"Provide structured analysis of the speech based on its content.",
"Be objective and accurate in your assessments."
),
schema = ellmer::type_object(
language = ellmer::type_string(
"Primary language of the speech, in English (e.g., 'English', 'Mandarin', 'French', 'Indonesian')"
),
language_confidence = ellmer::type_enum(
c("high", "medium", "low"),
"Confidence in language identification"
),
speech_type = ellmer::type_enum(
c("conversational", "formal_speech", "reading", "spontaneous", "other"),
"Type or style of speech"
),
main_topics = ellmer::type_string(
"Main topics or themes discussed in the speech (comma-separated, max 5 topics)"
),
key_phrases = ellmer::type_string(
"Important phrases or keywords mentioned (comma-separated, max 5 phrases)"
),
tone = ellmer::type_enum(
c("formal", "informal", "neutral", "technical", "conversational"),
"Overall tone of the speech"
),
sentiment = ellmer::type_enum(
c("positive", "negative", "neutral", "mixed"),
"Overall sentiment expressed in the speech"
),
summary = ellmer::type_string(
"Brief 2-3 sentence summary of the speech content"
)
),
role = "You are an expert linguist and discourse analyst.",
input_type = "text"
)
# View the codebook structure
codebook_transcripts## quallmer codebook: Speech Transcript Analysis
## Input type: text
## Role: You are an expert linguist and discourse analyst.
## Instructions: You are a research assistant analyzing transcribed speech co...
## Output schema:ellmer::TypeObject
## Levels:
## language: nominal
## language_confidence: nominal
## speech_type: nominal
## main_topics: nominal
## key_phrases: nominal
## tone: nominal
## sentiment: nominal
## summary: nominal
Coding transcripts using Gemini 2.5 Flash
We use Gemini 2.5 Flash to analyze the transcripts. This model is fast and cost-effective for text analysis:
# Apply transcript analysis using qlm_code()
coded_transcripts <- qlm_code(
transcripts,
codebook = codebook_transcripts,
model = "google_gemini/gemini-2.5-flash",
name = "audio_transcripts_gemini",
notes = "Analysis of multilingual speech transcripts",
include_cost = TRUE
)
# Save results
saveRDS(coded_transcripts, "data/coded_transcripts_gemini.rds")The run records the transcription behind each unit.
qlm_replicate() and qlm_backfill() code these
stored transcripts again without another transcription request, and
qlm_trail() reports the table below as part of the
instrument:
qlm_meta(coded_transcripts, "transcription") %>%
select(.id, source, sha256, model, status) %>%
mutate(sha256 = paste0(substr(sha256, 1, 12), "...")) %>%
kable(caption = "Transcription recorded with the coded run")| .id | source | sha256 | model | status |
|---|---|---|---|---|
| F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | 4a7f23c350e0… | openai/gpt-4o-mini-transcribe | ok |
| harvard.wav | harvard.wav | 971b41636704… | openai/gpt-4o-mini-transcribe | ok |
| OSR_cn_000_0072_8k.wav | OSR_cn_000_0072_8k.wav | a7e2e6c7a047… | openai/gpt-4o-mini-transcribe | ok |
| OSR_cn_000_0075_8k.wav | OSR_cn_000_0075_8k.wav | 3fd3b56518d3… | openai/gpt-4o-mini-transcribe | ok |
| OSR_fr_000_0041_8k.wav | OSR_fr_000_0041_8k.wav | 381d49ce7f50… | openai/gpt-4o-mini-transcribe | ok |
| OSR_in_000_0064_8k.wav | OSR_in_000_0064_8k.wav | 24955a6fcaa4… | openai/gpt-4o-mini-transcribe | ok |
Examining the results
Let’s view the extracted information:
# Display key results
coded_transcripts %>%
select(.id, language, language_confidence, speech_type,
tone, sentiment) %>%
kable(
col.names = c("File", "Language", "Confidence", "Type", "Tone", "Sentiment"),
caption = "Transcript Analysis Results"
)| File | Language | Confidence | Type | Tone | Sentiment |
|---|---|---|---|---|---|
| F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | English | high | spontaneous | conversational | negative |
| harvard.wav | English | high | other | neutral | mixed |
| OSR_cn_000_0072_8k.wav | Mandarin | high | other | neutral | positive |
| OSR_cn_000_0075_8k.wav | Chinese | high | spontaneous | neutral | neutral |
| OSR_fr_000_0041_8k.wav | French | high | other | neutral | mixed |
| OSR_in_000_0064_8k.wav | Hindi | high | spontaneous | neutral | neutral |
The coding cost for 6 transcripts, kept separate from the transcription usage above:
cat("Analysis cost (Gemini): $",
round(sum(coded_transcripts$cost, na.rm = TRUE), 4), "\n", sep = "")## Analysis cost (Gemini): $0.0119
Language distribution
cat("Languages detected:\n")## Languages detected:
##
## Chinese English French Hindi Mandarin
## 1 2 1 1 1
cat("\nLanguage confidence levels:\n")##
## Language confidence levels:
##
## high medium low
## 6 0 0
Topics and themes
# Display topics for each transcript
coded_transcripts %>%
select(.id, main_topics) %>%
kable(
col.names = c("File", "Main Topics"),
caption = "Topics Identified in Each Transcript"
)| File | Main Topics |
|---|---|
| F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | societal tension, stress, negative news, impatience |
| harvard.wav | Sensory experiences, Food and beverages, Health benefits, Temperature effects |
| OSR_cn_000_0072_8k.wav | daily life scenes,nature,animals,urban environment |
| OSR_cn_000_0075_8k.wav | astronomy, travel, natural scenery, seasons |
| OSR_fr_000_0041_8k.wav | Daily observations, Emotions, Actions, Idioms, Transportation |
| OSR_in_000_0064_8k.wav | personal attributes, possessions, hobbies, advice, interpersonal relations |
Detailed view of one transcript
Let’s examine the complete analysis for one transcript:
# Select the first transcript for detailed view
transcript_detail <- coded_transcripts[1, ]
cat("=== Detailed Analysis ===\n\n")## === Detailed Analysis ===
cat("File:", transcript_detail$.id, "\n\n")## File: F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3
cat("Language:", transcript_detail$language,
"(", transcript_detail$language_confidence, "confidence )\n")## Language: English ( 1 confidence )
cat("Speech type:", transcript_detail$speech_type, "\n")## Speech type: 4
cat("Tone:", transcript_detail$tone, "\n")## Tone: 5
cat("Sentiment:", transcript_detail$sentiment, "\n\n")## Sentiment: 2
cat("Main topics:", transcript_detail$main_topics, "\n\n")## Main topics: societal tension, stress, negative news, impatience
cat("Key phrases:", transcript_detail$key_phrases, "\n\n")## Key phrases: tension in the air, stressed out, news is so negative, impatience of people
cat("Summary:", transcript_detail$summary, "\n\n")## Summary: The speaker observes a significant amount of tension and impatience in the current societal atmosphere. They attribute this to potential factors like negative headlines, widespread stress, or general negativity in the news. The overall sentiment conveyed is one of concern regarding the pervasive impatience experienced in daily life.
cat("=== Transcript (first 300 chars) ===\n")## === Transcript (first 300 chars) ===
## And this is such an important topic because I'm sure you felt it. There's tension in the air, right? Everywhere you go. I don't know if it's the headlines or the fact that everybody is so stressed out or the news is so negative, but the impatience of people when they're waiting. ...
Summary statistics
# Speech type distribution
cat("Speech types:\n")## Speech types:
##
## conversational formal_speech reading spontaneous other
## 0 0 0 3 3
# Tone distribution
cat("\nTone distribution:\n")##
## Tone distribution:
##
## formal informal neutral technical conversational
## 0 0 5 0 1
# Sentiment distribution
cat("\nSentiment distribution:\n")##
## Sentiment distribution:
##
## positive negative neutral mixed
## 1 1 2 2
Coding the recordings directly
The two-step route has a cost beyond the transcription fee: the
coding model only ever sees the transcript, so anything the transcriber
dropped is gone, and the transcript itself is a second instrument whose
errors are invisible to the coder. Since quallmer 0.5, a codebook can
declare input_type = "audio", and qlm_code()
then uploads each recording to the provider and sends the model a
reference to it alongside the instructions. The model listens to the
audio itself, so the schema can ask for a transcript as one field among
the others.
Which providers accept audio this way is not checked in advance: the
recordings are uploaded and the model is asked, and a provider that
cannot take them refuses with its own message. As of this writing only
Google Gemini accepts an uploaded recording alongside a
schema-constrained request; OpenAI’s audio models refuse such a request
and Anthropic takes no audio at all, so for those providers the two-step
route through qlm_transcribe() above remains the way. See
the section “Audio input” in ?qlm_code for the details.
The codebook is the one used on the transcripts with one field added, so that the two routes can be compared field by field:
codebook_audio <- qlm_codebook(
name = "Speech Audio Analysis",
instructions = paste(
"You are a research assistant analyzing a speech recording.",
"Listen to the recording, transcribe it, and provide structured analysis",
"of the speech based on its content. Be objective and accurate in your assessments."
),
schema = ellmer::type_object(
transcript = ellmer::type_string(
"Verbatim transcript of the speech, in the language spoken"
),
language = ellmer::type_string(
"Primary language of the speech, in English (e.g., 'English', 'Mandarin', 'French', 'Indonesian')"
),
language_confidence = ellmer::type_enum(
c("high", "medium", "low"),
"Confidence in language identification"
),
speech_type = ellmer::type_enum(
c("conversational", "formal_speech", "reading", "spontaneous", "other"),
"Type or style of speech"
),
main_topics = ellmer::type_string(
"Main topics or themes discussed in the speech (comma-separated, max 5 topics)"
),
key_phrases = ellmer::type_string(
"Important phrases or keywords mentioned (comma-separated, max 5 phrases)"
),
tone = ellmer::type_enum(
c("formal", "informal", "neutral", "technical", "conversational"),
"Overall tone of the speech"
),
sentiment = ellmer::type_enum(
c("positive", "negative", "neutral", "mixed"),
"Overall sentiment expressed in the speech"
),
summary = ellmer::type_string(
"Brief 2-3 sentence summary of the speech content"
)
),
role = "You are an expert linguist and discourse analyst.",
input_type = "audio"
)The input is the vector of file paths rather than the transcripts.
Naming it by file name gives the same .id values as the
transcript run, which is what the comparison below merges on. Every file
is uploaded before the first coding request is sent, so a failed upload
stops the run with nothing spent.
names(audio_files) <- basename(audio_files)
coded_audio <- qlm_code(
audio_files,
codebook = codebook_audio,
model = "google_gemini/gemini-2.5-flash",
name = "audio_direct_gemini",
notes = "Single-pass coding of the recordings, no transcription step",
include_cost = TRUE
)
saveRDS(coded_audio, "data/coded_audio_gemini.rds")
coded_audio %>%
select(.id, language, language_confidence, speech_type, tone, sentiment) %>%
kable(
col.names = c("File", "Language", "Confidence", "Type", "Tone", "Sentiment"),
caption = "Direct Audio Analysis Results"
)| File | Language | Confidence | Type | Tone | Sentiment |
|---|---|---|---|---|---|
| F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | English | high | spontaneous | conversational | negative |
| harvard.wav | English | high | reading | neutral | neutral |
| OSR_cn_000_0072_8k.wav | Mandarin | high | spontaneous | neutral | neutral |
| OSR_cn_000_0075_8k.wav | Mandarin | high | reading | neutral | neutral |
| OSR_fr_000_0041_8k.wav | French | high | reading | neutral | neutral |
| OSR_in_000_0064_8k.wav | Hindi | high | reading | neutral | neutral |
Transcripts from two instruments
The model’s transcript can be set beside the one from
qlm_transcribe() for the same recording. Here is the first
clip:
first <- coded_audio$.id[1]
cat("=== gpt-4o-mini-transcribe, through qlm_transcribe() ===\n")## === gpt-4o-mini-transcribe, through qlm_transcribe() ===
cat(transcripts[[first]], "\n\n")## And this is such an important topic because I'm sure you felt it. There's tension in the air, right? Everywhere you go. I don't know if it's the headlines or the fact that everybody is so stressed out or the news is so negative, but the impatience of people when they're waiting.
cat("=== gemini-2.5-flash, in the same pass as the coding ===\n")## === gemini-2.5-flash, in the same pass as the coding ===
cat(coded_audio$transcript[coded_audio$.id == first], "\n")## And this is such an important topic because I'm sure you've felt it. There's tension in the air, right? Everywhere you go. I don't know if it's the headlines or the fact that everybody is so stressed out or the news is so negative, but the impatience of people when they're waiting
Agreement between the two routes
Both runs are qlm_coded objects keyed by file name, so
qlm_compare() measures their agreement on the categorical
fields exactly as it would for two coders:
qlm_compare(coded_transcripts, coded_audio,
by = c("language", "speech_type", "tone", "sentiment"))##
## ── Inter-rater reliability ──
##
## Subjects: 6
## Raters: 2
##
## ── language (nominal)
## Percent agreement 0.8333
## Krippendorff's alpha 0.8000
## Kappa 0.7857
##
##
## ── speech_type (nominal)
## Percent agreement 0.1667
## Krippendorff's alpha -0.1702
## Kappa 0.0000
##
##
## ── tone (nominal)
## Percent agreement 1.0000
## Krippendorff's alpha 1.0000
## Kappa 1.0000
##
##
## ── sentiment (nominal)
## Percent agreement 0.5000
## Krippendorff's alpha 0.2326
## Kappa 0.2800
##
Disagreement here is not simply error in one route: the two models
heard different things (one a transcript, one the audio) and were asked
the same questions. A gold-standard subset coded by hand, checked with
qlm_validate(), is what settles which route is closer to
the truth for a given corpus.
Cost and provenance
The cost of the direct run is reported by qlm_code(),
with a qualification: providers price audio tokens above text tokens,
and ellmer prices the total at the text rate, so the figure is
potentially underestimated. The note travels with the object and appears
when it is printed and in the audit trail.
cat("Direct coding cost (Gemini, at the text rate): $",
round(sum(coded_audio$cost, na.rm = TRUE), 4), "\n", sep = "")## Direct coding cost (Gemini, at the text rate): $0.0159
A run on files also records what it coded. Each unit’s file name,
size and SHA-256 hash are kept in the run’s metadata;
qlm_replicate() and qlm_backfill() check them
before uploading the files again, and refuse to continue if a path now
points at different bytes.
qlm_meta(coded_audio, "input_files") %>%
mutate(sha256 = paste0(substr(sha256, 1, 12), "...")) %>%
kable(caption = "Files behind each coded unit")| .id | file | size | sha256 |
|---|---|---|---|
| F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | F1523643-7930-4FCA-B0E1-1CB5AEBE6BF2.mp3 | 524288 | 4a7f23c350e0… |
| harvard.wav | harvard.wav | 3249924 | 971b41636704… |
| OSR_cn_000_0072_8k.wav | OSR_cn_000_0072_8k.wav | 319526 | a7e2e6c7a047… |
| OSR_cn_000_0075_8k.wav | OSR_cn_000_0075_8k.wav | 398442 | 3fd3b56518d3… |
| OSR_fr_000_0041_8k.wav | OSR_fr_000_0041_8k.wav | 1275156 | 381d49ce7f50… |
| OSR_in_000_0064_8k.wav | OSR_in_000_0064_8k.wav | 599896 | 24955a6fcaa4… |
Creating an audit trail
Document the complete analysis:
qlm_trail(coded_transcripts, coded_audio, path = "audio_analysis")This creates two files:
-
audio_analysis.rds: Complete trail object containing the coding run, codebook, and metadata -
audio_analysis.qmd: Quarto document with full audit trail documentation
Summary
This example demonstrates:
-
Two-step workflow: Transcription
(
qlm_transcribe()) → Analysis (LLM), which works with any coding model, and records the transcription with the coded run -
Direct workflow:
input_type = "audio"sends the recordings themselves to a multimodal model, currently Gemini, which transcribes and codes in one pass - Multilingual capability: Both routes handle multiple languages automatically
-
Structured extraction: The same codebook fields
serve both routes, so
qlm_compare()measures their agreement - Scalability: Process multiple audio files in batch
- Reproducibility: Transcripts carry their provenance, file hashes are recorded on both routes, and both runs go into the audit trail
Both workflows enable researchers to analyze audio content at scale, from political speeches to interviews to podcast episodes. The two-step route keeps transcription as a separate, cacheable instrument that any coding model can read; the direct route lets the model hear the recording, at the price of being tied to the providers that accept audio.