Skip to content

Add print_alignment function - #115

Merged
thequilo merged 6 commits into
mainfrom
print-alignment
Jun 17, 2025
Merged

Add print_alignment function#115
thequilo merged 6 commits into
mainfrom
print-alignment

Conversation

@thequilo

Copy link
Copy Markdown
Member

The print_alignment function prints a seglst-style alignment as produced by meeteval.wer.wer.time_constrained.align(..., style='seglst') in a human-readable format. This makes discussing alignments, such as in #113, easier.

import meeteval
alignment = meeteval.wer.wer.time_constrained.align(
   [
         {"words": "hi", "start_time": 0.93, "end_time": 2.03},
         {"words": "good how are you", "start_time": 3.15, "end_time": 5.36},
         {"words": "i'm leigh adams", "start_time": 7.24, "end_time": 8.36},
         {"words": "pretty good now and you", "start_time": 9.44, "end_time": 12.27},
         {"words": "yeah", "start_time": 15.49, "end_time": 16.95},
     ],
     [
         {"words": "hi", "start_time": 0.93, "end_time": 2.03},
         {"words": "are you", "start_time": 3.15, "end_time": 5.36},
         {"words": "leigh adams", "start_time": 7.24, "end_time": 8.36},
         {"words": "good now and", "start_time": 9.44, "end_time": 12.27},
         {"words": "yep", "start_time": 15.49, "end_time": 16.95},
     ], style='seglst'
)
meeteval.wer.wer.time_constrained.print_alignment(alignment)
 0.93  2.03     hi - hi     1.48  1.48
 3.15  3.83   good + are    3.70  3.70
 3.83  4.34    how + *
 4.34  4.85    are + you    4.81  4.81
 4.85  5.36    you + *
 7.24  7.50    i'm + *
 7.50  7.93  leigh - leigh  7.52  7.52
 7.93  8.36  adams - adams  8.08  8.08
 9.44 10.33 pretty + good  10.01 10.01
10.33 10.93   good + *
10.93 11.38    now - now   11.00 11.00
11.38 11.82    and + *
11.82 12.27    you + and   11.85 11.85
15.49 16.95   yeah + yep   16.22 16.22

@boeddeker

Copy link
Copy Markdown
Member

How about adding a sentence to the readme?
A pointer to this PR may also help. Alternatively, the example could be shown in the readme. If it is too long, it could be put in a details html tag.

@thequilo
thequilo merged commit eb63e9f into main Jun 17, 2025
@thequilo
thequilo deleted the print-alignment branch June 17, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants