Unlike what other people may think ventriloquists do not have the ability to do magic so their puppets can speak. Rather, what they do is they practice in front of the mirror. They make sure that their lips are slightly parted while they are smiling. They will then “throw” their voice to make it seem like the puppet is speaking.
They have to make sure that speaking will coincide with the movements that their puppets will do to make their puppet appear like they are talking and conversing with them. It can be very complicated especially for those who have never tried it before. If you want to learn how to do it, you should practice. The more that you do it, the better you will be at it.