Compare two voices in python

Compare the Audio Data in Two MP3 Files in python language

In this article, I will explain you all how you compare voices between two files which are in the python language.Now, we are going to use Muse library to compare two voices files in python.

To create this we have some of the problems with MP3 files, and the problem is how we do that.First of all we want two MP3 files to comparison. 

This often leads to my having two MP3 files with the same name, and not being sure whether they are the same song with different tags, or two different versions of the song (for example, a studio version and a live version).

You guys, have to remember two things:-
·         First,two voices files are situated in same location.
·         Second Don’t give them same of the voice files.

Now,Iam started to use  muse library, and create a python program to back up and restore music libraries to a network attached file server, writing in python to allow it to be run on either Windows or Linux.

When I looked on Internet for the python library to let me compare the audio portions of two MP3 files and then, I found pydub in python. Unfortunately, pydub extracts the audio by running an external program, ffmpeg.

But I want my program which is easy for me or all of you for this I want  a Desiring portable solution, Then I decided to write my own library to allow me to compare the audio in two MP3 files in python.
The muse library defines the Mp3File object.

You can compare two Mp3Files using the compare Audio method. Each file is only processed once, and an MD5 checksum stored in the object to improve the speed of future comparison operations.

You guys, can find the latest version of muse on github:


MUSE is a Python program which is use  for backing up, restoring, and comparing your music library in python programming language and so compatible and so easy to use.


musealso provide some command line program that back ups, restores, and helps you to manage or compare your voice files or MP3 files or your music library. If you want help execute it with the --help option will give you a detailed manual page.After this you can easily execute your muse library.


Provide a backup music from your library
Compare your library for your backup music
Display the contents of your library or backup
Help for the user’s who want help
Restore files from your backup to your libary


Stop if any warning is came and stop all operation’s immediately.
It fix some issues when generated related to the muse libraries, when you install it on you python.
Ignore errors and treated them like warnings
Override the default location of the library and you can give your location.
Just for show some data’s or you can say that meta data
Show you guys all details but for that will do nothing
Quiet your muse library and come outside
Show all actions in the past

Python Program

Now we are going to create our python program to compare two voices of MP3 by with the use of python programming language.

For this we create three python program files,which is given below:-

This program file is use for ignoring purpose and if you all guys want to ignore serial commas,playlists and checksum’s in your program use this or you could say add this file in your project file.

import os

import sys

import unittest

dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.dirname(dir) + "../file")

from muse.StringFunctions import simpleString, reconcileStrings, safeAppend

class one(unittest.TestCase):

def testSimpleString(self):

self.assertEquals("your ,text", simpleString("Your new ,text"))

self.assertEquals(None, simpleString(None))

self.assertEquals("new one text", simpleString(u"add  \xD6yster text".encode('utf8')))

self.assertEquals("some more text’s", simpleString("some some add more text’s"))

self.assertEquals("hello how r u", simpleString("HELLO HOW  R U"))

def testReconcileStrings(self):

self.assertEquals("MINE", reconcileStrings("bubble", "The MINE", None))

self.assertEquals(None, reconcileStrings("linux", "linuc 3.2.1", None))

self.assertEquals("vision", reconcileStrings(None, None, default = "new vision"))

self.assertEquals("baby ", reconcileStrings("baby new ear’s", "kick the bar", None))

def testSafeAppend(self):

self.assertEquals("save -", safeAppend("safe", " - "))

self.assertEquals("", safeAppend(None, "+"))

self.assertEquals("", safeAppend("Unknown", "&", suppress="track"))

if __name__ == '__main__':


Our second python programming file is python file have the location of the two voices or audio MP3 files and for this location program want’s to know the location of the both MP3 files.

Well you all are create it in one python file it’s good to use all three files do their work alone because if we do all these work in one python file then program will become complex and it’s not good for our project.

import os

import sys

import unittest

new_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.dirname(new_dir) + "../file")

from muse.Library import Library

class mine(unittest.TestCase):

def func(self):

self.library = Library(testDir + "/data_file")

def func1(self):

self.library = Library(testDir + "/data_file", "PYTHON")

if __name__ == '__main__':


Now our last python file ise guys,Iam giving my program’s my name you all are have to give your’s.

This python file is for parsing or call the MP3 voice or audio files and after that you can compare them easily but first of all you all have to parse them here in the python programming files.this is the last step we have to do.

import os

import sys

import unittest

dir = os.path.abspath(os.path.dirname(__file__))

sys.path.append(os.path.dirname(dir) + "/file")

from muse.Factory import createAudioFile

from muse.Options import options

options['warning'] = True

class muse_func(unittest.TestCase):

def first(self):

value = createAudioFile(dir + "/data_file/PYTHON/songs/storm.mp3")


self.assertEqual(value.id3v2version, "versions 0.0.1")

self.assertTrue(not value.unsynchronization, "Not syncronized set")

def second(self):

new_value= createAudioFile(dir + "/data_file/PYTHON/songs/our_song.mp3")

self.assertEqual(new_value.id3v2version, "versions 3.2.3")

self.assertTrue(not new_value.unsynchronization, "Not syncronized  set")

if __name__ == '__main__':


Now at last you all have to compare both the function’s in the same class and if they are same they show messages that they are same voices or MP3 files else show that they are different voices .


Now you all finish your program of comparing two voices or MP3 files in python language.I really enjoy to explain you all to about this in my article.

I know that this program is not so easy and I know it will create some error’s but you all have to learn first the basic’s of python programming language.

This is important you all because it reduce error’s of your coding.

If you want help and want to learn python basics click here :-

If you Guy’s like this article plz comment here or if you all want solutions of some problems then comment  . . . . .


Post a Comment