insertEvalSetFromFile.py 文件源码

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

项目:Eyra 作者: Eyra-is 项目源码 文件源码
def run():
    with open('test_set.txt', 'r') as f:
        try:
            cur = _db.cursor()

            j = 1
            for line in f:
                print('Processing line: {} ({})'.format(line.rstrip(), j))
                cur.execute('SELECT recording.id FROM recording '+
                            'WHERE recording.filename=%s', (line.rstrip()+'.wav',))

                recId = cur.fetchone()[0]
                cur.execute('INSERT INTO evaluation_sets (eval_set, recordingId) '+
                            'VALUES (\'test_set\', %s)', (recId,))
                j += 1
        except MySQLdb.Error as e:
            msg = 'Error inserting utts into set.'
            log(msg, e)
            raise     

        # finally commit if no exceptions
        _db.commit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号