There are a few different pieces here, each of which needs to be solved. None of them are trivial and require a decent amount of signal processing knowledge, so you'll probably want to look for libraries to handle that part of the heavy lifting.
Cardiac beat detection. This is outside my area of knowledge, but let's assume that you can access this somehow.
Music beat detection There are several libraries available for this, both commercial and open source. You may want to look at http://aubio.org/ -- it already has python bindings available.
Tempo Change -- Once you know the target BPM and the current BPM, you need another library that can be used to change the tempo of your audio track to match (without changing the pitch). A few to look at are Rubber Band and SoundTouch
Googling will find other libraries for these manipulations (and other pieces that you'll need, something like PyMedia to open and playback the sounds, etc.)