fixed an item-lost bug when exporting to textgrid #814
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.
There is a item-lost bug in the previous version, which will make every file to lose its first phone and word item in the exported textgrid file.
Problem
In function
construct_textgrid_output
of filetextgrid.py
, thewhile True
loop ends with this:Montreal-Forced-Aligner/montreal_forced_aligner/textgrid.py
Lines 420 to 422 in 76c46a1
These codes empty the three lists, while they are not empty because of these lines:
Montreal-Forced-Aligner/montreal_forced_aligner/textgrid.py
Line 377 in 76c46a1
Montreal-Forced-Aligner/montreal_forced_aligner/textgrid.py
Line 393 in 76c46a1
Montreal-Forced-Aligner/montreal_forced_aligner/textgrid.py
Line 406 in 76c46a1
Emptying them at the ending of a loop will cause a direct data discard.
Solution
I removed the three lines first, and to avoid the loop becomes an infinite loop, in this
if
block:Montreal-Forced-Aligner/montreal_forced_aligner/textgrid.py
Lines 383 to 387 in 76c46a1
I added a:
phone_data = []
These codes were tested and worked well now.