speechbrain.k2_integration.utils 模块
用于k2与SpeechBrain集成的实用工具。
此代码是从 icefall (https://github.com/k2-fsa/icefall) 调整而来。
- Authors:
皮埃尔·冠军 2023
赵泽宇 2023
乔治奥斯·卡拉卡西迪斯 2023
摘要
函数:
从最佳路径的FSA中提取文本(作为单词ID)。 |
|
将最佳路径转换为字符串列表。 |
|
加载一个用于解码图创建(或语言模型重评分)的语言模型。 |
|
准备一个语言模型,目的是用于语言模型重评分。 |
参考
- speechbrain.k2_integration.utils.lattice_path_to_textid(best_paths: k2.Fsa, return_ragged: bool = False) List[List[int]] | k2.RaggedTensor[source]
从最佳路径的FSA中提取文本(作为单词ID)。
- Parameters:
best_paths (k2.Fsa) – 一个包含最佳路径的k2.Fsa,其中best_paths.arcs.num_axes() == 3,即包含多个FSA,这预期是k2.shortest_path的结果(否则返回的值将没有意义)。
return_ragged (bool) – 如果为True,则返回一个具有两个轴的稀疏张量 [utt][word_id]。 如果为False,则返回一个列表的列表形式的单词ID。
- Returns:
返回一个包含整数列表的列表,其中包含我们解码的标签序列。
解码。
- speechbrain.k2_integration.utils.lattice_paths_to_text(best_paths: k2.Fsa, word_table) List[str][source]
将最佳路径转换为字符串列表。
- speechbrain.k2_integration.utils.load_G(path: str | Path, cache: bool = True) k2.Fsa[source]
加载一个语言模型用于解码图的创建(或语言模型重评分)。
- speechbrain.k2_integration.utils.prepare_rescoring_G(G: k2.Fsa) k2.Fsa[source]
准备一个LM,目的是将其用于LM重评分。 例如,在librispeech配方中,这是一个4-gram LM(而一个3gram LM用于HLG构建)。
- Parameters:
G (k2.Fsa) – 一个表示语言模型的FSA。
- Returns:
G – 一个表示语言模型(LM)的FSA,具有以下修改: - G.aux_labels 被移除 - G.lm_scores 被设置为 G.scores - G 是弧排序的
- Return type:
k2.Fsa