Introduction: Play CDs Without CD Player, Using AI and YouTube
Want to play your CDs but have no more CD player? Did not have time to rip your CDs? Ripped them but the files are unavailable when needed?
No problem. Let AI (artificial intelligence) identify your CD, and YouTube play it!
I wrote an Android app doing the following:
1. take a picture of the CD cover,
2. search for text keywords using Google Vision
3. search for a corresponding playlist on YouTube
4. then launch YouTube on the found playlist.
This Instructable covers the installation, setup and usage of the app. As a bonus, it briefly covers the retrofitting of a vintage 80's boombox.
If you like this project, please vote for it in the audio contest!
Step 1: The Concept
The problem with CDs
I have a few hundreds CDs, but we have no more audio CD player around. More than ten years ago I started to rip my CDs: eventually less than the half would get ripped, and stored no longer sure where.
Today, most of our stuff is in our smartphones, in the cloud, streamed.
But I still like my CDs. What do they represent to me? Maybe the feeling the I can physically own the music I did purchase. Or the reminiscence of a time when concept albums were a thing...
Enter YouTube and Google Cloud Vision
On YouTube, many CDs, even lesser known, have been ripped and published as a playlist.
Google Cloud Vision provides image analysis services, of which we will use image labeling. In short, an image is submitted, the service analyses it (using machine learning with models trained by Google) and returns labels, which are text keywords saying what has been recognized in the image. Cloud Vision is surprisingly good at recognizing CD artworks.
A solution
Having noticed the latter, and after a quick test in Python, I decided to write an Android app (written in Kotlin) that would:
1. take a photo of the CD case,
2. query Google Vision to get keywords describing the image,
3. query YouTube to see if there is a full album corresponding to these keywords,
4. launch YouTube on the found playlist.
Why using a smartphone?
Essentially because everything needed is here and well integrated, in particular the camera.
Arguably, used smartphones are a better alternative to Raspberry Pi for building media centers.
Step 2: Stuff Needed: an Android Phone
The Phone
Just use your current Android cell phone, or get (an old) one if you intend to build a dedicated music player.
What to buy?
Should you buy a cheap new phone, or buy a used one?
Although the hardware specs are not tremendously important for this project, I would not recommend buying a new one under $100, as the quality can be very poor (shitty screen, sluggish). If you consider buying an old flagship, remember that you never really know what you will get.
It's always best if you can try it before buying.
Can I use an iPhone?
Not yet, and not that I know. I only developed the app for Android.
If you know an equivalent iOS app, or developed it, or know somebody who did, please let me know!
Step 3: Google APIs Setup
You will need to enable the APIs for you, and get an API key.
1. About APIs and keys
API keys are needed by the mobile app to access the Google services on your behalf.
For the Google Cloud VisionAPI, as per https://cloud.google.com/vision/pricing#prices, up to 1000 detections per month are free.
For YouTube Data API, as per https://developers.google.com/youtube/v3/getting-started#quota the quota is 1 million units per day. For one CD search you will consume 100+6 units, this means you can do 9433 searches per day.
* * *
This should incur no costs to you.
However, DO IT AT YOUR OWN RISKS.
I cannot be held responsible for any problem caused by this tutorial nor the ScanTube app.
* * *
2. Enable YouTube and Google Cloud Vision APIs, and get a key
2a. Visit https://console.developers.google.com/apis
2b. Create your project, name it e.g. ScanTube.
2c. Create credentials:
- Select credentials: https://console.developers.google.com/apis/credentials
- Create credentials of type API key.
- Copy the key value in a local text file in your computer.
2d. Enable YouTube API:
- Visit https://console.developers.google.com/apis/library and locate YouTube Data API v3. Activate it.
2e. Enable Cloud Vision API:
- Visit https://console.developers.google.com/apis/library and locate Cloud Vision API. Activate it.
We'll use the same API key for both YouTube and Cloud Vision services, so we're done for this part.
Step 4: Phone Setup
The ScanTube app is available on the Google Play Store in beta test program.
First, be sure to read and accept the Privacy Policy.
1. Install the ScanTube Android app
Visit the following link from your mobile phone: https://play.google.com/apps/testing/digital.bauermeister.scantube, then click download it on Google Play and follow instructions.
(If you are a developer and want read the source, visit https://github.com/pbauermeister/ScanTube.)
2. Configure the ScanTube Android app
2a. Start the ScanTube app, allow it to use the camera.
2b. On the first use, the app suggests to set the app keys, so do it:
- For the Google Vision app key, enter the API key obtained above (*).
- For the YouTube app key, enter the same API key (*).
(*) Instead of typing the API key manually (which is a huge burden), you can send it from your computer to your phone via email or via a DropBox file, and copy-paste it into the ScanTube settings field.
2c. Go back to the main screen, start the settings by clicking the cog icon. Review the General settings. Quite self-explanatory.
In particular, Camera choice shall be set according to your use case. For integration into a media center: front camera. For hand-held use: back camera.
3. Other considerations for an Android-based media center
- Install Nova Launcher and set the desired desktop orientation.
- On the desktop, create shortcuts for ScanTube, YouTube, and any other audio/video relevant apps.
- Uninstall or disable all irrelevant apps.
If anyone may use this media center:
- Disable the lock screen.
- Use a dedicated Google account, free of private data and emails
Step 5: Optional: Retrofit a Vintage Boombox
In this step, the cell phone is fitted onto an old boombox from the 80's.
Mounting the smartphone
All original functions of the boombox being intact and perfectly functional, including the cassette player, I decided to preserve them and mount the phone on the outside of the tape deck door.
Audio signals
The boombox has AUX inputs. That was a purchase decision factor. I connected them to the phone jack.
Powering the smartphone
The mains transformer was defective so I am using an external 9V adapter. 9V because the boombox accepts 6 x 1.5V batteries. An LDO voltage regulator (LM1117T-5.0) generates 5V out of the 9V, in order to power the phone via USB.
Connections
Finally I routed the power and audio signals to the outside, using flat-band cable going through the door space.
Now we have a genuine survivor of the 80's
It's in perfect condition, upgraded for the present days of YouTube, Internet streaming and AI.
How lovely!
Step 6: Use It: Scan and Play Your CDs
If all went well so far, the usage will be as simple as 1-2-3.
Make sure your phone has data connectivity (over WiFi or mobile data).
Usage
1. Present a CD box to your camera, until it entirely takes the square portion of the screen, and its becomes sharp. Avoid reflections from light sources.
2. Click scan.
3. Wait for YouTube to be called on a playlist matching your CD.
Step 7: Alternate Usage
Of course you do not need to use actual CD, which honestly take way too much place in a pocket.
For instance, I photocopied and laminated 16 of my favorite CDs with reduction down to 2.75", and have a handy physical surrogate collection, that fit in one pocket!
Step 8: Reliability - Excellent Performers
These CDs were exceptionally well recognized, and their playlists were found reliably.
Step 9: Reliability - Good Performers
For these CDs the end result was good, but they were more difficult to properly capture, because light reflections are more apparent.
Step 10: Reliability - Bad Performers
For these CDs, the artists were correctly recognized, but wrong albums were found.
Mostly, the image detection returned good keywords, but unexpected playlists were found.