Coder Social home page Coder Social logo

itspoma / audio-fingerprint-identifying-python Goto Github PK

View Code? Open in Web Editor NEW
353.0 13.0 166.0 368 KB

The Shazam-similar app, that identify the song using audio fingerprints & spectrum analysis and Fast Fourier transform

License: MIT License

Python 98.64% Makefile 1.36%

audio-fingerprint-identifying-python's Introduction

Fingerprint audio files & identify what's playing

How to set up

  1. Run $ make clean reset to clean & init database struct
  2. Run $ make tests to make sure that everything is properly configurated
  3. Copy some .mp3 audio files into mp3/ directory
  4. Run $ make fingerprint-songs to analyze audio files & fill your db with hashes
  5. Start play any of audio file (from any source) from mp3/ directory, and run (parallely) $ make recognize-listen seconds=5

How to

  • To remove a specific song & related hash from db

    $ python sql-execute.py -q "DELETE FROM songs WHERE id = 6;"
    $ python sql-execute.py -q "DELETE FROM fingerprints WHERE song_fk = 6;"

Thanks to

audio-fingerprint-identifying-python's People

Contributors

itspoma avatar naereen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

audio-fingerprint-identifying-python's Issues

python3

this project is not working for me and I am using python3

Show Sound Frequency While Recording

Hello!
Thank you so much for your project!

Sorry to bother you guys.

But i've been trying since the last week to get it to show the sound frequency in Hz (not an spectrum, just the Hz value) on console while recording but no success yet.

I think i need to do modifications in the recognize-from-microphone.py or the reader_microphone.py or the visualiser_console.py.

Can someone help me? Thank you in advance!

make recognize-file

Hello,
I try to test "make recognize-file filepath".
But it didn't work.
Is it possible recognize from mp3 file?
Thanks

recognize-from-file.py

not working

original
from libs.reader_microphone import FileReader

song = None
seconds = 5

r = FileReader(123)
r.recognize(seconds=seconds)

print(song)

is going to be ?????

from libs.reader_file import FileReader

song = None
seconds = 5

r = FileReader(123)
#r.recognize(s=5)

print(song)

WindowsError: [Error 2] The system cannot find the file specified

The problem occurs when we try to execute the collect fingerprint file
Traceback (most recent call last):
File "C:/Users/BARRETT/Desktop/audio-fingerprint-identifying-python-master/collect-fingerprints-of-songs.py", line 24, in
audio = reader.parse_audio()
File "C:\Users\BARRETT\Desktop\audio-fingerprint-identifying-python-master\libs\reader_file.py", line 34, in parse_audio
audiofile = AudioSegment.from_file(self.filename)
File "C:\Python27\lib\site-packages\pydub\audio_segment.py", line 505, in from_file
p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 672, in init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 882, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Couldn't find a license

You project seems very interesting, could you add a license?

By the way, I am evaluating some audio fingerprinting libraries and most of them use MIT License, however a few use GPL license.

Live monitoring just like Shazam does.

Hello,
This project does fingerprint matching after sound is been fully recorded. But can we perform live monitoring of the sounds just the way shazam app does, If yes can you please guide me on same.

Write a requirements.txt file

Hi,
Nice projects 👏!

It's hard to test though, as there is no clean list of dependencies (I had to try, see that module X is missing, run pip install X, then try again, like 5 times…).
Could you write a requirements.txt please?
Thanks!

error running make fingerprint-songs command

Hi i keep trying to run the 'make fingerprint-songs' command but keep getting this error.

root@programmer-virtual-machine:~/Desktop/audio-fingerprint-identifying-python# make fingerprint-songs sqlite - connection opened Traceback (most recent call last): File "collect-fingerprints-of-songs.py", line 25, in <module> song = db.get_song_by_filehash(audio['file_hash']) File "/home/programmer/Desktop/audio-fingerprint-identifying-python/libs/db.py", line 15, in get_song_by_filehash "filehash": filehash File "/home/programmer/Desktop/audio-fingerprint-identifying-python/libs/db_sqlite.py", line 61, in findOne return self.executeOne(select['query'], select['values']) File "/home/programmer/Desktop/audio-fingerprint-identifying-python/libs/db_sqlite.py", line 34, in executeOne self.cur.execute(query, values) sqlite3.OperationalError: no such table: songs sqlite - connection has been closed Makefile:19: recipe for target 'fingerprint-songs' failed make: *** [fingerprint-songs] Error 1 root@programmer-:~/Desktop/audio-fingerprint-identifying-python#

Error: recognize() got an unexpected keyword argument 'seconds'

Ive beet getting the following error whenever i try to recognize from a file! Any ideas how to fix this? or what the problem might be

Traceback (most recent call last):
File "recognize-from-file.py", line 7, in
r.recognize(seconds=seconds)
TypeError: recognize() got an unexpected keyword argument 'seconds'
Makefile:25: recipe for target 'recognize-file' failed
make: *** [recognize-file] Error 1

multiple audio fingerprinting

Hi, i want to fingerprint multiple sounds from microphone.
i used python this python module but it can't recognize multiple sounds that play continuously.
is there any solution to recognize multiple sounds in one record ?

thanks.

Updated codes to Python 3.6 showing error

@itspoma

I forked this repo and updated the python files to Python 3.6.
But on running the command make fingerprint-songs

I get these errors.

