The application of machine learning in the field of music teaching is emerging, especially in piano teaching shows obvious potential. In this paper, we propose a key touch action recognition model based on ADAG-SVM. The Gaussian kernel function is chosen to solve the problem of high-dimensional vectors in the input space and feature space of action representation. And the optimal penalty parameters as well as the kernel radius are obtained to further improve the performance of touch-key action recognition. In addition, the piano timbre feature matrix is extracted, and based on the discrete Fourier transform, a tone synthesis model with editable timbre is established to generate expressive demonstration clips to deepen the students’ understanding of tonal expressiveness. The keystroke action recognition model in this paper can predict the change of the angle of the keystroke action of the student’s fingers, and provide scientific action guidance and correction for the learners. The LSD and MSD values of piano tones generated by this paper’s algorithm are 1.52 and 492.68 respectively, which are lower than those of the comparison algorithm. At the end of teaching, the scores of the C2 class under the intervention of this paper’s machine learning method in the piano level evaluation dimension improved by 0.62-1.97 points compared with the traditional teaching C1 class. Students’ satisfaction with the piano teaching class under this paper’s method ranged from 4.35 to 4.81 points, and the overall satisfaction reached 4.59.The piano teaching method combined with machine learning significantly improved students’ keystroke skills and tonal expression.