SKILL.md
AssemblyAI Core Workflow B — Streaming & LeMUR
Overview
Two advanced workflows: (1) real-time streaming transcription via WebSocket for live captioning and voice agents, and (2) LeMUR for applying LLMs to transcripts — summarization, Q&A, action items, and custom tasks.
Prerequisites
assemblyaipackage installed (npm install assemblyai)- API key configured in
ASSEMBLYAI_API_KEY - For streaming: microphone or audio stream source
Part 1: Real-Time Streaming Transcription
Step 1: Basic Streaming Setup
import { AssemblyAI } from 'assemblyai';
const client = new AssemblyAI({
apiKey: process.env.ASSEMBLYAI_API_KEY!,
});
const transcriber = client.streaming.createService({
// Model options: 'nova-3' (default), 'nova-3-pro' (highest accuracy)
speech_model: 'nova-3',
sample_rate: 16000,
});
transcriber.on('open', ({ sessionId }) => {
console.log('Session opened:', sessionId);
});
transcriber.on('transcript', (message) => {
// message_type: 'PartialTranscript' or 'FinalTranscript'
if (message.message_type === 'FinalTranscript') {
console.log('[Final]', message.text);
} else {
process.stdout.write(`\r[Partial] ${message.text}`);
}
});
transcriber.on('error', (error) => {
console.error('Streaming error:', error);
});
transcriber.on('close', (code, reason) => {
console.log('Session closed:', code, reason);
});
await transcriber.connect();
// Send audio chunks (16-bit PCM, 16kHz mono)
// transcriber.sendAudio(audioBuffer);
// When done:
// await transcriber.close();
Step 2: Stream from Microphone (Node.js)
import { AssemblyAI } from 'assemblyai';
import { spawn } from 'child_process';
const client = new AssemblyAI({
apiKey: process.env.ASSEMBLYAI_API_KEY!,
});
const transcriber = client.streaming.createService({
speech_model: 'nova-3',
sample_rate: 16000,
});
transcriber.on('transcript', (msg) => {
if (msg.message_type === 'FinalTranscript' && msg.text) {
console.log(msg.text);
}
});
await transcriber.connect();
// Use SoX to capture microphone audio as raw PCM
const mic = spawn('sox', [
'-d', // default audio device
'-t', 'raw', // raw PCM output
'-b', '16', // 16-bit
'-r', '16000', // 16kHz sample rate
'-c', '1', // mono
'-e', 'signed-integer',
'-', // pipe to stdout
]);
mic.stdout.on('data', (chunk: Buffer) => {
transcriber.sendAudio(chunk);
});
mic.on('close', async () => {
await transcriber.close();
});
// Handle Ctrl+C
process.on('SIGINT', async () => {
mic.kill();
await transcriber.close();
process.exit(0);
});
