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.zipInstalls 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,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
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-authsetup - 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
| Error | Cause | Solution |
|---|---|---|
| 401 Unauthorized | Invalid API key | Verify SPEAK_API_KEY environment variable |
| 429 Rate Limited | Too many requests | Wait Retry-After seconds, use backoff |
| Audio format error | Wrong codec/sample rate | Convert to WAV 16kHz mono with ffmpeg |
| Session expired | Timeout after 30 min | Start 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
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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| speak-sdk-patterns (this skill) | 0 | 27d | Review | Intermediate |
| exa-upgrade-migration | 1 | 27d | Review | Intermediate |
| instantly-sdk-patterns | 1 | 27d | Caution | Intermediate |
| deepgram-sdk-patterns | 1 | 27d | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by jeremylongshore
View all by jeremylongshore →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".
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".
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".
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".
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).
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.