Skip to main content

Welcome to Tafrigh

Tafrigh is a Node.js audio processing library that simplifies the process of transcribing audio files using Wit.ai. The library includes built-in support for splitting audio into chunks, noise reduction, and managing multiple API keys to optimize transcription workflows for larger files.

Key features

Audio splitting

Automatically splits audio files into manageable chunks based on silence detection, ideal for services with file or duration size limits

Noise reduction

Apply configurable noise reduction and dialogue enhancement to improve transcription accuracy

Multiple input formats

Supports streams, remote media file URLs, or local media file paths in any format supported by FFmpeg

API key rotation

Cycle through multiple Wit.ai API keys to prevent rate limits and enable higher concurrency

Smart concurrency

Control worker concurrency and resume failed jobs with built-in retry logic and exponential backoff

Rich error reporting

Failures capture failed chunks, successful transcripts, and working directory for easy debugging and resumption

How it works

The transcribe function provides an end-to-end transcription pipeline:
  1. Preprocess - Formats media, applies noise reduction and dialogue enhancement
  2. Split - Splits audio into chunks based on silence detection to avoid word breaks
  3. Transcribe - Sends chunks to Wit.ai API with smart key rotation and concurrency
  4. Merge - Combines results into typed segment objects with timestamps

Example output

[
  {
    "text": "Hello world",
    "start": 0,
    "end": 2.5,
    "confidence": 0.95,
    "tokens": [
      { "text": "Hello", "start": 0, "end": 1.2, "confidence": 0.98 },
      { "text": "world", "start": 1.3, "end": 2.5, "confidence": 0.92 }
    ]
  },
  {
    "text": "This is a test",
    "start": 2.7,
    "end": 4.2
  }
]

Next steps

Installation

Install Tafrigh using your preferred package manager

Quick start

Get your first transcription working in minutes

Guides

Learn advanced features like noise reduction and error handling

API reference

Explore the complete API documentation

Build docs developers (and LLMs) love