Second, the flute is a rather hard object, and once the cobra has bitten it a few times, it will probably learn that this is both painful and futile, and desist in future. And the cobras' biting technique also makes it easier to avoid than something like a rattlesnake. Cobras tend to bite downward from standing - the same movement as if you set your bent elbow on a table and swung your hand downward. It's slower and easier to predict. While Whit Gibbons estimates that some cobras have venom 20 times more powerful than that of a rattlesnake, judging the potency of such poisons is difficult, and the deadliness of any one bite will depend on a complex mix of factors relating both to the snake and its victim.
Many snake charmers remove the fangs from the cobras, or even excise the fang-bearing jaw bone.
This normally results in infections, which will kill the snakes. Some charmers even sew the snake's mouth shut. Furthermore, some charmers do not feed their cobras, but simply go out and catch more when their snakes die off. This is very variable, and there are, no doubt, many charmers around who do take reasonable care of their snakes, but there are many who do mistreat them grossly. I think snakes are really misunderstood.