The invention discloses a method for generating music electrical stimulation for analgesia. The music that subjects like is selected, and at least three characteristics of the music, pitch, sound length and loudness, are extracted according to the playing time sequence of the music; the extracted music is The pitch, sound length and loudness characteristics of the electrical stimulation are converted into the stimulation frequency, stimulation duration and stimulation intensity parameters corresponding to the electrical stimulation respectively, forming a musical electrical stimulation with a sense of musical rhythm and rhythm; the musical electrical stimulation can be used for the subjects' It relieves pain on the surface of the skin. The invention selects the music that the subject likes, analyzes and processes the music, extracts the pitch, sound length and loudness data information representing the melody of the music, and then converts the extracted melody information into an electrical stimulation signal to act on the electrical stimulator , The electrical stimulator acts on the skin surface of the subjects, so that the electrical stimulation felt by the subjects is a signal that matches the rhythm, melody, and strength of the music, which improves the analgesic effect.