lab-rs
Toolkit and library for reading, writing, and manipulating HTK .lab label files
.lab files are plain-text label files used by HTK and throughout speech and singing-voice tooling for phoneme/word alignments. Each line is a labelled time segment, with times in units of 100 nanoseconds:
0 2500000 sil
2500000 4200000 hh
4200000 6100000 eh
6100000 7800000 l
7800000 9200000 ow
9200000 12000000 sil
The parser handles the common subset of the HTK label format tolerantly: start and end times are optional, an optional numeric score may follow the label text, and blank lines and extra whitespace are ignored.
I tried my best not to make my code look AI-generated since that's apparently something you need to worry about nowadays. Excuse the potential lack of comments and documentation outside this README and docs.rs. And yes, I am bitter about this.
Library
The library has no dependencies by default. Enable the serde feature for Serialize/Deserialize on all types.
use LabFile;
LabFile dereferences to Vec<Label>, so the usual vector and slice methods work directly. It also provides helpers for looking up labels by time, shifting and scaling timestamps, merging adjacent labels, and validating a label sequence. See the documentation for the full interface.
CLI
This installs a lab binary that lets you do things like:
License
MIT, see LICENSE.