Gravitational waves have been detected from the inspiral of a binary neutron-star, GW170817, which allowed constraints to be placed on the neutron star equation of state. The equation of state can be further constrained if gravitational waves from a postmerger remnant are detected. Postmerger waveforms are currently generated by numerical-relativity simulations, which are computationally expensive. Here we introduce a hierarchical model trained on numerical-relativity simulations, which can generate reliable postmerger spectra in a fraction of a second. Our spectra have mean fitting factors of 0.95, which compares to a fitting factor of 0.93 between different numerical-relativity codes that simulate the same physical system. This method is the first step towards generating large template banks of spectra for use in postmerger detection and parameter estimation.