The horizontal-to-vertical spectral ratio (HVSR) of ambient noise has seen widespread use as a tool for measuring a site's fundamental resonant frequency (f0). However, the processing of HVSR with traditional methods can be tedious and time consuming, particularly when the HVSR is complex and exhibits multiple resonances. This work proposes the AutoHVSR algorithm that allows for the fully-automated processing of HVSR measurements including those with zero, one, or multiple clear resonances. The AutoHVSR algorithm accepts seismic wave recordings and user-defined HVSR processing parameters as input and returns the HVSR calculations, statistics on the HVSR curve, and statistics on each automatically identified HVSR resonant frequency. The AutoHVSR algorithm integrates robust signal processing and computational methods with state-of-the-art machine-learning models trained using a diverse dataset of 1109 HVSR measurements. The AutoHVSR algorithm demonstrates excellent performance by correctly determining the number of HVSR resonances for 1099 of the 1109 HVSR measurements (>99%) and predicting the mean resonant frequency of the correctly identified resonances with a root mean square error (RMSE) of 0.05 Hz. Furthermore the AutoHVSR algorithm was able to produce these predictions in 13 minutes compared to the 30 hours required for traditional processing (a speed up of 138). The AutoHVSR algorithm is further demonstrated on a challenging dataset from Canterbury, New Zealand that had been previously interpreted by a different group of analysts (i.e., disjoint from those who produced the AutoHVSR training dataset) and with the assistance of local geology and information about resonances identified nearby. Despite the challenging nature of the dataset the AutoHVSR algorithm was capably of determining 104 of the 129 HVSR measurements and predicting the mean resonant frequency of the correctly identified resonances with a RMSE below 0.05 Hz. Finally, while the AutoHVSR algorithm was developed using ambient noise measurements where the horizontal components were combined using the geometric mean it is shown to extend without modification to ambient noise HVSR measurements where the two horizontal components are rotated azimuthally and to HVSR measurements from small-strain earthquake ground motion recordings.