Testing API
Public API for model testing and evaluation operations.
- pstrain.api.testing.create_report(result, title=None, corpus_name='', test_set_name='')[source]
Create a test report from a TestResult.
- pstrain.api.testing.load_transcripts(transcript_file)[source]
Load transcripts from a Sphinx-format transcription file.
Format: <s> word word word </s> (utterance_id)
- pstrain.api.testing.test_model(model_dir, test_audio_dir, test_transcripts, dict_file, filler_dict=None, lm=None, verbose=False, compute_cer=False, jobs=None)[source]
Test an acoustic model and calculate all WER metrics.
- Parameters:
model_dir (Path) – Path to acoustic model directory
test_audio_dir (Path) – Directory containing test audio files
test_transcripts (dict[str, str]) – Dict mapping utterance_id to reference transcript
dict_file (Path) – Path to pronunciation dictionary
filler_dict (Path | None) – Optional filler dictionary
lm (Path | None) – Optional language model (ARPA format)
verbose (bool) – Store per-utterance results
compute_cer (bool) – Also compute Character Error Rate
jobs (int | None) – Decoder worker processes. None auto-selects up to 12.
- Returns:
TestResult with all jiwer metrics
- Raises:
ImportError – If PocketSphinx not available
RuntimeError – If testing fails
- Return type:
TestResult