Skip to main content

Convert audio recordings to text using faster-whisper with ModelScope

Project description

TingXie

Convert audio recordings to text using faster-whisper with ModelScope model downloads. No HuggingFace needed — models are fetched from ModelScope's China-based CDN.

What It Does

TingXie transcribes .wav, .mp3, .m4a, .flac, .ogg, .wma, .aac, .opus, and .webm files to text. It can process a single file or batch-transcribe an entire directory. Each file gets detected language, per-segment timestamps, and a plain-text transcript.

Models download automatically from ModelScope (iic/speech_whisper_* repos), not HuggingFace. Set TINGXIE_MODEL_DIR to override the cache directory (default: ~/.cache/tingxie/models).

What it does not do: streaming transcription, real-time microphone input, speaker diarization, or translation (transcription only).

Features

  • Single file or batch directory transcription
  • faster-whisper: 4x faster than openai-whisper, lower memory usage
  • ModelScope model downloads (no HuggingFace, no wall issues in China)
  • 15+ Whisper model variants: tiny, base, small, medium, large-v3, turbo, distil-*
  • CPU and CUDA inference with configurable compute type
  • Automatic language detection or manual language hint
  • Per-segment timestamps with verbose mode
  • JSON output for pipeline integration
  • OpenAI function-calling tools schema for agent integration

Requirements

  • Python >= 3.9
  • faster-whisper (installed automatically)
  • modelscope (installed automatically)
  • CTranslate2 (installed with faster-whisper)
  • FFmpeg (required by faster-whisper — brew install ffmpeg on macOS)

Installation

pip install -e .

For development dependencies:

pip install -e ".[dev]"

Quick Start

Transcribe a single file:

tingxie samples/20260610_125906.wav

Batch transcribe a directory:

tingxie samples/ -m base -l zh

Save transcripts to files:

tingxie samples/ -o output/

Force CPU inference:

tingxie recording.wav --device cpu

CLI Usage

tingxie [-V] [-v] [-q] [--json] [-m MODEL] [-l LANG] [-o PATH]
        [--device {auto,cpu,cuda}] [--compute-type TYPE] PATH
Flag Meaning
-V, --version Print version and exit
-v, --verbose Show per-segment timestamps
-q, --quiet Suppress non-essential output
--json Output as JSON
-m, --model Whisper model (default: turbo)
-l, --language Language hint, e.g. zh, en
-o, --output Output file or directory
--device Inference device: auto, cpu, cuda
--compute-type Quantization: default, int8, float16, float32

Available Models

tiny, tiny.en, base, base.en, small, small.en, medium, medium.en, large-v1, large-v2, large-v3, large, distil-large-v2, distil-large-v3, distil-medium.en, distil-small.en, turbo

Python API

from tingxie import transcribe, transcribe_dir

# Single file
result = transcribe(audio_path="samples/20260610_125906.wav", model="turbo")
print(result.success)        # True
print(result.data["text"])   # transcribed text
print(result.data["language"])  # detected language

# Force CPU with int8 quantization
result = transcribe(
    audio_path="recording.wav",
    device="cpu",
    compute_type="int8",
)

# Directory batch
result = transcribe_dir(
    directory="samples/",
    model="turbo",
    output="transcripts/",
)
for filename, info in result.data.items():
    print(f"{filename}: {info['text'][:50]}...")

Agent Integration

from tingxie.tools import TOOLS, dispatch

# Use TOOLS in your OpenAI function-calling setup
# Then dispatch results:
result = dispatch("tingxie_transcribe", {
    "audio_path": "recording.wav",
    "model": "turbo",
    "device": "cpu",
})

Model Cache

Models are stored at ~/.cache/tingxie/models/ by default. Override with:

export TINGXIE_MODEL_DIR=/custom/path
tingxie recording.wav

Limitations

  • Requires FFmpeg installed on the system
  • First run with a model downloads it from ModelScope (~1GB for turbo)
  • Not suitable for real-time streaming
  • No speaker diarization (cannot distinguish multiple speakers)
  • GPU recommended for models larger than small

Development

pip install -e ".[dev]"
ruff format . && ruff check . && mypy . && pytest

License

GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tingxie-0.2.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tingxie-0.2.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file tingxie-0.2.1.tar.gz.

File metadata

  • Download URL: tingxie-0.2.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for tingxie-0.2.1.tar.gz
Algorithm Hash digest
SHA256 738173d43593f8bf8ce345ae8ff4cc57989d1ab022753bbb8f62297db61a646f
MD5 a6b5df15b84e0cdca66c16547ce05a5b
BLAKE2b-256 3229127bf7cb18643da192069ed197aeb77dbe7c49612aa426fa1f4ef8eaf2d7

See more details on using hashes here.

File details

Details for the file tingxie-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tingxie-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for tingxie-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ccbad6cbceaed75b299e735666487edfdeb33318d6d805743a5c4f9f6cd1d33
MD5 28780739310bc8ff47f063bbe43216df
BLAKE2b-256 df8be18896448464c236e0dcacc7af1dd817b9758ea757cec38f23123dd4735e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page