Fetal heartbeat extraction is a challenging task due to the interference from the mother's heartbeat. The fetal heartbeat is much weaker than the mother's heartbeat, and the two signals are often overlapping in frequency. This makes it difficult to identify the fetal heartbeat directly.
Sound from mother's abdomen containing both mother and fetal heartbeats
One way to extract the fetal heartbeat is to use a Wiener filter. A Wiener filter is a linear filter that is designed to minimize the mean squared error between the desired signal and the filtered signal. In the case of fetal heartbeat extraction, the desired signal is the fetal heartbeat and the filtered signal is the output of the Wiener filter, which had the mother's pure heartbeat as the input.
Mother's pure heartbeat
Below is Python code to extract the fetal heartbeat using the Wiener Filter.
Extracted fetal heartbeat