| name | twinmind-performance-tuning |
| description | Optimize TwinMind transcription accuracy and processing speed.
Use when improving transcription quality, reducing latency,
or tuning model parameters for specific use cases.
Trigger with phrases like "twinmind performance", "improve transcription accuracy",
"faster twinmind", "optimize twinmind", "transcription quality".
|
| allowed-tools | Read, Write, Edit |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
TwinMind Performance Tuning
Overview
Optimize TwinMind for better transcription accuracy, faster processing, and improved user experience.
Prerequisites
- TwinMind Pro/Enterprise account
- Understanding of audio processing concepts
- Access to quality metrics and logs
Instructions
Step 1: Understand Performance Metrics
export interface TranscriptionMetrics {
wordErrorRate: number;
diarizationErrorRate: number;
confidenceScore: number;
processingTime: number;
realtimeFactor: number;
firstWordLatency: number;
speakerCount: number;
languageDetected: string;
noiseLevel: string;
}
export async function getTranscriptionMetrics(transcriptId: string): Promise<TranscriptionMetrics> {
const client = getTwinMindClient();
const response = await client.get(`/transcripts/${transcriptId}/metrics`);
return response.data;
}
export function analyzePerformance(metrics: TranscriptionMetrics): string[] {
const recommendations: string[] = [];
if (metrics.wordErrorRate > 0.10) {
recommendations.push('High WER - consider audio quality improvements');
}
if (metrics.diarizationErrorRate > 0.05) {
recommendations.push('Speaker labeling issues - ensure clear audio separation');
}
if (metrics.realtimeFactor > 0.5) {
recommendations.push('Slow processing - consider model optimization');
}
if (metrics.noiseLevel === 'high') {
recommendations.push('High background noise - recommend noise reduction');
}
return recommendations;
}
Step 2: Audio Quality Optimization
import ffmpeg from 'fluent-ffmpeg';
interface AudioPreprocessOptions {
targetSampleRate?: number;
channels?: number;
noiseReduction?: boolean;
normalization?: boolean;
format?: string;
}
const defaultOptions: AudioPreprocessOptions = {
targetSampleRate: 16000,
channels: 1,
noiseReduction: true,
normalization: true,
format: 'mp3',
};
export async function preprocessAudio(
inputPath: string,
outputPath: string,
options: AudioPreprocessOptions = {}
): Promise<void> {
const opts = { ...defaultOptions, ...options };
return new Promise( {
command = (inputPath)
.(opts.!)
.(opts.!);
(opts.) {
command = command.([
,
,
,
]);
}
(opts.) {
command = command.([
,
]);
}
command
.(opts.!)
.(, ())
.(, reject)
.(outputPath);
});
}
(): <{
: | | | ;
: [];
: [];
}> {
: [] = [];
: [] = [];
metadata = (filePath);
(metadata. < ) {
issues.();
recommendations.();
}
(metadata. && metadata. < ) {
issues.();
recommendations.();
}
(metadata. && metadata. > -) {
issues.();
recommendations.();
}
(metadata. && metadata. > -) {
issues.();
recommendations.();
}
quality = issues. === ? :
issues. <= ? :
issues. <= ? : ;
{ quality, issues, recommendations };
}
Step 3: Model Selection and Configuration
export interface ModelConfig {
model: 'ear-3' | 'ear-2' | 'ear-3-custom';
language?: string;
diarization: boolean;
punctuation: boolean;
profanityFilter: boolean;
vocabulary?: string[];
speakerHints?: string[];
}
export const modelConfigs: Record<string, ModelConfig> = {
meeting: {
model: 'ear-3',
language: 'auto',
diarization: true,
punctuation: true,
profanityFilter: false,
},
technical: {
model: 'ear-3',
language: ,
: ,
: ,
: ,
: [
, , , , ,
, , ,
],
},
: {
: ,
: ,
: ,
: ,
: ,
},
: {
: ,
: ,
: ,
: ,
: ,
: [
, , ,
, , ,
],
},
: {
: ,
: ,
: ,
: ,
: ,
},
: {
: ,
: ,
: ,
: ,
: ,
},
};
(): {
modelConfigs[useCase] || modelConfigs.;
}
Step 4: Streaming Optimization
export interface StreamingConfig {
chunkDurationMs: number;
overlapMs: number;
maxBufferMs: number;
interimResults: boolean;
endpointDetection: boolean;
}
const defaultStreamingConfig: StreamingConfig = {
chunkDurationMs: 100,
overlapMs: 50,
maxBufferMs: 5000,
interimResults: true,
endpointDetection: true,
};
export class OptimizedStreamingClient {
private config: StreamingConfig;
private buffer: Float32Array[] = [];
private lastInterimResult = '';
constructor(config: <> = {}) {
. = { ...defaultStreamingConfig, ...config };
}
(: ): <{
?: ;
?: ;
: ;
}> {
..(audioChunk);
totalMs = .. * (..);
(totalMs >= .. * ) {
result = .(.());
(result.) {
. = [];
{
: result.,
: result.,
};
} {
.();
{
: result.,
: result.,
};
}
}
{ : };
}
(): {
totalLength = ..( sum + arr., );
result = (totalLength);
offset = ;
( arr .) {
result.(arr, offset);
offset += arr.;
}
result;
}
(): {
(.. > ) {
. = ..(-);
}
}
(: ): <{
: ;
: ;
: ;
}> {
client = ();
response = client.(, {
: .(audio.).(),
: ..,
});
response.;
}
}
Step 5: Caching and Deduplication
import crypto from 'crypto';
interface CachedTranscript {
hash: string;
transcriptId: string;
createdAt: Date;
expiresAt: Date;
}
class TranscriptCache {
private cache = new Map<string, CachedTranscript>();
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): | {
cached = ..(hash);
(!cached) ;
( () > cached.) {
..(hash);
;
}
cached.;
}
(: , : ): {
..(hash, {
hash,
transcriptId,
: (),
: (.() + .),
});
}
(: ): <> {
hash = .(audioUrl);
cachedId = .(hash);
(cachedId) {
.();
cachedId;
}
.();
client = ();
result = client.(audioUrl);
.(hash, result.);
result.;
}
}
transcriptCache = ();
Output
- Performance metrics tracking
- Audio preprocessing pipeline
- Model configuration for use cases
- Streaming optimization
- Caching and deduplication
Performance Benchmarks
| Metric | Target | Ear-3 Actual |
|---|
| Word Error Rate | < 10% | ~5.26% |
| Diarization Error Rate | < 5% | ~3.8% |
| Real-time Factor | < 0.5x | ~0.3x |
| First Word Latency | < 500ms | ~300ms |
| Languages Supported | 100+ | 140+ |
Error Handling
| Issue | Cause | Solution |
|---|
| High WER | Poor audio quality | Apply preprocessing |
| Slow processing | Large file | Use streaming API |
| Wrong language | Auto-detect failed | Specify language explicitly |
| Missing speakers | Low audio separation | Improve microphone setup |
Resources
Next Steps
For cost optimization, see twinmind-cost-tuning.