master 分支要求 Python 3.11 或更高,稳定版要求需查 PyPI;视频读取需额外安装 torchcodec 并依赖兼容的 FFmpeg;压缩特征、索引 gzip、WebDataset 等能力需另装对应 extras
lhotse
lhotse-speechApache-2.0活跃维护面向语音与多模态机器学习的 Python 数据处理库,提供统一的音频加载、切分、特征提取和数据集管理接口,方便搭建语音识别等训练流水线。
Tools for handling multimodal data in machine learning projects.
python -m pip install lhotseREADME 未说明显存或 GPU 要求;PyTorch 为必需依赖,torchaudio 与 TorchCodec 0.10+ 为可选音频后端,TorchCodec 读视频还需受支持的 FFmpeg 版本
Lhotse 是准备多模态数据集并构建可扩展 PyTorch 数据管道的 Python 库
面向语音与多模态机器学习的 Python 数据处理库,提供统一的音频加载、切分、特征提取和数据集管理接口,方便搭建语音识别等训练流水线。
核心能力
- 用 manifest 描述音频、视频、图像和文本数据
- 惰性流式读取 JSONL manifest 并组合过滤与混洗
- 加载时对 cut 做截断、填充、混合与增强
- 按时长动态分批以减少 padding 并支持分布式切分
- 用 Shar 分片存储并支持索引与断点续训的数据加载
容易踩的坑
- v1.33.0v1.33.0 - Himalayan Vulture最新正式版2026-04-20 · 2026-04-20 13:11 UTC
Dependencies
- Make
lilcomoptional and fix failing unit tests on MacOS by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1555 - Add optional torchcodec support by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1562
Recipes
- Notsofar ihm recipe by @Lakoc in https://github.com/lhotse-speech/lhotse/pull/1551
- Add oto_speech dataset recipe by @Lakoc in https://github.com/lhotse-speech/lhotse/pull/1552
- Fix cached manifest reading in some recipes by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1560
New features
- Support loading multiple non-overlapping custom recordings in
MixedCutby @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1553 - Respect
LHOTSE_IO_BACKENDfor readingAudioSource(type='url'); update docs by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1557 - Add
AudioSamples(mono_downmix=True)to handle mixed single/multi channel batches gracefully by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1563 - Chunking functionality by @nune-tadevosyan in https://github.com/lhotse-speech/lhotse/pull/1556
- Add
CutSet.mix(..., tag="noise"),MixTrack.{is_snr_reference,mute}bools, andMixedCut.unmix(tag=...)by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1559
Fixes
- Fix cuts conversion to hf datasets by @mohsen-goodarzi in https://github.com/lhotse-speech/lhotse/pull/1546
- Fix invalid escape sequence warnings in iwslt22_ta by @yfyeung in https://github.com/lhotse-speech/lhotse/pull/1540
- extend SimpleCutSampler to work better with CutConcatenate by @KarelVesely84 in https://github.com/lhotse-speech/lhotse/pull/1520
- refactor(ais): Add backward compatibility and improve error handling in AISBatchLoader by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1542
- Remove hardcoded timeout from AIStore client by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1549
- Fix for AIStore client 1.23 by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1565
- fix: handle truncated batch stream with sequential GET fallback by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1566
- fix: skip zero-duration supervisions in index_supervisions() by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1567
- fix numpy broadcast dtype issue in loudness normalization by @tnq177 in https://github.com/lhotse-speech/lhotse/pull/1561
New Contributors
- @nune-tadevosyan made their first contribution in https://github.com/lhotse-speech/lhotse/pull/1556
- @tnq177 made their first contribution in https://github.com/lhotse-speech/lhotse/pull/1561
Full Changelog: https://github.com/lhotse-speech/lhotse/compare/v1.32.2...v1.33.0
- Make
- v1.32.2v1.32.2 - Blood Pheasant2026-01-14 · 2026-01-14 15:09 UTC
查看更新说明
What's Changed
- NSF grant acknowledgment in README.md by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1539
- Fix CutSampler initialization for newer PyTorch versions by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1543
Full Changelog: https://github.com/lhotse-speech/lhotse/compare/v1.32.1...v1.32.2
- v1.32.1v1.32.1 - Blood Pheasant2025-11-24 · 2025-11-24 16:43 UTC
查看更新说明
Fix issue with importing Lhotse v1.32.0 on Windows.
Full Changelog: https://github.com/lhotse-speech/lhotse/compare/v1.32.0...v1.32.1
- v1.32.0v1.32.0 - Blood Pheasant2025-11-21 · 2025-11-21 20:04 UTC
查看更新说明
Recipes
- Add recipe for NOTSOFAR-1 by @domklement in https://github.com/lhotse-speech/lhotse/pull/1517
- Add LibriMix full and WHAM noise preparation recipes by @Lakoc in https://github.com/lhotse-speech/lhotse/pull/1518
- LibriSpeechMix recipe addition. by @Lakoc in https://github.com/lhotse-speech/lhotse/pull/1521
- Restore punctuation in AMI recipe by @Lakoc in https://github.com/lhotse-speech/lhotse/pull/1519
- Add chime6 download by @domklement in https://github.com/lhotse-speech/lhotse/pull/1526
- Grid recipe fix by @ialmajai in https://github.com/lhotse-speech/lhotse/pull/1502
New features
- Add new augmentation: codec compression (GSM, Opus, Vorbis, MP3) by @racoiaws in https://github.com/lhotse-speech/lhotse/pull/1510
- Add new augmentation: lowpass using back-and-forth resampling via libsox by @racoiaws in https://github.com/lhotse-speech/lhotse/pull/1511
- Support cut.load_custom_video() and collate_video(..., recording_field='custom_video') by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1525
- Add AISBatchLoader for efficient batch data loading from AIStore by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1529
- Add AIStore batch loading support in AudioSamples class by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1534
Fixes and enhancements
- Fix Windows test failure in test/test_utils.py caused by NamedTemporaryFile by @denini08 in https://github.com/lhotse-speech/lhotse/pull/1504
- fix: resolve AttributeError in DynamicBucketer by @somniumism in https://github.com/lhotse-speech/lhotse/pull/1523
- fix: Add Image support to Cut.iter_data() method by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1530
- Add unit tests for AISBatchLoader and fix manifest tracking by @gaikwadabhishek in https://github.com/lhotse-speech/lhotse/pull/1531
- avoid bug appearing with OnTheFlyFeatures and PerturbVolume cut_transform by @KarelVesely84 in https://github.com/lhotse-speech/lhotse/pull/1527
New Contributors
- @ialmajai made their first contribution in https://github.com/lhotse-speech/lhotse/pull/1502
- @denini08 made their first contribution in https://github.com/lhotse-speech/lhotse/pull/1504
- @Lakoc made their first contribution in https://github.com/lhotse-speech/lhotse/pull/1519
- @somniumism made their first contribution in https://github.com/lhotse-speech/lhotse/pull/1523
Full Changelog: https://github.com/lhotse-speech/lhotse/compare/1.31.0...v1.32.0
- 1.31.0v1.31.1 - Expedition 332025-09-18 · 2025-09-18 21:42 UTC
查看更新说明
(skipping 1.31.0 because I accidentally uploaded and deleted this version in the past in PyPI, and can't re-use it now)
New recipes
- Add GigaSpeech 2 recipe by @yfyeung in https://github.com/lhotse-speech/lhotse/pull/1506
New features
- Prioritize torchaudio FFMPEG backend for video data by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1482
- Add image loading capabilities via Pillow by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1483
- Add new augmentation: soft/hard clipping by @racoiaws in https://github.com/lhotse-speech/lhotse/pull/1512
- Randomized shard slicing for Lhotse Shar by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1505
Fixes and enhancements
- minor fix: remove execute permission for all recipes by @yfyeung in https://github.com/lhotse-speech/lhotse/pull/1485
- Refactor IO to support both files and URLs for Features, Array, and Image by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1486
- update edacc download link by @teowenshen in https://github.com/lhotse-speech/lhotse/pull/1495
- allow reading kaldi
textfile with utterances having empty references by @KarelVesely84 in https://github.com/lhotse-speech/lhotse/pull/1496 - Support accessing MixedCut.custom by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1499
- Support not slicing custom recordings by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1494
- Support left padding in
supervision_intervalsandsupervision_masksby @yfyeung in https://github.com/lhotse-speech/lhotse/pull/1492 - fix cannot join current thread when drop_last=True by @hoangtran9122 in https://github.com/lhotse-speech/lhotse/pull/1487
- Allow up to half a second of duration mismatch between audio and manifest by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1513
- Allow random reads of files from inside of tar files by @pzelasko in https://github.com/lhotse-speech/lhotse/pull/1514
New Contributors
- @hoangtran9122 made their first contribution in https://github.com/lhotse-speech/lhotse/pull/1487
Full Changelog: https://github.com/lhotse-speech/lhotse/compare/v1.30.3...1.31.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Lhotse
Lhotse is a Python library for preparing multimodal datasets and building scalable PyTorch data pipelines. It provides manifests for audio, video, images, and text, on-the-fly augmentation, dynamic batching, efficient sharded storage, and indexed, resumable dataloading.
Documentation · Quick start · Tutorials · Contributing · Citation
Installation
Install the latest stable release from PyPI:
python -m pip install lhotse
This README and the latest documentation describe the development version on
master, which requires Python 3.11 or later. Some APIs and extras described
below may not yet be available in the stable release. The Python badge above
lists the versions tested on master; check PyPI for the stable release's requirements.
To use the development version:
python -m pip install git+https://github.com/lhotse-speech/lhotse
PyTorch is required; torchaudio and TorchCodec 0.10 or later are optional audio
backends. TorchCodec also reads video (python -m pip install torchcodec) and
requires an FFmpeg version that it supports.
See optional dependencies for additional formats and
integrations.
Quick start
Download the small public YesNo corpus, prepare its training split, and load a batch of audio and transcripts. This example uses waveforms directly, so it does not need precomputed features or worker processes.
from pathlib import Path
from torch.utils.data import DataLoader
from lhotse import CutSet
from lhotse.dataset import (
AudioSamples,
DynamicCutSampler,
K2SpeechRecognitionDataset,
)
from lhotse.recipes import download_yesno, prepare_yesno
corpus_dir = download_yesno(target_dir=Path("data"))
manifests = prepare_yesno(corpus_dir=corpus_dir)["train"]
cuts = CutSet.from_manifests(
recordings=manifests["recordings"],
supervisions=manifests["supervisions"],
output_path=Path("data") / "cuts.jsonl.gz",
lazy=True,
)
dataset = K2SpeechRecognitionDataset(input_strategy=AudioSamples())
sampler = DynamicCutSampler(cuts, max_duration=60, shuffle=False)
dataloader = DataLoader(dataset, sampler=sampler, batch_size=None)
batch = next(iter(dataloader))
print(batch["inputs"].shape) # Padded waveforms: (batch, samples).
print(batch["supervisions"]["text"])
The cuts are saved as a JSONL manifest and opened lazily, without loading their
audio into memory. DynamicCutSampler streams the cuts into batches with at most
60 seconds of audio, and the dataset loads and pads their waveforms when requested.
Despite its name, K2SpeechRecognitionDataset does not require k2.
Key features
- Multimodal manifests: represent recordings, supervision segments, images, and audio/video cuts in human-readable manifests with Python and CLI APIs.
- Lazy processing: stream large JSONL manifests and compose filtering, mapping, shuffling, and dataset blending without loading everything into memory.
- On-the-fly transforms: truncate, pad, mix, and augment cuts while adjusting their supervision timing; compute features during loading or store them in advance.
- Dynamic batching: group examples by duration and use dynamic bucketing to reduce padding. Partition data across distributed ranks and dataloader workers to avoid overlapping samples.
- Efficient storage: use Lhotse Shar for modular, sharded sequential I/O from local or remote storage.
- Indexed and resumable dataloading: index JSONL and Shar data, pack shard
indexes into
.idxpackcatalogs, and checkpoint supported iterator pipelines. See indexed manifests for the requirements for exact restore, including gzip indexes and worker state. - Corpus recipes: prepare standard manifests for commonly used datasets.
Tutorials
The notebooks in examples
cover the following workflows. Open them on GitHub to read them or in Colab to run
them; installation and data requirements are described in each notebook.
| Tutorial | Run |
|---|---|
| Basic Lhotse workflow | Colab |
| Transforming data with cuts | Colab |
| WebDataset integration | Colab |
| Combining multiple datasets | Colab |
| Lhotse Shar: modular data format | Colab |
| Image and video loading | Colab |
| AIStore batch loading (requires an AIStore endpoint) | Colab |
Resumable, indexed dataloading (torchdata for the optional multi-worker example) | Colab |
The video notebook reads video frames and audio tracks with TorchCodec 0.10 or later, which also requires FFmpeg. The AIStore notebook uses 100 training and 20 development recordings and creates and removes its own temporary bucket.
Tutorial presentations and materials
These conference materials provide additional background and may use older APIs:
- Interspeech 2023: tutorial notebook and slides (Microsoft sign-in required).
- Interspeech 2021: recorded lecture (3 hours).
Examples of use
- Icefall: speech recognition recipes combining Lhotse data pipelines with k2.
- NVIDIA NeMo: Lhotse dataloading with dynamic batching, dataset mixing, and Shar support.
- ESPnet example: a minimal integration notebook (Google sign-in may be required).
Lhotse shares its roots with Kaldi and supports importing and exporting Kaldi data.
Main ideas
RecordingSet describes recordings, SupervisionSet describes annotations such
as transcripts and speakers, and CutSet combines them into examples that can be
reshaped for training. Manifests store metadata and references to the underlying
data; audio transforms are applied when the data is loaded.

Cuts support mixing, truncation, padding, and augmentation. Feature extraction can run on the fly or ahead of training, with optional compressed storage. Lhotse also supports mixing features directly.

Optional dependencies
Install only the extras needed for your workflow. These extras describe master;
when using development-only features, include the extras in the source install:
python -m pip install 'lhotse[checkpoint,gzip] @ git+https://github.com/lhotse-speech/lhotse'
For a published extra, use a quoted requirement such as
python -m pip install "lhotse[lilcom]".
| Extra | Enables |
|---|---|
checkpoint | torchdata.stateful_dataloader.StatefulDataLoader for multi-worker checkpointing. |
gzip | Indexed gzip JSONL with indexed_gzip; keep both .idx and .gzidx sidecars. |
lilcom | Compressed features and arrays; lilcom_chunky is the preferred compressed feature backend. |
orjson | Faster JSONL serialization and reading. |
webdataset | WebDataset import/export. |
pillow | Image loading with Pillow. |
aistore | AIStore I/O and batch loading; configure AIS_ENDPOINT. |
kaldi | Kaldi I/O and feature extraction via kaldi-native-io and kaldifeat. |
h5py | HDF5 feature storage. |
dill | Serialization of lazy transforms such as lambdas across processes. Also set LHOTSE_DILL_ENABLED=1 or call lhotse.set_dill_enabled(True). |
Additional audio backends, remote storage clients, feature extractors, and SPHERE support are covered in the installation reference.
Environment variables
See the configuration reference
for audio and I/O backend selection, timing tolerances, remote storage settings,
and serialization options. Dill is disabled by default even when installed;
enabling it can help with lazy transforms in a PyTorch DataLoader with
num_workers > 0.
Development installation
Clone the repository, then install the locked development environment with uv:
git clone https://github.com/lhotse-speech/lhotse
cd lhotse
uv sync --locked
uv run --locked pre-commit install
See the contributor guide for the required uv version, system dependencies, tests, formatting, documentation builds, CPU/CUDA environments, dependency updates, and releases.
Citation
If you use Lhotse in research, please cite
Lhotse: a speech data representation library for the modern deep learning ecosystem
(NeurIPS Data-Centric AI Workshop, 2021). Citation metadata is available in
CITATION.cff.
Acknowledgment
Some contributions to this project were supported by National Science Foundation CCRI award 2120435.