DEV Community

Free Python Code
Free Python Code

Posted on

Extract audio meta data (album, artist, duration, etc) in Pyhton

Hi πŸ™‚πŸ–

Welcome to a new post. Today I will share with you how to extract meta data from an audio file, such as album, artist, and more. To do this, I will use a library called tinytag, which is a library for reading the music meta data of most common audio files in pure Python.

step 1

install tinytag from pip install tinytag

step 2


from tinytag import TinyTag

song = TinyTag.get('test.mp3')
print(song.album)
print(song.year)
print(song.artist)
print(song.duration)

Enter fullscreen mode Exit fullscreen mode

You can use print(song.as_dict()) to print all meta tags

Note
Some audio files do not have meta tags.

Form more information about tinytag

https://github.com/devsnd/tinytag

Now we're done πŸ€—

Don't forget to like and follow πŸ™‚

Top comments (0)