paddlespeech.s2t.utils.text_grid 模块

paddlespeech.s2t.utils.text_grid.align_to_tierformat(align_segs: List[List[int]], subsample: int, token_dict: Dict[int, str], blank_id=0) List[str][来源]

从对齐分割生成 textgrid.Interval 格式。

Args:

align_segs (List[List[int]]): 分段的 ctc 对齐 IDs。
subsample (int): 25ms 帧长度, 10ms 步长, 1/subsample
token_dict (Dict[int, Text]): int -> str 映射。

Returns:

List[Text]: 文本网格.Interval 文本的列表,str(开始, 结束, 文本)。

paddlespeech.s2t.utils.text_grid.generate_textgrid(maxtime: float, intervals: List[str], output: str, name: str = 'ali') None[来源]

创建对齐文本网格文件。

Args:

maxtime (float): 音频持续时间。
intervals (List[Text]): ctc 输出对齐。例如 "开始时间 结束时间 单词" 每项。
output (Text): textgrid 文件路径。
name (Text, optional): 层或层名称。默认为 'ali'。

paddlespeech.s2t.utils.text_grid.segment_alignment(alignment: List[int], blank_id=0) List[List[int]][来源]

通过连续的空白和重复标签进行分段 ctc 对齐 ID。

Args:
alignment (List[int]): ctc alignment id sequence.

例如 [0, 0, 0, 1, 1, 1, 2, 0, 0, 3]

blank_id (int, optional): 空白ID。默认为0。

Returns:
List[List[int]]: token align, segment aligment id sequence.

例如 [[0, 0, 0, 1, 1, 1], [2], [0, 0, 3]]