decoder.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:deepspeech.pytorch 作者: SeanNaren 项目源码 文件源码
def process_string(self, sequence, size, remove_repetitions=False):
        string = ''
        offsets = []
        for i in range(size):
            char = self.int_to_char[sequence[i]]
            if char != self.int_to_char[self.blank_index]:
                # if this char is a repetition and remove_repetitions=true, then skip
                if remove_repetitions and i != 0 and char == self.int_to_char[sequence[i - 1]]:
                    pass
                elif char == self.labels[self.space_index]:
                    string += ' '
                    offsets.append(i)
                else:
                    string = string + char
                    offsets.append(i)
        return string, torch.IntTensor(offsets)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号