Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Bug fix for MontrealCorpusTools#459

* Update tests for new models
  • Loading branch information
mmcauliffe authored Jun 4, 2022
1 parent 3944163 commit 144e121
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions montreal_forced_aligner/textgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ def export_textgrid(
if include_utterance_text:
for u in data["utterances"]:
tg.tierDict[utterance_tier_name].entryList.append(u.to_tg_interval())
for tier in tg.tierDict.values():
if tier.entryList[-1][1] > tg.maxTimestamp:
tier.entryList[-1] = Interval(
tier.entryList[-1].start, tg.maxTimestamp, tier.entryList[-1].label
)
if has_data:
for tier in tg.tierDict.values():
if len(tier.entryList) > 0 and tier.entryList[-1][1] > tg.maxTimestamp:
tier.entryList[-1] = Interval(
tier.entryList[-1].start, tg.maxTimestamp, tier.entryList[-1].label
)
tg.save(output_path, includeBlankSpaces=True, format=output_format, reportingMode="error")
8 changes: 4 additions & 4 deletions tests/test_g2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ def test_scored_match(english_g2p_model, temp_dir):
g2p_model = G2PModel(english_g2p_model)
pron_scores = {
("read", "R IY1 D"): 12.3903465,
("read", "R EH1 D"): 12.2733212,
("read", "R EH1 D"): 3.03866529,
("theatres", "TH IY1 AH0 T ER0 Z"): 12.3603706,
("theatres", "DH IY1"): 39.7762604,
("the", "DH"): 11.7815981,
("the", "TH"): 12.3016987,
("the", "DH AH0"): 16.9708042,
("the", "DH IY1"): 16.2190933,
("the", "DH IY0"): 15.3279858,
("them", "DH EH0 M"): 14.7657909,
("them", "DH EH0 M"): 9.89364433,
("them", "DH AH0 M"): 11.9653378,
("them", "DH EY1"): 28.7747478,
("them", "DH EY1"): 25.8712311,
}
fst = pynini.Fst.read(g2p_model.fst_path)
for (word, pron), absolute_reference in pron_scores.items():
Expand All @@ -57,7 +57,7 @@ def test_scored_match(english_g2p_model, temp_dir):
input_token_type="utf8",
output_token_type=pynini.SymbolTable.read_text(g2p_model.sym_path),
)
assert absolute_score == absolute_reference
assert abs(absolute_score - absolute_reference) < 2


def test_training(basic_dict_path, basic_g2p_model_path, temp_dir):
Expand Down

0 comments on commit 144e121

Please sign in to comment.