-4

I have many .wav files having heart sounds recorded through MIC by putting phone directly on people chest. I want to calculate BPM from these sounds. Could you please help regarding this? Any library,algorithm or tutorials?

Noman marwat
  • 353
  • 1
  • 18
  • 2
    [reading input sound](https://stackoverflow.com/questions/35344649/reading-input-sound-signal-using-python), [pattern detection](https://medium.com/@almeidneto/sound-pattern-recognition-with-python-9aff69edce5d) – Yevhen Kuzmovych Sep 10 '19 at 11:03
  • @YevhenKuzmovych this is irrelevant to my question – Noman marwat Sep 12 '19 at 18:49
  • @Noman-marwat the links Yevhen Kusmovych provided, especially on pattern detection, are very good resources for this type of problem. –  Sep 12 '19 at 19:10

2 Answers2

3

Can you (are you allowed to) put some sample somewhere?

I've played with some ECG (up to 12 eletrode) and neural signals (spikes look a lot similar to the R-S transition). Those spikes were so big, a simple find_peaks from scipy.signal was enough to detect them. I used a butterworth filter before that though. You might need that too, filtering out the 50/60Hz mains is common, there might be similar noises in audio as well.

After finding the peaks, beats per minute is a division (and probably some averaging).

Nyos
  • 394
  • 5
  • 13
  • I have uploaded some files to drive. you can check there. https://drive.google.com/open?id=1oFLbx0TAkWmiaaabsL1GcTFT7r_xAJBZ – Noman marwat Sep 13 '19 at 07:10
  • you might be interested to this answer and to the contained link: https://stackoverflow.com/questions/5010941/generating-a-audio-waveform-graphic-within-python – Vincenzooo Sep 16 '19 at 22:37
1

What you're trying to do is essentially calculate the fourier domain for the given sound file, and then identify the strongest peak. That's likely going to be the frequency of your dominant signal (which in this case should be the heart-rate).

Thankfully, someone else has already asked / answered this on stackoverflow.

The only caveat with this approach, is if there are other repetitive signals that dominate the heart-beat, in which case you may need to clean your data first.

Abhinav Ramakrishnan
  • 1,070
  • 12
  • 22