tracek / Ornithokrites

Automatic identification of kiwi calls from audio recordings
GNU General Public License v3.0
51 stars 15 forks source link

Ornithokrites

Ornithokrites is a transliteration of ancient Greek όρνϊθοκρίτης, meaning interpreter of flight or cries of birds. With its rather ambitious name, the program itself is a tool meant for an automatic identification of kiwi calls from low quality audio recordings. It has been designed to cope with large variations of environmental conditions and low quality of input data. For each provided audio file, the program enables detection of any kiwi calls and, in case they are present, which gender they belong to (male, female or both).

Features

Usage

Expected input are monaural (single-channel) audio files in Waveform Audio File Format (commonly known as WAV or WAVE). The following sections explain two ways of running the program: user-friendly (Web Interface) and user-hostile (install-yourself).

Web interface

If the data is stored on Amazon Web Services S3 bucket, then by far the easiest way of using the program is through a password-protected web site. This protection is necessary since only one user at a time can run the program. After providing the credentials, the user is directed to a simple web form that serves as an interface to the application. The form contains the following:

Interactive mode

The program is written in Python, which means that running it directly (either from command line or in interactive mode) requires installation of all dependent modules. Due to the dependencies between modules, their installation may prove difficult.

Batch mode - command line

Executing program with '-h' switch, i.e. ornithiokrites.py -h, will print the complete help with command line arguments explained. This mode allows batch processing of files stored on a disc.

Single-file mode - graphical user interface

If no command line arguments are provided then program will start in interactive mode. With open file dialogue user can select a single file for analysis.

How it works

After the recordings are ready following steps take place:

  1. Apply high-pass filter. This step will reduce strength of any signal below 1500 Hz. Previous experiments have demonstrated that kiwi rarely show any vocalization below this value. It also helps to eliminate bird calls which are of no interest to the user, e.g. morepork.
  2. Find Regions of Interest (ROIs), defined as any signal different than background noise. Since length of a single kiwi call is roughly constant, ROI length is fixed to one second. First onsets are found by calculating local energy of the input spectral frame and taking those above certain dynamically-assessed threshold. Then from the detected onset a delay of -0.2s is taken to compensate for possible discontinuities. End of ROI is defined as +0.8s after beginning of the onset, summing to 1s interval. The algorithm is made sensitive, since the potential cost of not including kiwi candidate in a set of ROIs is much higher then adding noise-only ROI.
  3. Reduce noise. Since ROIs are identified, Noise-Only Regions (NORs) can be estimated as anything outside ROIs (including some margin). Based on NORs spectral subtraction is performed: knowing noise spectrum we can try to eliminate noise over whole sample.
  4. Calculate Audio Features Those features will serve as a kiwi audio signature, allowing to discriminate kiwi male from female - and a kiwi from any other animals. Audio Features are calculated with Yaafe library. On its project page a complete description of above-mentioned features can be found. For each ROI following features are calculated:
    • spectral flatness
    • perceptual spread
    • spectral rolloff
    • spectral decrease
    • spectral shape statistics
    • spectral slope
    • Linear Predictive Coding (LPC)
    • Line Spectral Pairs (LSP)
  5. Perform kiwi identification. At this stage Audio Features are extracted from the recording. Based on these, a Machine Learning algorithm, that is Support Vector Machine (SVM), will try to classify ROI as kiwi male, kiwi female and not a kiwi. Additional rules are then applied, employing our knowledge on repetitive character of kiwi calls. Only in case a sufficiently long set of calls is identified, the kiwi presence is marked.
  6. Report. Algorithm output can be: female, male, male and female and no kiwi detected.

Dependencies

Following libraries are used by Ornithokrites:

Acknowledgements

I wish to thank Barry Polley for providing this utmost interesting challenge and his assistance along the way. My great appreciation also goes to Pat Miller of BirdingNZ.net community that supplied me with invaluable help concerning kiwi identification; without his aid I would not be able to achieve such high accuracy.