Skip to main content

Overview

Every customer call contains signal that most teams never act on. This pipeline surfaces that signal automatically — agent effectiveness, customer sentiment, resolution quality, and upsell opportunities — using the Batch STT API for transcription and an LLM for structured analysis.
Sentiment via LLM. The Batch STT API returns speaker-separated segments with timestamps. Derive sentiment arcs, emotion shifts, and resolution quality in the LLM analysis step — no native sentiment fields are returned from the transcription layer.

Prerequisites & Installation

ffmpeg for audio prep. If you need to compress or convert audio before upload (10 MB per-file limit), install ffmpeg with brew install ffmpeg on macOS or apt install ffmpeg on Linux.

Authentication

Every request to the Batch STT API requires the X-API-Key-ID header. Store all credentials in environment variables.
.env
Never hardcode API keys. Do not commit API keys to version control. Use environment variables, a secrets manager, or a vault. Rotate keys immediately if exposed.

Supported Languages

ITN not supported on Batch STT. Transcripts are returned verbatim. Use REST STT if you need Inverse Text Normalization on short clips.

Batch API Flow

Creating a job does not start transcription. You must call /start after upload.
1

Create — POST /stt/v3/batch/jobs

Upload 1–100 audio files as multipart form data with a config JSON field (model, language_code, diarization settings). Receive a job_id with status CREATED. Transcription has not started yet.
2

Start — POST /stt/v3/batch/jobs/{job_id}/start

Trigger processing. Status transitions: STARTINGQUEUEDIN_PROGRESSCOMPLETED (or a terminal failure state).
3

Poll — GET /stt/v3/batch/jobs/{job_id}

Call the status endpoint every 10 seconds until status reaches a terminal state. Job status and file counts are returned — not transcript text.
4

Fetch transcript URLs — GET /files?status=COMPLETED

Each completed file includes a transcript_url (valid for 1 hour). Download each URL to retrieve full_transcript and segments.
5

Parse and analyze

Build speaker-separated conversation threads and talk-time logs from segments. Send the parsed transcript to Claude or OpenAI for structured analysis including sentiment arc.
Minimum poll interval: 10 seconds. Do not poll more frequently than every 10 seconds for the same job_id.

Pipeline Implementation

Imports & Setup

imports and config

Create, Start & Poll

process_audio_files + _poll_until_complete

Download & Parse — Speaker Transcripts & Talk Time

_download_and_parse fetches completed file entries, downloads each transcript_url, and writes two output files per call: a speaker-labelled conversation transcript and a per-speaker talk-time log.
_download_and_parse
Files produced per call: {name}_conversation.txt — speaker-labelled transcript · {name}_timing.json — talk time per speaker in seconds

LLM Analysis

The analysis step sends the parsed conversation to your chosen LLM with a structured prompt. Sentiment arc, resolution quality, and upsell signals are inferred here — not from the STT response. Switch providers by changing the LLM_PROVIDER environment variable.
analysis prompt
analyze_transcription + _call_llm

Ad-hoc Q&A

Ask any question against a transcribed call — useful for targeted investigation after bulk processing.
answer_question

Summary Report

Generate a single summary report across all analyzed calls in the session.
get_summary

Full Pipeline

call_analytics_pipeline.py

Sample Output

call_001_conversation.txt
call_001_analysis.txt (excerpt)

Limits & Notes