Every word w in a free group naturally induces a probability measure on every compact group G. For example, if w = [x, y] is the commutator word, a random element sampled by the w-measure is given by the commutator [g, h] of two independent, Haar-random elements of G. Back in 1896, Frobenius showed that if G is a finite group and ψ an irreducible character, then the expected value of ψ ([g, h]) is 1 ψ(e) . This is true for any compact group, and completely determines the [x, y]-measure on these groups. An analogous result holds with the commutator word replaced by any surface word.We prove a converse to this theorem: if w induces the same measure as [x, y] on every compact group, then, up to an automorphism of the free group, w is equal to [x, y]. The same holds when [x, y] is replaced by any surface word.The proof relies on the analysis of word measures on unitary groups and on orthogonal groups, which appears in separate papers, and on new analysis of word measures on generalized symmetric groups that we develop here.