This paper proposes music rhythm perception technology and music automatic classification technology, respectively, which are pattern recognition technologies for music teaching. The short-time Fourier transform is used to analyze the audio information, transform the acoustic spectrogram into a Mel spectrogram, build the convolutional neural network architecture, and process the spectrogram sequentially to realize the automatic classification of music. The music signal is preprocessed to remove noise using normalization, and a new histogram-based method is proposed to detect music rhythms by analyzing and modeling the music beat sequence. This paper uses S High School in Qujing City, Yunnan Province, China, as the research site to implement pattern recognition technology in teaching practice. The experimental class’s music scores increased from 50.18 before the experiment to 64.52, which was higher than the control class’s, with a 28.58% increase. The experimental class’s mean values in the sentence and paragraph dimensions of music rhythmic sense, the mean values of the experimental class were 0.73 and 0.65 higher than those of the control class, showing significant differences (P<0.05). All dimensions of music core literacy, except opera knowledge and general knowledge of musical instruments, also showed significant differences (P<0.05).