13 ms·
I recreated Shazam’s algorithm with Go
- bravura 2y agoIt would be quite nice if there were a community-based way of sharing fingerprints.
- johnneville 2y agoI think musicbrainz supports this https://musicbrainz.org/doc/AcoustID https://musicbrainz.org/doc/AcoustID
- gradientsrneat 2y agoI'd love to see this also, for audio but also picture and video clips as well. iirc Bittorrent uses a DHT, but the hashes are of the entire content. Not so useful for, say, finding the original version for poorly attributed derivative works. Tineye is sometimes good for finding the original version of an image.
- johnneville 2y agoI'd love a way to use local files instead of spotify/youtube to create the set of fingerprints that is searched.
- ccgzirim 2y agoI've added that to my to-do list and plan to implement it this weekend.
- deleted 2y ago[deleted]
- KomoD 2y agoIf you insert Spotify songs, wouldn't it make more sense to output Spotify songs too?
- ccgzirim 2y agoIt would actually. But Spotify doesn't allow direct downloads so I had to find the songs on YouTube and download them from there.
- written-beyond 2y agoYou're a G
- crtasm 2y agoNote that YouTube's ToS doesn't allow this either, be aware what you're potentially getting into by releasing a tool that rips music from there.
- lucb1e 2y agoUploaders can choose a video license. Since there is no download button for those videos, I've always wondered if that is a creative commons' violation and therefore Youtube should run into the same legal issue that StackOverflow currently is (ctrl+f "violat" https://meta.stackexchange.com/questions/401324/announcing-a-change-to-the-data-dump-process https://meta.stackexchange.com/questions/401324/announcing-a...), namely that this terminated google's (but nobody else's) license to use the video under these creative commons terms
- subpub47 2y agoAll Spotify sees is bytes going to your computer. What happens to those bytes afterward is your own business.
- vegabook 2y agoRecently found Shazam is less accurate - somehow soundhound is giving me better results. On Shazam I'm getting a lot of results from Asian musical traditions which is great, if it wasn't the wrong song. Maybe they need to improve the algo if they've increased the range of music they will select from? Seems now there's a lot more hash table collision[1]. [1] https://github.com/cgzirim/not-shazam?tab=readme-ov-file#resources--card_file_box
- cglan 2y agoSoundhound has always been better than Shazam. It can even pick up people singing and extremely quiet songs
- jedberg 2y agoIn my sample of one song, I have to disagree. I played Watermelon by Mezerg, which is admittedly not very popular, and Soundhound couldn't get it with two tries, but Shazam picked it up in less than two seconds.
- robbomacrae 2y agoI work at SoundHound. If it didn't get it in two tries it's likely we didn't have that song in the database. Both Shazam and SH have knowledge gaps.
- IndySun 2y agoI've championed Soundhound but it has literally stopped working (finding any tune) on my iphone. I've reinstalled, still nothing. It does not appear to 'hear' anything.
- RockRobotRock 2y agoIs it possible the microphone permission was turned off?
- hactually 2y agoreally decent and nicely done Golang! I'll pull and play with it tomorrow!
- ccgzirim 2y agoThanks! I appreciate the compliment on my Golang; This is actually my first full-fledged project with the language, haha. Feel free to reach out if you have any issues running it.
- halfmatthalfcat 2y agoFYI - If this is a true reproduction of Shazam, it’s under patent by Apple through at least March 2025[1]. [1] https://patents.google.com/patent/US7627477 https://patents.google.com/patent/US7627477
- mathfailure 2y ago[flagged]
- halfmatthalfcat 2y agoI thought my comment would be obvious but anyone using this code for profit within a jurisdiction that honors this patent would be exposed to potential litigation from Apple.
- amelius 2y agoFigure 1 looks interesting since it has both a time and frequency axis, when usually signals have either a time __or__ frequency axis. Now I'm curious how the Fourier (?) transform of a signal at a __single__ given timepoint is even defined ...
- jamessb 2y agoThe concepts you are looking for are the short-time Fourier transform and spectrogram: https://en.wikipedia.org/wiki/Short-time_Fourier_transform https://en.wikipedia.org/wiki/Short-time_Fourier_transform https://en.wikipedia.org/wiki/Spectrogram https://en.wikipedia.org/wiki/Spectrogram
- earthnail 2y agoJamessb already linked to the right terms. One thing to add is that there is always a tradeoff between time and frequency resolution on short time Fourier transforms. You just can’t have both. It’s always a somewhat unsatisfying tradeoff that still works well in practice.
- 2y ago
- DandyDev 2y agoIsn’t the whole point of Shazam that you don’t know the song and want to find it? If you don’t know the song, hoeven you provide a Spotify link?
- zild3d 2y agothis is a demo of the algorithm, not a full app / hosted service using it with a pre-populated database. The spotify link would be to fingerprint the song and add it to the database
- ccgzirim 2y agoYou're right. The Spotify link is used solely to get details about the song. These details are then used to search for and download the song from YouTube. Afterward, the fingerprint for the song is created and added to the database.
- paxys 2y agoThe idea is that you add every Spotify song in the database, and then run your match against them.
- yazmeya 2y agoI enjoyed this talk at the DAFx17 conference by Avery Wang, co-founder of Shazam. It goes a little into the theory behind the algorithm, and looks at some of the more practical issues (background noise, etc.): https://www.youtube.com/watch?v=YVTnj3OIhwI https://www.youtube.com/watch?v=YVTnj3OIhwI
- DevX101 2y agoAdding this to the watch list. Reading this paper was one of the first times I got a 'wow' moment around computing algorthms.
- anticristi 2y agoI wonder how long until someone will simply smoosh a billion songs into a "large song model" and make all signal processing knowledge irrelevant.
- deleted 2y ago[deleted]
- Cieric 2y agoWhile the project does look nice to use and modify. I'm not sure I personally would have posted it yet. - The instructions seem not to be the best to get it up and running (e.g. "cd not-shazam" and just a few lines later "cd not-shazam/client") - MongoDB is needed but information on how to hook it up/use it are absent (I would make the DB swapable and provide something less intrusive like sqlite) - If replacing MongoDB is not possible, I would provide a dockerfile and a docker compose to allow easy startup and testing. - The client npm install has 8 critical vulnerabilities, these might not actually matter but it makes me hesitant to continue testing - You might not care about the patent or the copyright, but I would still change the name at the very least. Github itself is located in the US and will remove the project if they receives a DMCA. - Last, this might not be as important, I would add a way to add songs from wav files. Not everything I'd want to test this with is on spotify or youtube. I'm not saying this to discourage you or anything, I just think the project needs that little extra bit of polish. Minor things will cause people to discredit or ignore a project. If I get around to it I might make a PR for the project. I want to experiment with audio matching outside of the music space, and your project seems like it'll be the easiest to modify. Edit: Formatting
- deleted 2y ago[deleted]
- ccgzirim 2y agoThank you for the time you took to provide such detailed feedback. I really appreciate your honest input. You've raised some valid points that I hadn't really considered. I agree that the project could definitely use some polishing. I'll prioritize improving the setup instructions and look into adding a file-based DB for flexibility, as well as resolving the npm vulnerabilities. Adding support for directly fingerprinting wav files is a great idea and something I'll prioritize, too. Regarding the project name, I understand the potential legal implications and will definitely change it. I'd appreciate any suggestions you might have. I'm excited about the possibility of your contributions. Please, feel free to open a PR whenever you're ready. Thanks again for your feedback!
- bravura 2y ago
- Philip-J-Fry 2y agoI think you've leaked your developer key here... https://github.com/cgzirim/not-shazam/blob/main/spotify/youtube.go#L21 https://github.com/cgzirim/not-shazam/blob/main/spotify/yout...
- strongly-typed 2y agoThis is really cool. I’ve been itching to try building this exact kind of thing as part of my bucket list.
- ccgzirim 2y agoThanks. I'm glad it inspires you! It'd be awesome to see you take it on. You can clone it and develop it further.
- wmichelin 2y agoHardcoded sleeps for some reason, nice /s https://github.com/cgzirim/not-shazam/blob/888070f3434acbc0a59a3cad8972eba3c359ee27/spotify/downloader.go#L34 https://github.com/cgzirim/not-shazam/blob/888070f3434acbc0a...
- rvnx 2y agoIt's to go around the ban of the IP / account by Spotify and to be softer with them, you have to wait between two requests to download songs.
- lucb1e 2y agoI also use sleep a lot in my code when interfacing with third-party services (multiprocess usually so it's not blocking things, though I'd also totally see myself using a callback pattern or so if the caller can handle those). When it's more than an ad-hoc piece of code, it generally measures how long ago the previous request finished to determine how long to sleep if the next call is made within the cool-off period. If you're not doing that... please don't interface with my server
- euroderf 2y agoRun it as a daemon that displays every song in a UI notification ?
- theabhinavdas 2y agoYou deserve reddit gold for this idea
- jokoon 2y agoThis is useless unless you have all the songs on earth Algorithm don't matter, only data matters
- 38 2y ago[flagged]
- jena2244 2y ago[dead]
- nwsm 2y agoHere we have an open-source algorithm that is useful to anyone with data. It doesn't have to be music
- 0cf8612b2e1e 2y agoAlthough, would be curious how good you could get to isolating to a single artist. If you had say one exemplar fingerprint per artist, could an out of dataset fingerprint from their discography cluster to that artist? Obviously not for artists who transitioned musical styles. Or is the algorithm more feature hash than a clusterable feature vector?
- ccgzirim 2y agoIsolating a single artist based on a fingerprint sounds challenging but interesting. Using exemplar fingerprints, a representative sample of an artist's music, is a good approach, but success would require detailed fingerprints, a varied dataset, and a well-chosen algorithm. For artists who change styles, time-series analysis can capture their evolving sound. The solution will likely need machine learning. The current solution doesn't use feature hashing or clusterable feature vectors. Instead, it relies on audio fingerprinting, which breaks down short audio samples into unique patterns or "fingerprints" for quick comparison with a large database of known songs.
- lucb1e 2y ago
- msie 2y agoI enjoyed reading the Go source. As opposed to the time I had to read some Ruby code.
- jena2244 2y ago[dead]
- blackeyeblitzar 2y agoI’ve heard that the Google phones have a built in music recognition feature that is the best implementation of this stuff. Anyone know what their approach was? Apart from that I always have felt Soundhound was better than Shazam
- lucb1e 2y agoIirc there was some small algorithm, or perhaps even a piece of hardware, that should trigger when music is playing so that the phone isn't active all the time. From there, I guess they could use any old detection algorithm; for me, the magic was in this super-energy-efficient bit of the chain, though I never read up on the details (if they ever provided any)
- pjs_ 2y agoShazam's technology came in part out of CCRMA, which is a very cool and special place on Stanford Campus, with deep connections to early computer history. I think it is very interesting that so many of the early applications of computer technology have to do with audio. John Bardeen's music box, the first commercial application of the transistor in hearing aids, the HP garage in Palo Alto was originally building audio oscillators, the iPhone evolved from the iPod, the internet was built on copper made to carry analog telephone calls, Bell Labs (ping!), the list goes on. A friend of mine has the hypothesis that maybe human beings end up figuring out how to do kHz stuff before they go on to do MHz/GHz stuff. Not a perfect explanation but kind of attractive...
- crowdstriker 2y agoYou're reaching.
- crngefest 2y agoIMHO it’s because audio is „easy“ to manipulate electronically. You can transform every audio signal into an electronic signal relatively easy - for graphics there is so much more complexity involved just in making them visible. A speaker that translates electronic signal into sound waves is a super simple contraption at its core. Edit:/ and audio is striking - it has a profound effect on every human (except deaf of course). If I wanted to demonstrate the power of electronics/computers I would choose audio as well.
- ascorbic 2y agoThis is cool, but you urgently need to change the name.
- scoot 2y agoShazam is historically interesting, but Google's "hum to search" algorithm is far superior, and even that is nearly four years old (since production).
- renierbotha 2y agoHaven't crawled through the repo (yet) but quick question - where does the data that is being searched over come from? Are you loading a library or searching some large library acquired from somewhere else?
- ccgzirim 2y agoThe data comes from a database of fingerprints connected to the server. These fingerprints are created whenever songs are added.