Baking soda has many uses and carpet deodorizer is one of them. Put two cups of baking soda in a jar (you can add a few drops of your favorite essential oils if you want). Either make holes in the jar lid or cut the top from a discarded salt container and place it on the jar before screwing on the top of a canning jar. The spout will make it easy to sprinkle the baking soda.
Sprinkle on the carpet and leave overnight. Vacuum the following day.