Pycon Tanzania 2026

Do Earthworms Make Sounds? Decoding the Vibrations of Soil Life with Python

PyCon Long Talk, 30 min Data, AI & ML Intermediate
Thursday 26 November 14:00 to 14:30 Main Hall, Binary Labs, Dar es Salaam

Have you ever wondered what goes on beneath our feet? Humans talk, lions roar, birds sing, but do the earthworms and ants living in the soil make sound too? They do, as tiny vibrations we never hear. Soil bioacoustics, an emerging field, studies these sounds to understand life underground. Piezoelectric sensors capture the vibrations, and Python turns those recordings into a measure of how alive our soil is. Along the way, this talk tackles a problem most ML engineers face: unlabelled data. Using soil sounds as a case study, you will leave with a recipe for labelling your own data with Python.

Soil is full of life we never see or hear. Earthworms, ants, larvae and other organisms move, feed and burrow, and that activity produces faint vibrations. If we can capture and interpret those vibrations, we gain a non-invasive way to check soil health without digging it up. This talk follows a real soil bioacoustics project which was tested in Rwanda, from raw vibration recordings to a working prediction service, with Python doing the heavy lifting at every stage.

We start by listening to the soil: how piezoelectric sensors on a low-cost ESP32 device record soil vibrations alongside temperature and moisture, and what that raw audio looks like when you first load it with librosa. From there, we move to the heart of the talk, labelling data that has no labels. We extract ecoacoustic features such as the bioacoustic index, spectral entropy and event density using librosa and SciPy, then label the recordings in two independent ways: a percentile threshold on an activity score with pandas, and KMeans clustering with scikit-learn. Measuring how much the two approaches agree, and keeping only the recordings where they do, produces a training set we can trust.

Next, we turn sound into images and images into predictions. The recordings are converted into mel spectrograms, and six pretrained image models are compared with TensorFlow/Keras to find the best fit for a small dataset. We then ship the model by converting it to TensorFlow Lite and serving it through a FastAPI endpoint in a Docker container on Hugging Face Spaces. The talk closes with honest lessons on what I would do differently, including the cost of rendering spectrograms as images and what it would take to run inference directly on the device.

You will leave with a reusable recipe for creating reliable labels when your dataset has none, one that applies well beyond audio. You will also get a practical introduction to audio feature extraction in Python and a clear path from a notebook experiment to a deployed model API. The talk is for anyone comfortable with Python and pandas who is curious about machine learning on real-world, messy data. No prior experience with audio or signal processing is needed.

#AI