Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/twinmind-performance-tuning

@0d57af8
Run it yourself

Optimize TwinMind transcription accuracy and speed with Ear-3 model configuration, audio quality tuning, and caching strategies. Use when implementing performance tuning, or managing TwinMind meeting AI operations. Trigger with phrases like "twinmind performance tuning", "twinmind performance tuning".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/twinmind-performance-tuning

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesimplementation.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

TwinMind Performance Tuning - Detailed Implementation

Performance Metrics

export interface TranscriptionMetrics {
  wordErrorRate: number;          // Ear-3: ~5.26%
  diarizationErrorRate: number;   // ~3.8%
  confidenceScore: number;
  processingTime: number;
  realtimeFactor: number;         // ~0.3x
  firstWordLatency: number;       // ~300ms
  speakerCount: number;
  noiseLevel: string;
}

export function analyzePerformance(metrics: TranscriptionMetrics): string[] {
  const recommendations: string[] = [];
  if (metrics.wordErrorRate > 0.10) recommendations.push('High WER - improve audio quality');
  if (metrics.diarizationErrorRate > 0.05) recommendations.push('Speaker labeling issues - ensure clear audio');
  if (metrics.realtimeFactor > 0.5) recommendations.push('Slow processing - consider model optimization');
  if (metrics.noiseLevel === 'high') recommendations.push('High noise - apply noise reduction');
  return recommendations;
}

Audio Preprocessing

import ffmpeg from 'fluent-ffmpeg';

export async function preprocessAudio(inputPath: string, outputPath: string, options = {}): Promise<void> {
  const opts = { targetSampleRate: 16000, channels: 1, noiseReduction: true, normalization: true, format: 'mp3', ...options };

  return new Promise((resolve, reject) => {
    let command = ffmpeg(inputPath).audioFrequency(opts.targetSampleRate).audioChannels(opts.channels);

    if (opts.noiseReduction) {
      command = command.audioFilters(['highpass=f=200', 'lowpass=f=3000', 'afftdn=nf=-25']);
    }
    if (opts.normalization) {
      command = command.audioFilters(['loudnorm=I=-16:TP=-1.5:LRA=11']);
    }

    command.toFormat(opts.format).on('end', resolve).on('error', reject).save(outputPath);
  });
}

export async function assessAudioQuality(filePath: string) {
  const issues: string[] = [];
  const recommendations: string[] = [];
  const metadata = await getAudioMetadata(filePath);

  if (metadata.sampleRate < 16000) { issues.push(`Low sample rate: ${metadata.sampleRate} Hz`); recommendations.push('Use 16 kHz or higher'); }
  if (metadata.peakLevel > -1) { issues.push('Audio clipping'); recommendations.push('Reduce recording volume'); }
  if (metadata.noiseFloor > -40) { issues.push(`High noise floor: ${metadata.noiseFloor} dB`); recommendations.push('Use noise reduction'); }

  return { quality: issues.length === 0 ? 'excellent' : issues.length <= 1 ? 'good' : 'fair', issues, recommendations };
}

Model Configurations

export const modelConfigs: Record<string, ModelConfig> = {
  meeting: {
    model: 'ear-3', language: 'auto', diarization: true, punctuation: true, profanityFilter: false,
  },
  technical: {
    model: 'ear-3', language: 'en', diarization: true, punctuation: true, profanityFilter: false,
    vocabulary: ['API', 'SDK', 'microservice', 'Kubernetes', 'Docker', 'CI/CD', 'GraphQL', 'PostgreSQL'],
  },
  callCenter: {
    model: 'ear-3', language: 'auto', diarization: true, punctuation: true, profanityFilter: true,
  },
  medical: {
    model: 'ear-3-custom', language: 'en', diarization: true, punctuation: true, profanityFilter: false,
    vocabulary: ['diagnosis', 'prognosis', 'contraindication', 'hematology', 'cardiology'],
  },
  lecture: {
    model: 'ear-3', language: 'auto', diarization: false, punctuation: true, profanityFilter: false,
  },
  podcast: {
    model: 'ear-3', language: 'auto', diarization: true, punctuation: true, profanityFilter: false,
  },
};

export function getOptimalConfig(useCase: string): ModelConfig {
  return modelConfigs[useCase] || modelConfigs.meeting;
}

Streaming Optimization

export class OptimizedStreamingClient {
  private buffer: Float32Array[] = [];
  private config = { chunkDurationMs: 100, overlapMs: 50, maxBufferMs: 5000, interimResults: true };

  async processChunk(audioChunk: Float32Array): Promise<{ interim?: string; final?: string; confidence: number }> {
    this.buffer.push(audioChunk);
    const totalMs = this.buffer.length * this.config.chunkDurationMs;

    if (totalMs >= this.config.chunkDurationMs * 3) {
      const result = await this.sendToApi(this.concatenateBuffer());
      if (result.isFinal) {
        this.buffer = [];
        return { final: result.text, confidence: result.confidence };
      }
      this.trimBuffer();
      return { interim: result.text, confidence: result.confidence };
    }
    return { confidence: 0 };
  }

  private concatenateBuffer(): Float32Array {
    const total = this.buffer.reduce((sum, arr) => sum + arr.length, 0);
    const result = new Float32Array(total);
    let offset = 0;
    for (const arr of this.buffer) { result.set(arr, offset); offset += arr.length; }
    return result;
  }

  private trimBuffer(): void {
    if (this.buffer.length > 2) this.buffer = this.buffer.slice(-2);
  }
}

Caching and Deduplication

import crypto from 'crypto';

class TranscriptCache {
  private cache = new Map<string, { transcriptId: string; expiresAt: Date }>();
  private ttlMs = 24 * 60 * 60 * 1000;

  async hashAudio(audioUrl: string): Promise<string> {
    const response = await fetch(audioUrl);
    const buffer = await response.arrayBuffer();
    return crypto.createHash('sha256').update(Buffer.from(buffer)).digest('hex');
  }

  get(hash: string): string | null {
    const cached = this.cache.get(hash);
    if (!cached || new Date() > cached.expiresAt) { this.cache.delete(hash); return null; }
    return cached.transcriptId;
  }

  set(hash: string, transcriptId: string): void {
    this.cache.set(hash, { transcriptId, expiresAt: new Date(Date.now() + this.ttlMs) });
  }

  async transcribeWithCache(audioUrl: string): Promise<string> {
    const hash = await this.hashAudio(audioUrl);
    const cached = this.get(hash);
    if (cached) { console.log(`Cache hit: ${hash.substring(0, 8)}...`); return cached; }

    const client = getTwinMindClient();
    const result = await client.transcribe(audioUrl);
    this.set(hash, result.id);
    return result.id;
  }
}

export const transcriptCache = new TranscriptCache();

Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides tools for optimizing TwinMind transcription services, utilizing best practices for API key management and standard media processing libraries. No malicious patterns were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
What it can do
Reads files Edits files Runs commands
version
1.13.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "twinmind",
  "performance"
]
All 6 allowed tools
ReadWriteEditBash(npm:*)Bash(curl:*)Grep
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/twinmind-performance-tuning