transcription
Real-time and batch speech-to-text via Deepgram — live transcript overlay for video rooms, post-meeting full transcript with search, speaker labels, and Postgres persistence. Use this skill when the user says "add transcription", "setup speech to text", "add captions", "transcribe audio", or "setup transcription".
What this skill does
# Transcription
Real-time and batch speech-to-text powered by [Deepgram](https://deepgram.com). Provides live streaming transcription for video rooms via Deepgram's WebSocket API, batch transcription for recorded audio, a scrolling real-time transcript panel with speaker labels, and a full post-meeting transcript viewer with search and speaker filtering. All transcripts are persisted to Postgres via Drizzle.
## Prerequisites
- Next.js app with `src/` directory and App Router
- `video-room` skill installed (LiveKit room infrastructure)
- `db` skill installed (Drizzle ORM with PostgreSQL)
- `env-config` skill installed (`src/env.ts`)
- shadcn/ui initialized
## Installation
```bash
bun add @deepgram/sdk
```
## Environment Variables
Add to `.env.local`:
```env
# Deepgram
DEEPGRAM_API_KEY=your-deepgram-api-key-here
```
### Update `src/env.ts`
Add to the `server` object:
```typescript
server: {
// ... existing variables
DEEPGRAM_API_KEY: z.string().min(1),
},
```
Add to the `runtimeEnv` object:
```typescript
runtimeEnv: {
// ... existing variables
DEEPGRAM_API_KEY: process.env.DEEPGRAM_API_KEY,
},
```
## What Gets Created
```
src/
├── lib/
│ ├── video/
│ │ ├── transcription.ts # Server-side Deepgram client, batch + streaming
│ │ ├── types-transcription.ts # TranscriptSegment, Transcript, Speaker types
│ │ └── use-transcription.ts # "use client" hook for live transcript state
│ └── db/
│ └── schema/
│ └── transcripts.ts # Drizzle: transcripts + transcript_segments tables
├── components/
│ └── video/
│ ├── live-transcript.tsx # Scrolling real-time transcript panel
│ └── transcript-viewer.tsx # Post-meeting full transcript with search
└── app/
└── api/
└── video/
└── transcripts/
├── route.ts # GET list / POST start transcription
└── [id]/
└── route.ts # GET full transcript with segments
```
## Database
After applying this skill, push the schema to create the `transcripts` and `transcript_segments` tables:
```bash
bunx drizzle-kit push
```
## Setup Steps
### Step 1: Create `src/lib/video/types-transcription.ts`
```typescript
export type Speaker = {
id: number;
name: string;
};
export type TranscriptSegment = {
speaker: number;
text: string;
startTime: number;
endTime: number;
confidence: number;
};
export type Transcript = {
id: string;
roomName: string;
segments: TranscriptSegment[];
speakers: Speaker[];
duration: number;
createdAt: Date;
};
export type LiveTranscriptEvent = {
type: "transcript";
segment: TranscriptSegment;
isFinal: boolean;
};
export type TranscriptionStatus = "idle" | "connecting" | "transcribing" | "error" | "stopped";
```
### Step 2: Create `src/lib/video/transcription.ts`
```typescript
import { createClient, LiveTranscriptionEvents } from "@deepgram/sdk";
import type { TranscriptSegment, Speaker } from "./types-transcription";
/**
* Create a configured Deepgram client.
* Must be called server-side only — uses DEEPGRAM_API_KEY.
*/
export function createDeepgramClient() {
const apiKey = process.env.DEEPGRAM_API_KEY;
if (!apiKey) {
throw new Error("DEEPGRAM_API_KEY is not set");
}
return createClient(apiKey);
}
/**
* Transcribe an audio buffer using Deepgram's batch (pre-recorded) API.
* Supports speaker diarization and punctuation.
*
* @param audioBuffer - Raw audio data (WAV, MP3, OGG, etc.)
* @param mimetype - MIME type of the audio (e.g., "audio/wav")
* @returns Transcript segments with speaker labels and timestamps.
*/
export async function transcribeAudio(
audioBuffer: Buffer,
mimetype = "audio/wav"
): Promise<{ segments: TranscriptSegment[]; speakers: Speaker[]; duration: number }> {
const client = createDeepgramClient();
const { result } = await client.listen.prerecorded.transcribeFile(audioBuffer, {
model: "nova-3",
smart_format: true,
diarize: true,
punctuate: true,
utterances: true,
mime_type: mimetype,
});
const segments: TranscriptSegment[] = [];
const speakerSet = new Set<number>();
const utterances = result?.results?.utterances ?? [];
for (const utterance of utterances) {
const speakerId = utterance.speaker ?? 0;
speakerSet.add(speakerId);
segments.push({
speaker: speakerId,
text: utterance.transcript,
startTime: utterance.start,
endTime: utterance.end,
confidence: utterance.confidence,
});
}
const speakers: Speaker[] = Array.from(speakerSet).map((id) => ({
id,
name: `Speaker ${id + 1}`,
}));
const duration = result?.metadata?.duration ?? 0;
return { segments, speakers, duration };
}
type LiveTranscriptionCallbacks = {
onSegment: (segment: TranscriptSegment, isFinal: boolean) => void;
onError: (error: Error) => void;
onClose: () => void;
};
type LiveTranscriptionHandle = {
send: (audioData: Buffer) => void;
close: () => void;
};
/**
* Create a live (streaming) transcription session via Deepgram's WebSocket API.
* Accumulates transcript segments with speaker labels and timestamps in real time.
*
* @param roomName - The video room name (used for logging/context).
* @param callbacks - Handlers for transcript segments, errors, and close events.
* @returns A handle with `send(audioData)` to push audio chunks and `close()` to end the session.
*/
export function createLiveTranscription(
roomName: string,
callbacks: LiveTranscriptionCallbacks
): LiveTranscriptionHandle {
const client = createDeepgramClient();
const connection = client.listen.live({
model: "nova-3",
smart_format: true,
diarize: true,
punctuate: true,
interim_results: true,
utterance_end_ms: 1000,
encoding: "linear16",
sample_rate: 16000,
channels: 1,
});
connection.on(LiveTranscriptionEvents.Open, () => {
console.log(`[transcription] Live session opened for room: ${roomName}`);
});
connection.on(LiveTranscriptionEvents.Transcript, (data) => {
const alternatives = data.channel?.alternatives;
if (!alternatives || alternatives.length === 0) return;
const alternative = alternatives[0];
const transcript = alternative.transcript;
if (!transcript || transcript.trim().length === 0) return;
const isFinal = data.is_final === true;
const speakerId = data.channel?.alternatives?.[0]?.words?.[0]?.speaker ?? 0;
const words = alternative.words ?? [];
const startTime = words.length > 0 ? (words[0].start ?? 0) : 0;
const lastWord = words.length > 0 ? words[words.length - 1] : undefined;
const endTime = lastWord?.end ?? startTime;
const segment: TranscriptSegment = {
speaker: speakerId,
text: transcript,
startTime,
endTime,
confidence: alternative.confidence ?? 0,
};
callbacks.onSegment(segment, isFinal);
});
connection.on(LiveTranscriptionEvents.Error, (error) => {
console.error(`[transcription] Error for room ${roomName}:`, error);
callbacks.onError(error instanceof Error ? error : new Error(String(error)));
});
connection.on(LiveTranscriptionEvents.Close, () => {
console.log(`[transcription] Live session closed for room: ${roomName}`);
callbacks.onClose();
});
return {
send(audioData: Buffer) {
connection.send(audioData.buffer.slice(audioData.byteOffset, audioData.byteOffset + audioData.byteLength));
},
close() {
connection.requestClose();
},
};
}
```
### Step 3: Create `src/lib/video/use-transcription.ts`
```typescript
"use client";
import { useState, useCallback, useEffect, useRef } from "react";
import type { TranscriptSegment, TranscriptionStatus } from "./types-transcription";
type UseTranscriptionOptions = {
/** The LiveKit data channel topic to subscribe to for transcript events */
dataTopic?: string;
};
type TranscriptMessRelated in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.