将Python中的随机列表文件合并为一个字符串

时间:2016-02-09 07:39:09

标签: python sox

我想将wav文件与sox.like这个模板合并:

sox input1.wav input2.wav input3.wav outfile.wav

我想通过python脚本随机输出wavfile:

import os, time, fnmatch, random

fichier = []
file = os.getcwd() + "/*"
p = 0
time.sleep(0.1)
time.sleep(0.1)
for file in os.listdir('.'):
    if fnmatch.fnmatch(file, '*.wav'):
        fichier.append(file)
        p = p + 1
print("nombre de fichiers=> " + str(p))
random.shuffle(fichier)
cmd='sox '+ fichier +' sortie.wav'

print(cmd)
os.system(cmd)

问题是fichier是一个列表,不能在字符串命令中... 我怎样才能正确地从数组中提取所有文件?

0 个答案:

没有答案