Repository navigation
2pass: keep the phrase line, and label the gaps - #7
Merged
Merged
Conversation
Three problems in the align -> breathe --merge -> align --textgrid chain: 1. The phrase line was lost. `breathe --merge` wrote only phones + breath, discarding texts/words, and the second pass reads only phones -- so a re-alignment had nothing to rebuild the phrase from. The merge now carries texts/words through, and the second pass re-attaches that grouping to the new spans: each token is mapped back to the text/word that contained it, which is exactly what build_alignment_tiers() aggregates by, so the tiers come out with the original words and the *new* boundaries. 2. Stretches no token covered stayed empty. A Praat tier has to run continuously, and a dataset annotation should not leave a stretch without a label, so TextGridTier gains a per-tier `gap_label` and align/breathe fill the phones tier with it -- `--fill-gaps LABEL`, default SP, empty to keep the upstream "unlabelled" behaviour. texts/words are unaffected. 3. Confirmed the mechanism before designing it: SP is a stop symbol and is dropped by encode_phones(), so an SP inserted before the second pass cannot survive it; AP/EP/GS are global symbols and do. Filling therefore happens at serialisation, after alignment, and is a labelling step -- not a token inserted into the model. A gap that is silence is SP, and SP costs the alignment nothing. Verified on hanser_0_0: the first pass writes 12 phones + 7 SP-filled gaps, the merge keeps all four tiers, and the second pass returns the six words (今天我们唱歌) re-timed to the new alignment with 14 tokens (12 phones + 2 AP) and 8 SP-filled gaps -- no unlabelled interval anywhere. Test suite 30/30.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Fixes the three problems reported in the 2PASS chain.
1. The phrase line was lost
breathe --mergewrote onlyphones+breath, so the first pass'stexts/wordswere gone before the second pass even ran — and the second pass reads only the
phones tier, so nothing could rebuild them. Two changes:
texts/wordsthrough into the merged TextGrid;align --textgridre-attaches that grouping to the new spans. Each token ismapped back to the text/word interval that contained it (by time, in the input
TextGrid), and the tier builder aggregates by exactly that owner id — so the
tiers come out with the original words and the new boundaries.
The mapping has to skip the empty intervals the writer pads every tier with, and
has to skip the stop symbols the aligner drops; when the shapes still disagree it
declines to guess and leaves the tiers as before.
2. Stretches no token covered stayed empty
TextGridTiergains a per-tiergap_label.alignandbreathe --mergefillthe phones tier with it —
--fill-gaps LABEL, defaultSP, empty string tokeep the upstream "unlabelled" behaviour.
texts/wordsare untouched (theystill pad with empty labels, which is what upstream's textgrid package does).
3. The mechanism, confirmed before designing the fix
SPis a stop symbol:encode_phones()drops it, so an SP inserted beforethe second pass cannot survive it.
AP/EP/GSare global symbols and dosurvive. Filling therefore belongs at serialisation, after alignment — it is a
labelling step, not a token pushed into the model. A gap that is silence is SP,
and SP costs the alignment nothing.
Evidence
hanser_0_0.wav, three steps:Test suite 30/30 (a new
TextGrid.GapLabelIsPerTierAndDefaultsToEmptycovers theper-tier fill).
Note
The first pass also fills its gaps with SP now, since the flag defaults to SP for
both commands. That is what makes the final annotation gap-free; pass
--fill-gaps ""to keep the old behaviour.