Conversation
… FSG Register align_beam, align_pbeam, align_wbeam (defaults 1e-48) and align_use_main_beams (default no). fsg_search_init uses them for the _align search only; other FSG and LVCSR paths unchanged. Document CLI flags in usage_align.
Describe align_* vs main beams and align_use_main_beams in API header, README, man page, and Python set_align_text.
Verify _align FSG uses align_* under asymmetric wbeam and main beams when align_use_main_beams is enabled.
When global bestpath is enabled, fsg_search_hyp() can return the lattice bestpath string, which may be shorter than the forced transcript. The align CLI already turns bestpath off; Decoder() does not. Force fsgs->bestpath false for _align so ps_get_hyp matches the full path and cython/test/alignment_test.py::test_default_lm passes.
dhdaines
reviewed
Apr 15, 2026
Contributor
dhdaines
left a comment
There was a problem hiding this comment.
I think this is good - I presume the reason for this is so that you can use the same ps_decoder_t for both recognition and alignment?
Or is it just to get better defaults in alignment mode? In this case, I still think it's fine, though another option would simply be to ignore -pbeam and -wbeam when aligning. This might not be as obvious to the user, though. What do you think?
| segmentation in the usual manner. For phone-level alignment, | ||
| see `set_alignment` and `get_alignment`. | ||
|
|
||
| Pruning for this pass uses ``align_beam``, ``align_pbeam``, and |
Contributor
There was a problem hiding this comment.
Should these be single or double backquotes?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds separate configuration for forced-alignment FSG (
ps_set_align_text, CLIalign) so pruning does not use the samebeam/pbeam/wbeamtriple as LVCSR. Default alignment beams (align_beam,align_pbeam,align_wbeam, all1e-48) avoid the fragile interaction where stockwbeamdiffered frombeam. Addsalign_use_main_beamsto opt back into the main decoder beams when comparing behavior or debugging.Motivation
Forced alignment uses a linear FSG (
_align). Asymmetric word vs frame beams in the global defaults could produce empty or broken word segments andfsg_searcherrors (“Final result does not match the grammar”) even when audio, transcript, and lexicon match. Alignment-specific parameters keep LVCSR defaults unchanged while giving alignment a sensible, documentable default.Changes
src/config_macro.h:align_beam,align_pbeam,align_wbeam(float);align_use_main_beams(bool, defaultno). Wired intoPOCKETSPHINX_OPTIONS.src/fsg_search.c: For the_alignsearch only, readalign_*unlessalign_use_main_beamsis set; other FSG searches unchanged.include/pocketsphinx/search.h, README align subsection,doxygen/pocketsphinx.1(.in),cython/_pocketsphinx.pyx(set_align_text),usage_aligninpocketsphinx_main.c.test/unit/test_align_fsg_beam.c+CMakeLists.txtentry (asserts_alignFSG usesalign_*under asymmetricwbeam, and main beams whenalign_use_main_beamsis on).Follow-up in the same change set: For the
_alignFSG only,bestpathis forced off (fsgs->bestpath = FALSE) after the usual config read. When globalbestpathis yes, FSGhyp()otherwise uses the lattice bestpath string, which can be shorter than the forced transcript; the CLIaligncommand already disablesbestpathfor the whole run, but the PythonDecoder()does not, socython/test/alignment_test.py::TestAlignment::test_default_lmfailed in CI. Aligning FSG behavior with the CLI fixes that without requiring tests to tweak config.How to review
fsg_search_initbranch:_align+ notalign_use_main_beams→align_*; else →beam/pbeam/wbeam(same as before for non-align FSG).align_use_main_beams.cmake --build build --target test_align_fsg_beam(or fullcheck).Testing
cmake --build <build> --target check(or CI)test_align_fsg_beampassesFollow-ups (not in this PR)
align_*in GStreamer props if maintainers want parity there.