一种编辑Python中WAV文件元数据的方法

发布于 2025-02-03 20:51:03 字数 401 浏览 4 评论 0原文

有没有办法或库在Python中添加WAV文件的元数据?我试图使用诱变库,但似乎与WAV文件和其他库(Exp的TinyTag)似乎不太合作。同样,我尝试使用诱变剂,以下是我尝试创建一个函数以添加具有日期值的新日期标签:

def update_metadata(wavFile, date):
    wavFile.tags["DATE"] = mutagen.id3.Frame(encoding=3, text=date)
    wavFile.tags.save()

然后,当我使用pprint()>使用元数据时我得到frame = date这是错误的,因为我应该得到date = date。它甚至没有被保存到元数据标签上。

Is there a way or library to add/ edit metadata of a WAV file in Python? I have tried to use the Mutagen library but it doesn't seem to work well with WAV files and other libraries (tinytag for exp.) only seem to allow you to access the metadata but not edit or add in new entries. Again, I have tried to use Mutagen and below is my attempt at creating a function to add in a new DATE tag with a date value:

def update_metadata(wavFile, date):
    wavFile.tags["DATE"] = mutagen.id3.Frame(encoding=3, text=date)
    wavFile.tags.save()

And then when I go to print out the metadata using pprint() I get Frame=date which is wrong as I should get DATE = date. It doesn't even get saved onto the metadata tag.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅窗月明清似水 2025-02-10 20:51:03

好的,我终于找到了一个用于WAV文件和其他音频文件的库,其pytaglib: htttps:htttps:// pypi.org/project/pytaglib/ 。这是C ++ taglib api的Python包装器( https://taglib.org/api/api/api/ )音频文件的元数据。

Okay, I finally found a library that does this for Wav files and other audio files, its Pytaglib: https://pypi.org/project/pytaglib/. It's a Python wrapper for the C++ taglib api (https://taglib.org/api/) that edits the metadata for audio files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文