  We prove a quantitative version of Obata's Theorem involving the shape of
functions with null mean value when compared with the cosine of distance
functions from single points. The deficit between the diameters of the manifold
and of the corresponding sphere is bounded likewise. These results are obtained
in the general framework of (possibly non-smooth) metric measure spaces with
curvature-dimension conditions through a quantitative analysis of the
transport-rays decompositions obtained by the localization method.
