zemoto / WhatAmIHearing

App that will record system audio and send it off to the Shazam API to be identified. For when your phone's microphone just can't quite capture the song well enough for Shazam to figure it out.
MIT License
37 stars 0 forks source link
app application audio csharp desktop-app music mvvm naudio net6 portable recording shazam windows wpf xaml

WhatAmIHearing

An app that will record system audio and send it off to the Shazam API to be identified. For when your phone's microphone just can't quite capture the song well enough for Shazam to figure it out.

How do I Download it?

Go to the Releases Page on the right side of the GitHub repo and on the latest release you'll see a zip file attached named WhatAmIHearing.zip:

Click that link to download the zip file, unzip it, and run WhatAmIHearing.exe to open the app.

Updating

Settings are stored in a config.json and history is stored in history.json. Both files are kept right next to your WhatAmIHearing.exe. When updating all you need to do is take those files from your previous version and put them next to the new WhatAmIHearing.exe. If you're using your own API key, be sure to also bring in your ShazamApiKey.json file.

Rate Limiting

Shazam's API has a rather stingy 500 requests per month on the free tier, and the higher tiers are unreasonably expensive for a non-business. To work around this the app supports using your own API key in place of the one I bundle with the app.

To get an API key:

  1. Go to https://rapidapi.com and make an account.
  2. Go to https://rapidapi.com/apidojo/api/shazam and under the "Pricing" section subscribe to the free tier. This should not require any additional info.
  3. Go to https://rapidapi.com/developer/dashboard to see a new Shazam app created for you. Should be named something like default-application_#######.
  4. The Authorization section of that App contains the API key which you can then paste into the ShazamApiKey.json file bundled with the WhatAmIHearing.

Sorry I can't do much to make this easier other than spend a bunch of money to upgrade the API tier. Feel free to ask me any question or report any issues by creating a new Issue.

Technical Details

Written in C# with WPF for the UI. Compiled with Visual Studio Community 2022 against .NET 6.0.

ZemotoCommon (https://github.com/zemoto/ZemotoCommon/tree/master) is my utility submodule containing classes that I use in all of my projects.

Uses POST calls to Shazam's API (see documentation at https://rapidapi.com/apidojo/api/shazam) with the raw audio in the body for song detection.

Audio recording

NAudio (https://github.com/naudio/NAudio) used for recording, resampling, and playback. See the Recorder class for the meat of the logic.

Uses NAudio's WasapiLoopbackCapture class to record system audio. Shazam allows for up to 500KB of audio to be sent to their API, so we record the maximum amount we can. As of NAudio v2.1 the recorder supports resampling the audio during recording so it is already in a format that Shazam will take once we are done.