![](/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.