Well, that would certainly depend on what kind of pet you are talking about! Parrots and some other birds can learn to talk easily by hearing humans repeat things. Most other pets can't learn to talk the way humans do because the anatomy of their mouths and throats makes it impossible to shape sounds into words. Even chimpanzees, who are quite similar to us anatomically, cannot learn to speak with their mouths, but they can learn to speak in sign language.
You can teach a dog or cat to make vocalizations (barking or meowing for a treat) by repeating the command and rewarding the behavior when it begins to occur (in this case, a whine or chirp would be considered a beginning and would be rewarded). Beyond that, you will have to learn their language instead of teaching them yours.
A dog or cat can communicate by signalling you when they want to tell you something. For instance, my dog will tap the doorknob with his nose when he needs to relieve himself. When I hear the doorknob rattling, I know it's time to let the dog out.
Check out the links below for some pet training tips. To train any pet patience, consistency, and repetition are the keys. If you spend five minutes once or twice every day working on a single command, most dogs can master it in under a week.