##将制定文件夹下的文件随机挑出n个,放在另一个文件夹下
import random
import os
from shutil import copyfile
imgs = []
for x in os.listdir(file_path):
if x.endswith('.wav'):
imgs.append(x)
selected_imgs=random.sample(imgs,k=5)
print(selected_imgs)
for img in selected_imgs:
src=os.path.join(file_path,img)
dst=os.path.join(out_path,img)
copyfile(src,dst)
print("copy done")