Hmmm Im confused, is it a script you made or a request ?
The commob way of doing is to convert audio to MIDI and do the editing from this MIDI data. I already have some scripts to
split items from a MIDI track
The main advantage is you can access various very performant pitch detection software with different algorithm based on the source (chords, bass, voice etc..). Then you can clean the analyses by hand which is very nice too for exrra precision.