In this talk, I will present the main results of a recent article written in collaboration with L. Ambrosio (SNS Pise), S. Honda (Tohoku University) and J. Portegies (Eindhoven University) in which we adapt a theorem of P. Bérard, G. Besson and S. Gallot to the context of metric measure spaces. The content of this theorem is the following: for any closed (i.e. compact without boundary) Riemannian manifold, there exists a family of smooth embeddings $(\Phi_t)_{t>0}$ of $M$ into a Hilbert space whose corresponding pull-back metrics $(g_t)_{t>0}$ converge to $g$ with a first-order term involving the Ricci and scalar curvatures of $(M,g)$. I will explain how this result extends to the class of compact $\mathrm{RCD}(K,N)$ spaces and present a few perspectives.