Transcribe a podcast or webinar, extract key phrases, then use LLM Gateway to generate a blog post draft with highlights.Products used:Pre-recorded STT + key phrases + LLM GatewayModel selection: Uses assemblyai-stt-3-7 with universal-2 fallback for multilingual content. If your content is English-only, assemblyai-stt-3-7 alone gives the best results.
Python
JavaScript
import requestsimport time# ── Config ────────────────────────────────────────────────────base_url = "https://api.assemblyai.com"headers = {"authorization": "YOUR_API_KEY"}audio_url = "https://assembly.ai/wildfires.mp3"# ── Step 1: Transcribe with key phrases enabled ──data = { "audio_url": audio_url, "speech_models": ["assemblyai-stt-3-7", "universal-2"], "language_detection": True, "auto_highlights": True,}response = requests.post(base_url + "/v2/transcript", headers=headers, json=data)response.raise_for_status()transcript_id = response.json()["id"]while True: result = requests.get(f"{base_url}/v2/transcript/{transcript_id}", headers=headers).json() if result["status"] == "completed": break elif result["status"] == "error": raise RuntimeError(f"Transcription failed: {result['error']}") time.sleep(3)# ── Step 2: Extract top key phrases ──highlights = result.get("auto_highlights_result", {}).get("results", [])top_phrases = sorted(highlights, key=lambda x: x["rank"], reverse=True)[:10]phrases_list = ", ".join(p["text"] for p in top_phrases)# ── Step 3: Generate blog post via LLM Gateway ──llm_response = requests.post( "https://llm-gateway.assemblyai.com/v1/chat/completions", headers=headers, json={ "model": "claude-sonnet-4-6", "messages": [ { "role": "user", "content": ( "You are a content writer. Transform this transcript into an engaging " "blog post.\n\n" "Requirements:\n" "- Write a compelling title and subtitle\n" "- Break the content into 3-5 sections with headers\n" "- Weave in the key phrases naturally\n" "- Add a TL;DR at the top\n" "- End with a call-to-action\n\n" f"Key phrases: {phrases_list}\n\n" "Transcript:\n{{ transcript }}" ), } ], "transcript_id": transcript_id, "max_tokens": 3000, },)llm_response.raise_for_status()print("=== Blog Post Draft ===\n")print(llm_response.json()["choices"][0]["message"]["content"])
const baseUrl = "https://api.assemblyai.com";const headers = { authorization: "YOUR_API_KEY", "Content-Type": "application/json",};const audioUrl = "https://assembly.ai/wildfires.mp3";// Step 1: Transcribe with key phrases enabledlet res = await fetch(`${baseUrl}/v2/transcript`, { method: "POST", headers, body: JSON.stringify({ audio_url: audioUrl, speech_models: ["assemblyai-stt-3-7", "universal-2"], language_detection: true, auto_highlights: true, }),});if (!res.ok) throw new Error(`Error: ${res.status}`);const { id: transcriptId } = await res.json();let result;while (true) { res = await fetch(`${baseUrl}/v2/transcript/${transcriptId}`, { headers }); result = await res.json(); if (result.status === "completed") break; if (result.status === "error") throw new Error(`Transcription failed: ${result.error}`); await new Promise((r) => setTimeout(r, 3000));}// Step 2: Extract top key phrasesconst highlights = result.auto_highlights_result?.results || [];const topPhrases = highlights .sort((a, b) => b.rank - a.rank) .slice(0, 10);const phrasesList = topPhrases.map((p) => p.text).join(", ");// Step 3: Generate blog post via LLM Gatewayres = await fetch("https://llm-gateway.assemblyai.com/v1/chat/completions", { method: "POST", headers, body: JSON.stringify({ model: "claude-sonnet-4-6", messages: [ { role: "user", content: "You are a content writer. Transform this transcript into an engaging " + "blog post.\n\n" + "Requirements:\n" + "- Write a compelling title and subtitle\n" + "- Break the content into 3-5 sections with headers\n" + "- Weave in the key phrases naturally\n" + "- Add a TL;DR at the top\n" + "- End with a call-to-action\n\n" + `Key phrases: ${phrasesList}\n\n` + "Transcript:\n{{ transcript }}", }, ], transcript_id: transcriptId, max_tokens: 3000, }),});if (!res.ok) throw new Error(`Error: ${res.status}`);const llmResult = await res.json();console.log("=== Blog Post Draft ===\n");console.log(llmResult.choices[0].message.content);
Example output
=== Blog Post Draft ===# When the Sky Turns Orange: Understanding Wildfire Smoke and Air Quality**How Canadian wildfires are reshaping air quality across the United States****TL;DR:** Wildfire smoke from Canada is triggering widespread air quality alertsin the US, with particulate matter levels reaching 10x normal in some cities.Here's what you need to know about the health risks and how to protect yourself.## The smoke crosses bordersHundreds of wildfires burning across Canada have sent massive plumes of smokesouthward into the United States, creating hazy skies and triggering air qualityalerts from the Midwest to the Eastern Seaboard...## Understanding particulate matterThe real danger lies in fine particulate matter — microscopic particles thatcan penetrate deep into your lungs and even enter your bloodstream...## Protecting your healthHealth experts recommend staying indoors, using air purifiers, and wearingN95 masks when outdoor exposure is unavoidable...## Looking aheadAs climate change intensifies wildfire seasons, these cross-border smoke eventsare likely to become more frequent...---*Want to transcribe your own podcast or webinar? Get started with AssemblyAI'sAPI at [assemblyai.com](https://assemblyai.com).*