Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preliminary-study-dai2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Transcribe-Educational-Videos
preliminary-study-dai2023
Compare revisions
f9d2e1256c1ca71eea563456e3b6a2f664a9a683 to b683843b813cfe2d83ea66b24e79f92ae5712e04
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
transcribe-educational-videos/preliminary-study-dai2023
Select target project
No results found
b683843b813cfe2d83ea66b24e79f92ae5712e04
Select Git revision
Branches
main
Swap
Target
transcribe-educational-videos/preliminary-study-dai2023
Select target project
transcribe-educational-videos/preliminary-study-dai2023
1 result
f9d2e1256c1ca71eea563456e3b6a2f664a9a683
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Updated the cli.py
· 510657e9
Ashwin Rao
authored
1 year ago
510657e9
Updated readme
· b683843b
Ashwin Rao
authored
1 year ago
b683843b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
code/jiwer/README.md
+2
-0
2 additions, 0 deletions
code/jiwer/README.md
code/jiwer/cli.py
+133
-1
133 additions, 1 deletion
code/jiwer/cli.py
code/jiwer/cli.py
+133
-1
133 additions, 1 deletion
code/jiwer/cli.py
with
268 additions
and
2 deletions
code/jiwer/README.md
View file @
b683843b
The cli.py is updated to print the hits, substitutions, deletions, and insertions.
Update the cli.py in the
<venv>
/lib/python3.10/site-packages/jiwer/cli.py
This diff is collapsed.
Click to expand it.
code/jiwer/cli.py
deleted
120000 → 0
View file @
f9d2e125
venv
/
lib
/
python3
.
10
/
site
-
packages
/
jiwer
/
cli
.
py
\ No newline at end of file
This diff is collapsed.
Click to expand it.
code/jiwer/cli.py
0 → 100644
View file @
b683843b
#
# JiWER - Jitsi Word Error Rate
#
# Copyright @ 2018 - present 8x8, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Provide a simple CLI wrapper for JiWER. The CLI does not support custom transforms.
"""
import
click
import
pathlib
import
jiwer
@click.command
()
@click.option
(
"
-r
"
,
"
--reference
"
,
"
reference_file
"
,
type
=
pathlib
.
Path
,
required
=
True
,
help
=
"
Path to new-line delimited text file of reference sentences.
"
,
)
@click.option
(
"
-h
"
,
"
--hypothesis
"
,
"
hypothesis_file
"
,
type
=
pathlib
.
Path
,
required
=
True
,
help
=
"
Path to new-line delimited text file of hypothesis sentences.
"
,
)
@click.option
(
"
--cer
"
,
"
-c
"
,
"
compute_cer
"
,
is_flag
=
True
,
default
=
False
,
help
=
"
Compute CER instead of WER.
"
,
)
@click.option
(
"
--align
"
,
"
-a
"
,
"
show_alignment
"
,
is_flag
=
True
,
default
=
False
,
help
=
"
Print alignment of each sentence.
"
,
)
@click.option
(
"
--global
"
,
"
-g
"
,
"
global_alignment
"
,
is_flag
=
True
,
default
=
False
,
help
=
"
Apply a global minimal alignment between reference and hypothesis sentences
"
"
before computing the WER.
"
,
)
def
cli
(
reference_file
:
pathlib
.
Path
,
hypothesis_file
:
pathlib
.
Path
,
compute_cer
:
bool
,
show_alignment
:
bool
,
global_alignment
:
bool
,
):
"""
JiWER is a python tool for computing the word-error-rate of ASR systems. To use
this CLI, store the reference and hypothesis sentences in a text file, where
each sentence is delimited by a new-line character.
The text files are expected to have an equal number of lines, unless the `-g` flag
is used. The `-g` flag joins computation of the WER by doing a global minimal
alignment.
"""
with
reference_file
.
open
(
"
r
"
)
as
f
:
reference_sentences
=
[
ln
.
strip
()
for
ln
in
f
.
readlines
()
if
len
(
ln
.
strip
())
>
1
]
with
hypothesis_file
.
open
(
"
r
"
)
as
f
:
hypothesis_sentences
=
[
ln
.
strip
()
for
ln
in
f
.
readlines
()
if
len
(
ln
.
strip
())
>
1
]
if
not
global_alignment
and
len
(
reference_sentences
)
!=
len
(
hypothesis_sentences
):
raise
ValueError
(
f
"
Number of sentences does not match.
"
f
"
{
reference_file
}
contains
{
len
(
reference_sentences
)
}
lines.
"
f
"
{
hypothesis_file
}
contains
{
len
(
hypothesis_sentences
)
}
lines.
"
)
if
global_alignment
and
compute_cer
:
raise
ValueError
(
"
--global and --cer are mutually exclusive.
"
)
if
compute_cer
:
out
=
jiwer
.
process_characters
(
reference_sentences
,
hypothesis_sentences
,
)
else
:
if
global_alignment
:
out
=
jiwer
.
process_words
(
reference_sentences
,
hypothesis_sentences
,
reference_transform
=
jiwer
.
wer_contiguous
,
hypothesis_transform
=
jiwer
.
wer_contiguous
,
)
else
:
out
=
jiwer
.
process_words
(
reference_sentences
,
hypothesis_sentences
)
if
show_alignment
:
print
(
jiwer
.
visualize_alignment
(
out
,
show_measures
=
True
))
else
:
if
compute_cer
:
print
(
out
.
cer
)
else
:
print
(
out
.
wer
,
out
.
wil
,
out
.
wip
,
out
.
mer
,
out
.
hits
,
out
.
substitutions
,
out
.
insertions
,
out
.
deletions
,
sep
=
'
,
'
)
if
__name__
==
"
__main__
"
:
cli
()
This diff is collapsed.
Click to expand it.