Parrots are among the few animals (along with dolphins, whales, hummingbirds, bats, and some primates) that learn their species’ communication patterns. This means that they are able to repeat the sounds that other parrots and other animals around them make. When they are forced to live with humans, parrots repeat what their owners say.
Parrots do not have vocal cords, so sound is achieved by forcing air out across the mouth of the trachea (the tube that connects the pharynx and larynx to the lungs). Different sounds are produced by changing the depth and shape of the trachea. So, talking parrots are really whistling in different variations.