本篇主要針對 AudioDiff 在音檔比對的實測

https://audiodiff.readthedocs.io/en/latest/ 安裝

pip install audiodiff

main.py

import audiodiff
from argparse import ArgumentParser


#Parser argument
parser = ArgumentParser(
    description="Compare two audio files to determine if one "
                "was derived from the other. Supports WAVE and MP3.",
    prog="audiomatch")
parser.add_argument("-f", action="append",
                    required=False, dest="files",
                    default=list(),
                    help="A file to examine.")
parser.add_argument("-d", action="append",
                    required=False, dest="dirs",
                    default=list(),
                    help="A directory of files to examine. "
                         "Directory must contain only audio files.")

args = parser.parse_args()

search_paths = args.dirs + args.files

if len(search_paths) != 2:
    die("Must provide exactly two input files or directories.")

if audiodiff.equal(search_paths[0], search_paths[1]):
    print "TRUE"
else:
    print "FALSE"

結論: 僅能比對不同類型的檔案,音源是否一樣