Language model API
Public API for language-model construction.
Decoding needs a language model, so building one is part of the supported
surface rather than an internal detail. Callers should use these functions
instead of reaching into pstrain.lib.lm.
- pstrain.api.lm.build_lm(transcripts, output_path, max_order=3, smoothing='auto')[source]
Build an ARPA language model from transcripts using arpabo.
- Parameters:
- Returns:
Path to the created LM file
- Return type:
Note
“auto” mode uses optimized Katz backoff, which works well for typical speech corpus sizes. For very small corpora, “good_turing” may be better.
- pstrain.api.lm.build_lm_from_file(transcript_file, output_path, max_order=3, smoothing='auto')[source]
Build an ARPA LM from a supported transcription file.
- pstrain.api.lm.load_transcripts(transcript_file)[source]
Load transcripts from a supported transcription file.
Supports
utterance_id wordsand<s> words </s> (utterance_id).- Parameters:
transcript_file (Path) – Path to transcription file
- Returns:
Dict mapping utterance_id to transcript text
- Raises:
ValueError – If a nonempty line does not match a supported format
- Return type: