When you get an ultrasound during pregnancy, one of the things the doctor or tech will check is your baby’s heartbeat using something called “Doppler ultrasound”. Depending on the type of check-up you get, the ultrasound image they give you might include the heartbeat printed on it as a “waveform” – an image that shows the beats over time.
But, although they might play the heartbeat so you can hear it, they probably won’t give you it in an MP3 that you can listen to easily.
However, there is a way to convert the waveform into a sound on your own computer that you can save for yourself or send to friends and family. This will take a little bit of effort, but I’ll walk through it step-by-step. This can be done entirely with free software.
A couple of important notes before we start: This heartbeat sound cannot be used for medical diagnosis – we’re talking about an ultrasound measurement of a heart, turned into a picture, printed out, scanned again, edited, turned into a sound, and then edited again. There are so many possible sources of error that medically important details could be lost or changed. This is solely about creating a keepsake to remind you of your pregnancy and let you share it. If you’re concerned about the heartbeat, please talk to your doctor.
What you’ll need
- An ultrasound image with the waveform of the doppler heartbeat printed on it (like this)
- Either the length of the doppler recording (this might be printed on the ultrasound) or beats per minute (BPM) of your baby’s heart (this may be printed in the report your doctor gave you). If you don’t know, use this table to estimate the fetal heart rate.
- GIMP. This is free image editing software you can download here. If you have Photoshop, that will work great too.
- GNU Octave. This is free data processing software you can download here
- Audacity. This is free sound editing software you can download here
Step 1: Cleaning up the doppler heartbeat
The first thing to do is to scan the ultrasound image into the computer. If you have a scanner, that will give you better image quality than just using a smartphone camera – be sure to turn the DPI (dots per inch) up for a better scan. If all you have is a phone, get a large, sharp image and try putting the ultrasound under glass to keep it flat.
Obviously if the clinic has sent you the ultrasound by email, you can skip the scanning step.
Next, open the ultrasound in GIMP. To demonstrate the process, I’ll be using this image from Wikimedia Commons by Nevit Dilmen (CC-BY-SA).
The first thing to do is to cut the image down to just the top half of the doppler. To do this, use the “Rectangle Select Tool” to draw a rectangle around the waveform, then on the “Image” menu at the top, click “Crop to selection”.
There may be bits of noise and numbers printed on the screen. You can clean these up a bit using the “Paintbrush” tool.
Next, on the “Colour” menu, select “Saturation” and turn it down to zero. This will make sure the image is in black and white. Then again under “Colour”, select “Curves”. What we want to do is to make it so the top half is solid black, and the bottom half is solid white. Play with the curves until you get this – the curve should be something like this.
Now the magic happens. Go to the “Filters” menu, and under “Edge-Detect” you’ll find “Edge…”. Turn “Amount” as low as it will go, and click OK. You should now have a nice wavy line on the screen, probably surrounded by few weird dots – clean these up with the paintbrush, and make sure the top and bottom edges of the image are black.
Once you have a nice clean curve, go to “File” and “Export As…”. Give it the name “Heartbeat.tif” (the .tif is important!) and Save. (If another window pops up after you save, just click “OK” without changing any options)
Step 2: Turning the heartbeat into a sound
Now open GNU Octave. I’ll mostly be using this excellent code by Patrick Feaster – the only change is to use an up-to-date sound writing function.
Before starting, make sure you know where Heartbeat.tif is saved on your computer – the “path”. This guide will show you how to find the path on Windows 10.
Copy these lines into Octave (make sure you replace “path of Heartbeat.tif” with its actual path! You can also change the path of “Heartbeat.wav” in the last line to change where it saves to):
F=imread("[path of Heartbeat.tif]");
This will do all the maths and turn that into a sound! We’re almost there now! The only problem is that the software doesn’t know how much time that image corresponds to – if you open it now, it might just sound like a weird short buzz. That is something we can fix in Audacity.
Step 3: Clean up the heartbeat sound file
In Audacity, open Heartbeat.wav. You should see something like this.
Scroll to the end of the sound, and check how long it is. This one for example is 0.080 seconds long. If ultrasound picture has the length of the doppler recording in seconds printed on it, you can quickly find out how much to speed the file up by dividing the length of the clip by that number. This gives us the “speed multiplier”. This ultrasound shows the time the recording took was 4 seconds, so we want to divide 0.080 by 4. You can type 0.080/4 into Google to get that answer fast – it’s 0.02.
If you don’t know how long the doppler recording was, you’ll need the BPM to get that number. Count the number of beats you can see in the clip, and multiply it by the BPM, then divide it by 60. That will tell you how the recording was. Again, divide the length of your clip in Audacity by the real recording length to get the speed multiplier.
Then in Audacity press Ctrl + A, to select the whole sound clip, and on the “Effects” menu, click on “Change Speed”. In the Speed Multiplier field, type in that number, and click OK. The heartbeat is now ready to play! The sound will probably be very quiet, so turn up the gain – the little volume slider on the left of the track – here to make it louder.
You can export it as an MP3 by opening the “File” menu and clicking “Export” and “Export as MP3”. You should have something that sounds like this.
This can then be saved to your phone, or sent to friends and family on services like Facebook Messenger and WhatsApp.
I hope that’s helped – if you have any questions, leave a comment below.