Search code examples
pythonmetadatawavmutagen

A way to edit the metadata of WAV files in Python


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.


Solution

  • 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.