  We study the connection between the $p$--Talagrand inequality and the
$q$--logarithmic Sololev inequality for conjugate exponents $p\geq 2$, $q\leq
2$ in proper geodesic metric spaces. By means of a general Hamilton--Jacobi
semigroup we prove that these are equivalent, and moreover equivalent to the
hypercontractivity of the Hamilton--Jacobi semigroup. Our results generalize
those of Lott and Villani. They can be applied to deduce the $p$-Talagrand
inequality in the sub-Riemannian setting of the Heisenberg group.
