Skip to content

Commit

Permalink
Print WER summary
Browse files Browse the repository at this point in the history
  • Loading branch information
thequilo committed Sep 17, 2024
1 parent 9d5125a commit 7511ca9
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions meeteval/wer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def _save_results(
hypothesis_paths: 'list[Path]',
per_reco_out: str,
average_out: str,
wer_name: str = 'WER',
):
"""Saves the results.
"""
Expand All @@ -130,6 +131,13 @@ def _save_results(
dataclasses.asdict(average),
average_out.format(parent=parent, stem=stem),
)
logging.info(
f'%{wer_name}: {average.error_rate:.2%} '
f'[ {average.errors} / {average.length}, '
f'{average.insertions} ins, '
f'{average.deletions} del, '
f'{average.substitutions} sub ]'
)
return average


Expand All @@ -156,7 +164,7 @@ def wer(
hypothesis = KeyedText.load(hypothesis)
from meeteval.wer.wer.siso import siso_word_error_rate_multifile
results = siso_word_error_rate_multifile(reference, hypothesis)
_save_results(results, hypothesis_paths, per_reco_out, average_out)
_save_results(results, hypothesis_paths, per_reco_out, average_out, wer_name='WER')


def orcwer(
Expand All @@ -178,7 +186,7 @@ def orcwer(
partial=partial,
normalizer=normalizer,
)
_save_results(results, hypothesis, per_reco_out, average_out)
_save_results(results, hypothesis, per_reco_out, average_out, wer_name='ORC-WER')


def greedy_orcwer(
Expand All @@ -202,7 +210,7 @@ def greedy_orcwer(
partial=partial,
normalizer=normalizer,
)
_save_results(results, hypothesis, per_reco_out, average_out)
_save_results(results, hypothesis, per_reco_out, average_out, wer_name='greedy ORC-WER')


def cpwer(
Expand All @@ -222,7 +230,7 @@ def cpwer(
reference_sort=reference_sort, hypothesis_sort=hypothesis_sort,
uem=uem, partial=partial, normalizer=normalizer,
)
_save_results(results, hypothesis, per_reco_out, average_out)
_save_results(results, hypothesis, per_reco_out, average_out, wer_name='cpWER')


def mimower(
Expand All @@ -242,7 +250,7 @@ def mimower(
reference_sort=reference_sort, hypothesis_sort=hypothesis_sort,
uem=uem, partial=partial, normalizer=normalizer,
)
_save_results(results, hypothesis, per_reco_out, average_out)
_save_results(results, hypothesis, per_reco_out, average_out, wer_name='MIMO-WER')


def tcpwer(
Expand All @@ -269,7 +277,7 @@ def tcpwer(
hypothesis_sort=hypothesis_sort,
uem=uem, normalizer=normalizer, partial=partial,
)
_save_results(results, hypothesis, per_reco_out, average_out)
_save_results(results, hypothesis, per_reco_out, average_out, wer_name='tcpWER')


def tcorcwer(
Expand Down Expand Up @@ -297,7 +305,7 @@ def tcorcwer(
uem=uem, partial=partial,
normalizer=normalizer,
)
_save_results(results, hypothesis, per_reco_out, average_out)
_save_results(results, hypothesis, per_reco_out, average_out, wer_name='tcORC-WER')


def greedy_tcorcwer(
Expand Down Expand Up @@ -325,8 +333,7 @@ def greedy_tcorcwer(
uem=uem, partial=partial,
normalizer=normalizer,
)
_save_results(results, hypothesis, per_reco_out, average_out)

_save_results(results, hypothesis, per_reco_out, average_out, wer_name='greedy-tcORC-WER')


def greedy_dicpwer(
Expand All @@ -348,7 +355,7 @@ def greedy_dicpwer(
partial=partial,
normalizer=normalizer,
)
_save_results(results, hypothesis, per_reco_out, average_out)
_save_results(results, hypothesis, per_reco_out, average_out, wer_name='greedy-DI-cpWER')


def _merge(
Expand Down

0 comments on commit 7511ca9

Please sign in to comment.