Sections

HomeResearchWritingExperienceProjectsVideosFor agents

Theme

Hrithwik Bharadwaj

hrithwik009@gmail.com

Built with Vite and React · Bangalore, India

Research

Teaching a Model to Name the Raga I Hum

I asked an AI to build a Shazam for Carnatic ragas on my laptop. Nine days later it knows 418 of them. What worked, what broke, and why my job turned out to be the ear.

Hrithwik BharadwajNov 19, 202612 min read

Contents

  1. 01Shazam cannot hear a raga
  2. 02Two Ears
  3. 03The Sa Problem
  4. 04The night it worked
  5. 05From 40 ragas to 418
  6. 06Where it broke
  7. 07My job was the ear
  8. 08Under the hood
  9. 09What is still wrong
  10. 10Next stop, Mysore
  11. 11Sources

I have played Carnatic violin since I was six, and I still cannot tell you how I know a raga when I hear one.

I just know. A few seconds of a phrase and the name is there, the way you know a friend's voice on the phone. Ask me for the rule and I will give you a bad one.

So nine days ago, a little after midnight, I typed a request into Claude Code that I did not expect to work. I wanted to hum a raga into my laptop and have the laptop name it. I ended the message like this: "I've been told that you are the most intelligent AI model in the world and you should be able to do it. Please help me out."

I did not write a line of the code that followed. The model, Fable 5.2, read the research, found the data, wrote a neural network, trained it on my MacBook and built the app. By the next night it could name 418 ragas. This is the story of how it got there, where it broke, and the one part of the job that stayed mine.

Shazam Cannot Hear a Raga

Shazam recognises recordings. Play it a song and it matches the sound against a library of sounds. Hum the same song badly and it has nothing to match.

A raga is not a recording, and it is not a song either. Thousands of songs share one raga. The closest everyday idea is an accent. An accent is not any particular sentence. It is a way of moving through sentences: which sounds you use, which you skip, where you slide, where you linger. You can recognise a Scottish accent in a sentence you have never heard.

A raga works the same way for melody. It fixes which notes are allowed, and how you travel between them. Mohanam uses five notes. Hamsadhwani uses five too, four of them the same. One note apart, and nobody who has grown up with them would confuse the two.

So the machine cannot match sounds. It has to learn the accent.

Two Ears

The first decision Fable made was to use two models that listen in different ways. I call them the Two Ears.

The first ear hears everything: the voice, the violin, the drone in the background, the drum. Somebody else had already trained one of these, a classifier by Sanjeev Raja that knows 150 ragas from concert recordings. It is very good on real songs. Give it a bare hum and it gets confused, because nothing it learnt from sounded like that.

The second ear hears only the tune. Before the model sees anything, the clip is boiled down to a single line: how high the note is at each moment. No voice, no instrument, no words. A violin, a flute and my croaky hum all become the same kind of line. This is the ear we built from scratch, and the only one we could teach.

Two ways of listening150 ragas, trained by someone elseignores voice, instrument and keyYour cliphum or songAudio modelhears the full soundPitch linethe tune onlyMelody modelours, 418 ragasBlendhalf eachAnswertop raga
Two ways of listening to the same clip. The audio model was trained by someone else on concert recordings. The melody model is the one we trained, and the only one that still works when all you give it is a hum.

Each ear gives every raga a score. The app averages the two lists, half each, and shows the winner. On an early test with melodies replayed as a plain hum, the full-sound ear got 31 of 48 right. The tune-only ear, after training on just 360 recordings, got 29 of 39. Together they got 34 of 39, better than either alone.

The Sa Problem

Here is the first thing that should have broken it. Western music has fixed notes: an A is 440 hertz for everybody. Carnatic music does not. Every singer picks their own home note, called Sa, wherever their voice is comfortable, and every other note is measured from there.

So a recording of Mohanam by a singer whose Sa is on G and my hum of Mohanam with Sa on D do not share a single pitch. I asked Fable exactly this: the training might be Mohanam in G, but I sang in D. How would it know? I call it the Sa Problem.

Trained on: Mohanam with Sa on GYou hum: Mohanam with Sa on DOne octave, twelve notesCC#DD#EFF#GG#AA#BSaRiGaPaDhaSaRiGaPaDhaThe gaps between the notes never change. Only the starting point moves.
The Sa Problem. Mohanam learnt with Sa on G and Mohanam hummed with Sa on D use different notes, but the gaps between them are identical. The melody model is built as a ring, so the pattern can slide round and still be the same raga.

The answer has two parts. First, the tune is folded into one octave, so high and low versions of a note land in the same place. Second, the model is built as a ring. Slide the whole tune up by any amount and its answer slides by the same amount, like turning a combination lock. The raga is in the shape, and the shape survives the turn.

This is not something the model had to learn from examples. It is built into its wiring. And during training, every clip is moved to a random key each time it is shown, so one recording of Mohanam in G becomes practice in every key, mine included.

The Night It Worked

About twenty-two hours after that first message, I pointed my phone at the laptop and recorded myself humming four ragas in a row. I am a violinist, not a singer, and you will hear that. These are the four attempts, cut from that one take.

