![](/img/trans.png)
[英]Load all csv/txt files from one directory and merge them via python
[英]Extract all audio files from a directory and put them to a new one | python
我有一个包含1600个音频文件的文件夹,我要在其中使用essentia提取器提取它们,并将它们更改为同一目录中另一个文件夹中的.json文件。 为此,我使用以下行:
os.system("/usr/local/bin/essentia_streaming_extractor_music 2.mp3 2.mp3.json")
2.mp3是原始文件,2是我的音频文件的ID。 如您所见,我想保持音频名称不变,只是添加.json扩展名。 我不知道如何保留每个文件的ID,以及我需要做哪种迭代和递归编程。 有人可以帮我吗?
import os
allfiles = os.listdir('.') # Lists all files in the current directory
for item in allfiles: # iterate over all files in the current directory
if item.endswith('.mp3'): # Checks if the file is a mp3 file
os.system('/usr/local/bin/essentia_streaming_extractor_music '+item+' '+item+'.json')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.