data_preprocessing.py 文件源码

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

项目:AVSR-Deep-Speech 作者: pandeydivesh15 项目源码 文件源码
def read_json_file(file_path):
    '''
    Args:
        1. file_path:   File path for a json file. 
                        File should be similar to the format -
                        https://gist.github.com/pandeydivesh15/2012ab10562cc85e796e1f57554aca33
    Returns:
        data:   A list of dicts. Each dict contains timing info for a spoken word(or punctuation).
    '''

    with open(file_path, 'r') as f:
        data = json.loads(f.read())['words']

        # for line in f:
        #   temp = json.loads(line)
        #   temp['start'] = None if temp['start'] == 'NA' else float(temp['start'])
        #   temp['end'] = None if temp['end'] == 'NA' else float(temp['end'])
        #   try:
        #       temp['word'] = temp['word'].encode('ascii')
        #   except KeyError:
        #       temp['punctuation'] = temp['punctuation'].encode('ascii')               
        #   data.append(temp)

    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号