【问题标题】:Extract all audio files from a directory and put them to a new one | python从一个目录中提取所有音频文件并将它们放到一个新目录中 | Python
【发布时间】:2016-11-14 19:10:38
【问题描述】:

我有一个包含 1600 个音频文件的文件夹,我想在其中使用 essentia 提取器提取它们并将它们更改为同一目录中另一个文件夹中的 .json 文件。为此,我使用这一行:

os.system("/usr/local/bin/essentia_streaming_extractor_music 2.mp3 2.mp3.json")

2.mp3 是原始文件,2 是我的音频文件的 id。如您所见,我想保持音频名称不变,只需添加 .json 扩大。我不知道如何保留每个文件的 id 以及我需要做什么样的迭代和递归编程来实现这一点。有人可以帮帮我吗?

【问题讨论】:

    标签: python json audio extract


    【解决方案1】:
    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')
    

    【讨论】:

      猜你喜欢
      • 2019-07-07
      • 1970-01-01
      • 1970-01-01
      • 2014-01-01
      • 2017-06-09
      • 1970-01-01
      • 2013-11-05
      • 1970-01-01
      • 2021-01-22
      相关资源
      最近更新 更多