Spaces:
Runtime error
Runtime error
File size: 1,179 Bytes
12bfd03 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# -*- encoding: utf-8 -*-
# 2022-2023 by zhaomingwork@qq.com
# can be used for generating train.lst or valid.lst only given a root dir
# example:
# python wavlstgen.py --wavdir /data/asr_data/aishell/ --outfile train.lst
import os
import time
import argparse
import json
import traceback
import logging
logging.basicConfig(level=logging.ERROR)
parser = argparse.ArgumentParser()
parser.add_argument("--wavdir",
type=str,
default="./",
required=True,
help="root dir of wav")
parser.add_argument("--outfile",
type=str,
default="./wav.lst",
required=False,
help="output list file name")
args = parser.parse_args()
print(args)
def genwavlist(rootdir):
outlist = open(args.outfile, 'w+')
for dirpath, dirnames, filenames in os.walk(rootdir):
for filename in filenames:
#print(os.path.join(dirpath, filename))
if filename.endswith(".wav"):
outlist.write(os.path.join(dirpath, filename)+"\n")
outlist.close()
if __name__ == '__main__':
genwavlist(args.wavdir)
|