ASR成绩单的大概有效期
jiwer的Python项目详细描述
自动语音识别的字错误率
这个存储库包含一个简单的Python包来近似抄本的WER。它计算最小编辑距离 一个语音到文本的api,介于基本真句和假设句之间。计算最小编辑距离 使用 Wagner-Fisher 算法。由于该算法计算字符级的最小编辑距离,因此句子中的每个单词都被赋予一个 唯一整数,编辑距离通过一个整数字符串计算。
安装
您应该可以使用pip:
$ pip install jiwer
用法
最简单的用例是计算两个字符串之间的编辑距离:
fromjiwerimportwerground_truth="hello world"hypothesis="hello duck"error=wer(ground_truth,hypothesis)
您还可以计算多个句子的wer:
fromjiwerimportwerground_truth=["hello world","i like monthy python"]hypothesis=["hello duck","i like python"]error=wer(ground_truth,hypothesis)
当基本真理句和假设句的数量不同时,对合并的句子进行最小对齐:
ground_truth=["hello world","i like monthy python","what do you mean, african or european swallow?"]hypothesis=["hello","i like","python","what you mean swallow"]# is equivelent toground_truth="hello world i like monhty python what do you mean african or european swallow"hypothesis="hello i like python what you mean swallow"
附加预处理
可以对输入进行一些额外的预处理。默认情况下,空格被删除,所有内容都设置为小写,
.
和,
被删除,从[]
到<>
(对于kaldi模型来说很常见)之间的所有内容都被删除,每个单词都由
被一个或多个空间分割。此外,如果
standardize=True
是沿着wer
方法传递的。
fromjiwerimportwerground_truth="he's my neminis"hypothesis="he is my <unk> [laughter]"wer(ground_truth,hypothesis,standardize=True)# is equivelent to ground_truth="he is my neminis"hypothesis="he is my"wer(ground_truth,hypothesis)
此外,还有一个选项提供一个单词列表,从 抄写,如“yhe”或“so”。
fromjiwerimportwerground_truth="yhe about that bug"hypothesis="yeah about that bug"wer(ground_truth,hypothesis,words_to_filter=["yhe","yeah"])# is equivelent to ground_truth="about that bug"hypothesis="about that bug"wer(ground_truth,hypothesis)