It is actually called canting and men are specifically trained to do this using what is called a trope teacher. I think this harkens back to temple times when the Levites would sing praises or psalms for certain occasions.
Some believe that David handed down a musical alef bet, in other words, each Hebrew letter has a specific sound and combonations have one as well. This may be where todays cantilations originated.