Traceback (most recent call last):
  File "collect-fingerprints-of-songs.py", line 54, in <module>
    channel_hashes = set(channel_hashes)
  File "/home/executable/Desktop/audio-fingerprint-identifying-python/libs/fingerprint.py", line 168, in generate_hashes
    h = hashlib.sha1("%s|%s|%s" % (str(freq1), str(freq2), str(t_delta)))
TypeError: Unicode-objects must be encoded before hashing
sqlite - connection has been closed
make: *** [Makefile:19: fingerprint-songs] Error 1

TypeError: numpy boolean subtract, the `-` operator, is deprecated

Traceback (most recent call last):
  File "collect-fingerprints-of-songs.py", line 53, in <module>
    channel_hashes = fingerprint.fingerprint(channel, Fs=audio['Fs'], plots=config['fingerprint.show_plots'])
  File "audio-fingerprint-identifying-python/libs/fingerprint.py", line 95, in fingerprint
    local_maxima = get_2D_peaks(arr2D, plot=plots, amp_min=amp_min)
  File "audio-fingerprint-identifying-python/libs/fingerprint.py", line 115, in get_2D_peaks
    detected_peaks = local_max - eroded_background
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logic al_xor function instead.

With most up-to date numpy on Python 2.

make clean reset

Could you help me ?

Traceback (most recent call last):
File "/home/prosper/Dev/audio-fingerprint-identifying-python/reset-database.py", line 2, in
from libs.db_sqlite import SqliteDatabase
File "/home/prosper/Dev/audio-fingerprint-identifying-python/libs/db_sqlite.py", line 1, in
from db import Database
ImportError: cannot import name 'Database' from 'db' (unknown location)
make: *** [Makefile:10 : reset] Erreur 1

What's wrong please ?

Error while running sqlite.py testing file

KeyError: 'db.file'
Exception AttributeError: "'SqliteDatabase' object has no attribute 'conn'" in <bound method SqliteDatabase.del of <libs.db_sqlite.SqliteDatabase object at 0x035828F0>> ignored

error to run "python collect-fingerprints-of-songs.py"

It shows me the next error:

MacBook-Pro-de-Jesus:audio-fingerprint-identifying-python jesushedo$ python collect-fingerprints-of-songs.py
sqlite - connection opened
Traceback (most recent call last):
File "collect-fingerprints-of-songs.py", line 24, in
song = db.get_song_by_filehash(audio['file_hash'])
File "/Users/jesushedo/Desktop/audio-fingerprint-identifying-python/libs/db.py", line 15, in get_song_by_filehash
"filehash": filehash
File "/Users/jesushedo/Desktop/audio-fingerprint-identifying-python/libs/db_sqlite.py", line 61, in findOne
return self.executeOne(select['query'], select['values'])
File "/Users/jesushedo/Desktop/audio-fingerprint-identifying-python/libs/db_sqlite.py", line 34, in executeOne
self.cur.execute(query, values)
sqlite3.OperationalError: no such table: songs
sqlite - connection has been closed

Make issue, "cannot import name 'Database' from 'db' (unknown location)"

I'm following the set-up instructions. I try make clean reset and get this error.

Traceback (most recent call last):
  File "reset-database.py", line 2, in <module>
    from libs.db_sqlite import SqliteDatabase
  File "/eric/Desktop/Audio fingerprint/audio-fingerprint-identifying-python-master/libs/db_sqlite.py", line 1, in <module>
    from db import Database
ImportError: cannot import name 'Database' from 'db' (unknown location)
make: *** [Makefile:10: reset] Error 1


I assume I'm doing something in the wrong order, but db is an empty folder. Just unsure what I'm missing.

Comparing short audio files

Hi,
I'm interested in finding near-duplicate audio files. My dataset is about 3000 thousands short audio files, between 0.5 seconds to 5 seconds. Unlike Shazam, both the "target" audio (i.e. the songs in Shazam's case) and the user input are short, and both might contain noise.

Can this library help?
If so, are there any recommendations for tuning parameters?

N.B - if a file is matched to multiple other files, it's fine - I have a less efficient algorithm that can verify which match is correct. In other words, I can handle some amount of false positives, but I don't want false negatives.

_UFuncNoLoopError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('S8'), dtype('int64')) -> None

I'm running using Python 3.9 and I get this error:

numpy.core._exceptions._UFuncNoLoopError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('S8'), dtype('int64')) -> None

With this line of code:

yield sid, offset - mapper[audio_hash]

To get around it I added a Try/Catch however I'm losing a lot of information and want to know the correct way to handle this?

        for hash, sid, offset in x:
            try:
                if isinstance(mapper[hash], bytes):
                    db_offset = int(mapper[hash].decode('utf-8'))
                elif isinstance(mapper[hash], (int, np.integer)):
                    db_offset = int(mapper[hash])
                else:
                    raise ValueError(f"Unsupported type for mapper[{hash}]: {type(mapper[hash])}")
                
                if isinstance(offset, bytes):
                    offset = int(offset.decode('utf-8'))
                elif not isinstance(offset, (int, np.integer)):
                    raise ValueError(f"Unsupported type for offset: {type(offset)}")
    
                yield (sid, offset - db_offset)
            except ValueError:
                print(f"Invalid value for mapper[{hash}]: {mapper[hash]} - Offset {offset}")    # Heaps are invalid
                continue
            except KeyError:
                print(f"Key {hash} not found in mapper")
                continue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.