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
data_preprocessing.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录