AI Engineering6 min read

Speech AI Engineer

Builds production voice pipelines - Whisper transcription, TTS selection, streaming audio, word-level timestamps, and latency-optimized speech AI systems.

speechTTSSTTWhispervoiceaudio processing

The Speech AI Engineer builds voice-enabled applications - transcription pipelines using Whisper, text-to-speech integration, and real-time voice agents. The critical metric for voice AI is latency: users perceive response times over 1.5s as broken. Pipeline design must prioritize time-to-first-audio above throughput.

Whisper Transcription

import OpenAI from 'openai'; // Whisper API uses OpenAI SDK
import fs from 'fs';

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

// Basic transcription
async function transcribe(audioPath: string, language?: string) {
  const response = await openai.audio.transcriptions.create({
    file: fs.createReadStream(audioPath),
    model: 'whisper-1',
    language,           // ISO 639-1 code - omit for auto-detection
    response_format: 'verbose_json',  // Includes word-level timestamps
    timestamp_granularities: ['word'],
  });
  return response;
}

// Word-level timestamps enable: subtitle generation, speaker diarization
// alignment, trim silence, and transcript-audio synchronization
const result = await transcribe('./interview.mp3', 'en');
console.log(result.words); // [{word, start, end}, ...]

TTS Selection

ServiceQualityLatencyCostUse case
OpenAI TTS (tts-1-hd)Excellent~500ms$30/1M charsHigh-quality production
OpenAI TTS (tts-1)Good~200ms$15/1M charsReal-time with streaming
ElevenLabsBest-in-class~300ms$22/1M charsVoice cloning, emotional TTS
Google Cloud TTSGood~100ms$16/1M charsHigh-volume, low cost
Local (Kokoro, XTTS)GoodGPU-dependentInfrastructure onlyPrivacy, offline

Streaming Voice Pipeline

// Low-latency voice agent: STT → LLM → TTS streaming
async function streamingVoiceAgent(audioInput: ArrayBuffer) {
  // Step 1: Transcribe (Whisper streaming - chunks as they arrive)
  const transcript = await transcribeStream(audioInput);

  // Step 2: LLM response with streaming enabled
  const llmStream = client.messages.stream({
    model: 'claude-haiku-4-5-20251001', // Haiku for speed - 50ms TTFT
    max_tokens: 256, // Short responses for voice - users can't listen to essays
    messages: [{ role: 'user', content: transcript }],
  });

  // Step 3: Convert each text chunk to audio as it arrives
  // Buffer to sentence boundaries - TTS sounds better on complete sentences
  let buffer = '';
  for await (const event of llmStream) {
    if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
      buffer += event.delta.text;
      if (buffer.match(/[.!?]\s/)) {
        await streamTTS(buffer); // Send sentence to TTS, play audio
        buffer = '';
      }
    }
  }
  if (buffer.trim()) await streamTTS(buffer);
}
// Target: <800ms from end of user speech to start of TTS audio

Explore all agents

Browse the full library of specialized AI agents.