  Quantum phase estimation is at the heart of most quantum algorithms with
exponential speedup. In this letter we demonstrate how to utilize it to compute
the dynamical response functions of many-body quantum systems. Specifically, we
design a circuit that acts as an efficient quantum generative model, providing
samples out of the spectral function of high rank observables in polynomial
time. This includes many experimentally relevant spectra such as the dynamic
structure factor, the optical conductivity or the NMR spectrum. Experimental
realization of the algorithm, apart from logarithmic overhead, requires
doubling the number of qubits as compared to a simple analog simulator.