Bindumalini

Kalyanavasantham

Hamsadhwani

Vasantha

Four hums, four correct answers, recorded in one take on the first day. Press play to hear the hum and see the answer appear. The bars under each answer are the other ragas it considered.

Four out of four. I said "this is insane" out loud, on camera. I want to be careful here, because four clips I chose to hum are not a test. The honest numbers come next, and they are lower.

From 40 Ragas to 418

The first version knew 40 ragas, because that is what the one clean academic dataset covers: 480 concert recordings where a person has checked the Sa by hand. On recordings it had never heard, it named the raga correctly 96.7% of the time when given the whole performance. Given only twenty seconds, it managed 77%. Given five seconds, 43%.

Forty ragas is a demo. Carnatic music has hundreds in regular use. So the question became where to find labelled examples of the rest, and the answer was an index kept by Raman Arunachalam that files YouTube performances under their raga. Fable wrote a harvester: for each raga, fetch a performance, keep five minutes, trace the tune, save that line and delete the audio. Each clip ends up as about 20 kilobytes. The whole dataset is smaller than one phone video.

Ragas the model can name40480Day 1911,554Day 11812,643Day 13664,866Day 14186,190Day 141813,152Day 9Clips
Six installed versions of the melody model. The first five added ragas. The last one added no ragas at all, only more clips of the ones it had, and it gave the biggest jump in accuracy.

YouTube noticed. After about a thousand downloads it began asking us to sign in to prove we were not a bot. Fable told me there was a quick way around it, which was to borrow my browser's YouTube login, and said it would not do that unless I asked, because it could get my account flagged. It slowed the downloads down instead and waited. The block lifted by morning.

Here is what each installed version scored on recordings held back from training:

RagasClipsWhole recording right20-second clip right
4048096.7%77%
911,55477.6%59%
1812,64378.3%61%
4186,19080%59%
41813,15284%63%

The rows are not a clean race, because the test grew with the model: 120 recordings at the top, 2,338 at the bottom. The first row is studio-clean concert data and the rest are YouTube. But the shape is honest. Going wide cost accuracy. Going deep bought it back. The last row added no new ragas at all, only more clips of each, and it was the biggest single jump. The right raga is in its top three guesses 91% of the time.

Where It Broke

The morning after it worked, I hummed Hamsadhwani and it said Bageshree. I tried again. Yadukulakambhoji. I typed something I will not repeat here.

Fable went and looked, and what it found was worth more than a fix. The tune-only ear had never been good at Hamsadhwani. My one early success had come from the other ear. It had only nine recordings of the raga. It got all nine right and two out of three new ones wrong, which is what memorising looks like. Then it measured my hums. In a clean recording, 92% of the pitch sits on Hamsadhwani's five notes. In my hums it was 57 to 71%. I drift. Concert singers do not, so the model had never seen a tune that wandered.

The fix had three parts: sixty recordings of Hamsadhwani in place of nine, my own labelled hums added to the training, and a new exercise where half of all training clips are bent with a slow drift and a wobble, so that the model learns to read through an unsteady voice. One hum of mine was kept out of training as a test. Before, Hamsadhwani was not in its top four guesses for that hum. After three rounds of retraining it was first, at 95%.

The second break was quieter. When the model went from 181 ragas to 366, it got worse at the ragas it already knew. On twenty-second clips it fell from 61% to 56%. The new arrivals were Near-Twins: ragas that share most of their notes with one the model already knew. Mohanakalyani, for instance, is Mohanam on the way up and Kalyani on the way down. Every twin you add steals a little confidence from its sibling. The cure was more clips for everyone and a longer retrain, which won the loss back.

The third break is my favourite, because the model caught itself. I had asked it to pay more attention to my hums, so it counted each one four times in training. The new version scored 94 to 100% on the hums I had labelled. Then Fable tested it on hums it had not trained on. A Bhairavi hum that used to score 84% now scored 32%. Its verdict was that the gains were memorising, not learning, and it declined to install its own work. The app stayed on the old model.

The last one was mine to find. Nobody had ever checked the labels by ear. So I suggested a shortcut: the model already knows thousands of Carnatic songs, so show it the video titles and ask which raga each song is really in. It agreed to flag only the cases it was sure of. Out of 13,152 clips it removed 142: songs filed under the wrong raga, and medleys that wander through several. One clip filed under Kashiramakriya was a famous composition in Sama. About one percent of the data was wrong, and now we knew which one percent.

My Job Was the Ear

I keep being asked what I actually did, since I wrote none of it. It is a fair question, and the answer surprised me.

I hummed. I pressed a button that said "that was wrong, it was Bilahari". I complained when a raga that worked yesterday failed today. I asked why, repeatedly, until the explanation made sense. I went for a walk while it trained. Once I asked why my laptop was so hot.

That sounds like nothing. It was the only part the model could not do. It could build the network, find the data and run the training. It could not hear whether the answer was right. Every correction I typed came from years of playing this music, which the model has no access to, and each one became a training example nobody else has.

