SP

speak-sdk-patterns

Standardized patterns for managing conversation sessions, audio preprocessing, and batch operations within the Speak SDK.

Install

mkdir -p .claude/skills/speak-sdk-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/8053" && unzip -o skill.zip -d .claude/skills/speak-sdk-patterns && rm skill.zip

Installs to .claude/skills/speak-sdk-patterns

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Production patterns for Speak language learning API: conversation sessions,
75 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Manage conversation state across turns
  • Preprocess audio to required specifications
  • Implement exponential backoff for API requests
  • Track learning progress across multiple sessions

How it works

It defines reusable classes and functions for managing session state, audio conversion, and request retries to ensure reliable integration.

Inputs & outputs

You give it
Raw audio file path
You get back
Processed WAV 16kHz mono file

When to use speak-sdk-patterns

  • Implementing production-ready Speak workflows
  • Refactoring existing Speak SDK usage
  • Standardizing team coding practices for language features
  • Managing multi-turn conversation state

About this skill

Speak SDK Patterns

Overview

Production patterns for Speak language learning API: conversation sessions, pronunciation assessment, audio preprocessing, and batch operations.

Prerequisites

  • Completed speak-install-auth setup
  • Valid API credentials configured
  • ffmpeg installed for audio processing

Instructions

Pattern 1: Conversation Session Manager

class ConversationManager {
  private client: SpeakClient;
  private sessions: Map<string, SessionState> = new Map();

  async startLesson(language: string, scenario: string, level: string) {
    const session = await this.client.startConversation({
      scenario, language, level, nativeLanguage: 'en',
    });
    this.sessions.set(session.id, {
      turns: [], startTime: Date.now(), language,
    });
    return session;
  }

  async submitResponse(sessionId: string, audioPath: string) {
    const turn = await this.client.sendTurn(sessionId, { audioPath });
    this.sessions.get(sessionId)?.turns.push(turn);
    return turn;
  }

  async endAndReport(sessionId: string) {
    const summary = await this.client.endSession(sessionId);
    const state = this.sessions.get(sessionId)!;
    return {
      ...summary,
      duration: (Date.now() - state.startTime) / 1000,
      totalTurns: state.turns.length,
      avgPronunciation: state.turns.reduce((s, t) =>
        s + (t.pronunciationScore || 0), 0) / state.turns.length,
    };
  }
}

Pattern 2: Audio Preprocessor

import { execSync } from 'child_process';

function preprocessAudio(inputPath: string): string {
  const outputPath = inputPath.replace(/\.[^.]+$/, '.processed.wav');
  // Convert to WAV 16kHz mono PCM — required by Speak API
  execSync(
    `ffmpeg -y -i "${inputPath}" -ar 16000 -ac 1 -c:a pcm_s16le "${outputPath}"`,
    { stdio: 'pipe' }
  );
  return outputPath;
}

Pattern 3: Retry with Backoff

async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (err: any) {
      if (err.response?.status === 429 && i < maxRetries - 1) {
        const wait = parseInt(err.response.headers['retry-after'] || '5');
        await new Promise(r => setTimeout(r, wait * 1000));
        continue;
      }
      throw err;
    }
  }
  throw new Error('Max retries exceeded');
}

Pattern 4: Progress Tracker

class LearningProgress {
  private history: SessionSummary[] = [];

  addSession(summary: SessionSummary) {
    this.history.push(summary);
  }

  getReport() {
    const recent = this.history.slice(-10);
    return {
      totalSessions: this.history.length,
      avgPronunciation: recent.reduce((s, h) => s + h.avgPronunciationScore, 0) / recent.length,
      totalMinutes: this.history.reduce((s, h) => s + h.durationMinutes, 0),
      vocabularyLearned: [...new Set(this.history.flatMap(h => h.newWords))].length,
    };
  }
}

Output

  • Patterns implementation complete
  • Speak API integration verified
  • Production-ready patterns applied

Error Handling

ErrorCauseSolution
401 UnauthorizedInvalid API keyVerify SPEAK_API_KEY environment variable
429 Rate LimitedToo many requestsWait Retry-After seconds, use backoff
Audio format errorWrong codec/sample rateConvert to WAV 16kHz mono with ffmpeg
Session expiredTimeout after 30 minStart a new conversation session

Resources

Next Steps

See speak-prod-checklist for production readiness.

Examples

Basic: Apply sdk patterns with default configuration for a standard Speak integration.

Advanced: Customize for production with error recovery, monitoring, and team-specific requirements.

When not to use it

  • For simple scripts not requiring state persistence
  • When not using the Speak SDK

Prerequisites

speak-install-auth setupValid API credentialsffmpeg installed

Limitations

  • Requires ffmpeg for audio conversion
  • Max retries limited to 3

How it compares

It establishes standardized architectural patterns for team consistency instead of ad-hoc implementation.

Compared to similar skills

speak-sdk-patterns side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
speak-sdk-patterns (this skill)027dReviewIntermediate
exa-upgrade-migration127dReviewIntermediate
instantly-sdk-patterns127dCautionIntermediate
deepgram-sdk-patterns127dReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

exa-upgrade-migration

jeremylongshore

Analyze, plan, and execute Exa SDK upgrades with breaking change detection. Use when upgrading Exa SDK versions, detecting deprecations, or migrating to new API versions. Trigger with phrases like "upgrade exa", "exa migration", "exa breaking changes", "update exa SDK", "analyze exa version".

14

instantly-sdk-patterns

jeremylongshore

Apply production-ready Instantly SDK patterns for TypeScript and Python. Use when implementing Instantly integrations, refactoring SDK usage, or establishing team coding standards for Instantly. Trigger with phrases like "instantly SDK patterns", "instantly best practices", "instantly code patterns", "idiomatic instantly".

12

deepgram-sdk-patterns

jeremylongshore

Apply production-ready Deepgram SDK patterns for TypeScript and Python. Use when implementing Deepgram integrations, refactoring SDK usage, or establishing team coding standards for Deepgram. Trigger with phrases like "deepgram SDK patterns", "deepgram best practices", "deepgram code patterns", "idiomatic deepgram", "deepgram typescript".

10

perplexity-known-pitfalls

jeremylongshore

Identify and avoid Perplexity anti-patterns and common integration mistakes. Use when reviewing Perplexity code for issues, onboarding new developers, or auditing existing Perplexity integrations for best practices violations. Trigger with phrases like "perplexity mistakes", "perplexity anti-patterns", "perplexity pitfalls", "perplexity what not to do", "perplexity code review".

01

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

Search skills

Search the agent skills registry