A snake charmer is a person who appears to make snakes (mainly cobras) rise up by playing a wind instrument called a pungi. Snake charming is most common in India though other Asian nations and some North African countries are also home to performers.
Although snakes are able to sense sound, they lack the outer ear that would enable them to hear the music. The cobra that sits up and sways to and fro is actually following the rhythmic movements of the player, who himself sways in time with the melody. The snake considers the charmer and pungi a threat and responds to it as if it were a predator. (Source The Encyclopedia of Trivia