Add a stream_reset option to pocketsphinx_batch - #495
Open
lenzo-ka wants to merge 1 commit into
Open
Conversation
With noise removal enabled, batch results depend on control-file order: one shared decoder processes every entry, and the spectral-subtraction noise estimate persists across entries because ps_start_utt() does not reset it. Only ps_start_stream() resets it, and the batch tool never called it. Retention is correct when a control file addresses segments of one continuous recording, but batch entries are routinely independent recordings, and the tool offered no way to choose. The same audio file listed twice in one control file can report two different scores in a single run. The new stream_reset option (default no, preserving current behavior) calls ps_start_stream() before each control-file entry when noise removal is effectively enabled. test-batch-stream-reset.sh decodes a control file that lists the same recording twice, with other audio between, under -stream_reset yes, and asserts the repeated entries report identical hypothesis and score. It fails when the reset is not performed.
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.
With noise removal enabled,
pocketsphinx_batchresults depend on control-file order. One shared decoder processes every entry, and the spectral-subtraction noise estimate persists across entries:ps_start_utt()does not reset it, onlyps_start_stream()does, and the batch tool never called it. Retaining the estimate is correct when a control file addresses segments of one continuous recording; batch entries are, however, routinely independent recordings, and the tool offered no way to choose.Measured at v5.1.1 with the shipped en-us model (its
feat.paramsenables noise removal; the effective configuration was confirmed in the run log) and shipped test audio, all throughpocketsphinx_batchitself:Listing
goforward.rawtwice in one control file, with other audio between, reports two different scores for identical input in a single run:Reversing a three-entry control file changes every score:
Hypothesis strings did not change in these runs; the observed effect is score movement.
The new
stream_resetoption (defaultno, preserving current behavior) callsps_start_stream()before each control-file entry when noise removal is effectively enabled. With-stream_reset yes, both constructions above produce identical per-utterance output regardless of position or order (gof -7226, num -10545, som -6199 in both orders).The reset covers exactly the state
ps_start_stream()controls: the noise-removal statistics. It does not make sample dithering position-independent — with-dither yes, dithering draws from a process-wide random sequence whose position depends on preceding audio, so entries can still differ by a few counts even with the reset. The measurements above were made with the en-us configuration, in which dithering is off (the config default; the model'sfeat.paramsdoes not enable it).On the default: entries that name separate files carry an implicit independence claim, and order dependence violates it, so a case can be made for resetting by default in that mode, while control files that segment one continuous recording want retention. This patch keeps current behavior as the default and adds the choice; whether to flip the default is left to the maintainers.
The option is also listed in the pocketsphinx_batch manual page. The regression test
test-batch-stream-reset.shdecodes a control file that lists the same recording twice under-stream_reset yesand asserts the repeated entries report identical hypothesis and score. The script asserts the tool run's exit status and removes any stale output first; it fails when the reset is not performed, and it uses only fixtures already shipped in the repository.Fixes #498
Tested on macOS (Apple clang) and Linux x86-64 (GCC 13.3); full unit and regression suite passes on both.