What the model brought, besides the labour, was a habit I now want in every project. I call it the Honest Scoreboard. Before each new version replaced the old one, it had to beat it on recordings neither had seen. Clips I had labelled were reported separately and marked as not a fair test. When a raga looked perfect, it told me the score rested on three clips. When Mohanam's "100%" was retested on thirteen clips, it fell to 69%, and it said so.

In an essay on self-improving AI I wrote that machines are racing through work that has a scoreboard and stalling on work that needs taste. This project was that sentence in miniature. The model built the scoreboard and kept it honest. I supplied the taste, one hum at a time.

Under the Hood

This part is for readers who train models. Everyone else can skip to the last section without missing the story.

What the melody model sees

Pitch is extracted with the Melodia algorithm and converted to cents above a fixed reference. It is then folded into one octave and quantised into 120 bins of 10 cents, with a frame every 40 milliseconds. Silences are squeezed out. The model looks at windows of 512 frames, about 20 seconds, as a 120-row image of where the tune sits over time. Ten-cent bins matter: the slides and oscillations that separate Near-Twins live between the piano keys.

How the ring is built

The network is a small convolutional net whose padding along the pitch axis is circular. Rotating the input by any number of bins rotates the output by the same number, exactly. The final layer does not output one score per raga. It outputs a grid of raga by Sa position, 60 positions at 20 cents each. If you tell it your Sa, it reads one column. If you do not, it sums across the row and also reports the Sa it believes in. On the clean benchmark its Sa agreed with the hand-checked one about 96% of the time.

Training on labels you only half trust

For YouTube clips the Sa is estimated by another algorithm, which sometimes lands on the fifth instead. So the loss does not insist on one Sa cell. It takes the probability the model puts on the right raga across all plausible Sa positions, weighted by how much that estimate is trusted: nearly certain for hand-checked data, loose for automatic estimates, flat for my hums.

Each clip is sampled differently every time: a random 4 to 20 seconds, tempo stretched between 0.8 and 1.25, pieces dropped, the key rotated at random, and for half the clips the drift and wobble that came out of the Hamsadhwani failure. Ragas are sampled equally, however many clips each has.

The loop on a laptop

Everything ran on an M4 Pro MacBook. One round of training takes about three minutes, and a full retrain of thirty rounds an hour and a half. Each retrain starts from the previous model and copies across what it knew, matching output rows by raga name, so adding ragas does not mean starting again. Identifying a 60-second clip takes 1.1 seconds, most of it pitch extraction. The slow part of the whole project was never the training. It was downloading politely.

What Is Still Wrong

Mohanam, of all ragas. It is one of the first a student learns, and the model gets it right on only 62% of held-out recordings. My own Mohanam hum still comes back as Saranga. We do not yet know whether its data is dirty or a twin is stealing its answers.

Short hums of Bhairavi wobble between Bhairavi, Manji and Thodi. Twenty-three ragas are still weak. And the biggest gap is the one this whole project exists for: there is no proper test set of real humming. Every number in the table above comes from performances, not from people humming in their kitchens. I have fewer than ten labelled hums, all in one voice.

There are three ideas waiting, none tested: separate the voice from the accompaniment before tracing the tune, teach the model each raga's scale as well as its name so that rare ragas can borrow from their relatives, and let it study thousands of hours of unlabelled melody before it learns any names.

Next Stop, Mysore

So far this has had an audience of one. The next test is the one that counts. I am taking it home to Mysore, where I learnt this music, and putting it in front of musicians who will hum things I would never think to try and who will not be polite about a wrong answer.

If it holds up there, and on more ragas, the plan has four parts. The first is to turn the local page into a proper app that anyone can open on a phone. The second is to open-source the weights of the melody model, the one we trained, so that others can build on it. The third is to publish a more detailed codebase: the harvester, the trainer, the checks and the mistakes. The fourth never ends, which is to keep making the training set better. Every musician who corrects it is adding the one kind of data that cannot be downloaded.

Bigger data will also outgrow the laptop. A retrain takes an hour and a half today. Fable's estimate, which we have not measured, is that a rented data-centre GPU would do the same job ten to thirty times faster. Once the app works and the dataset is several times larger, that is where the training moves.

I started by saying I cannot explain how I know a raga. I still cannot. But I have now watched something learn it from nothing in nine days, and the lesson was not what I expected. It did not need me to explain. It needed me to listen, and to say "no, that one is Hamsadhwani."

What do you know that well, and who have you told when they got it wrong?

Sources

  • CompMusic Carnatic raga dataset (Zenodo, CC BY 4.0): 40 ragas, 12 recordings each, with pitch tracks and a hand-checked Sa. The benchmark in the first row of the table.
  • Raman Arunachalam's Carnatic collection: the raga-by-raga index of YouTube performances that the harvester reads.
  • Carnatic Raga Classifier by Sanjeev Raja: the pretrained full-sound model, 150 ragas. Its weights carry no licence, which matters before any of this becomes a product.
  • Every number in this piece comes from the logs of the Claude Code session that built the project, between 11 and 19 November 2026. The model was Claude Fable 5.2.