microfaune package

Submodules

microfaune.audio module

microfaune.audio.create_spec(data, fs, n_mels=32, n_fft=2048, hop_len=1024)

Compute the Mel spectrogram from audio data.

Parameters
  • data (array-like) – Audio data.

  • fs (int) – Sampling frequency in Hz.

  • n_mels (int) – Number of Mel bands to generate.

  • n_fft (int) – Length of the FFT window.

  • hop_len (int) – Number of samples between successive frames.

Returns

S – Array of shape (Mel bands, time) containing the spectrogram.

Return type

array-like

microfaune.audio.cut_audio(old_path, new_path, start, end)

Cut audio data to specific starting and end point and save it as a new wav file

Parameters
  • old_path (str) – Original wav file path.

  • new_path (str) – New wav file path.

  • start (float) – Desired start time of new audio in seconds.

  • end (float) – Desired end time of new audio in seconds.

microfaune.audio.load_wav(path, decimate=None)

Load audio data.

Parameters
  • path (str) – Wav file path.

  • decimate (int) – If not None, downsampling by a factor of decimate value.

Returns

S – Array of shape (Mel bands, time) containing the spectrogram.

Return type

array-like

microfaune.audio.wav2spc(wav_file, fs=44100, n_mels=40, n_fft=2048, hop_len=1024, duration=10)

Load a wav file and compute its MEL spectogram.

Parameters
  • wave_file (str) – path to a wav file.

  • fs (int) – Sampling frequency in Hz.

  • n_mels (int) – Number of Mel bands to generate.

  • n_fft (int) – Length of the FFT window.

  • hop_len (int) – Number of samples between successive frames.

  • duration (int) – Duration of the sound to consider (starting at the beginning)

Returns

spec – Array of shape (Mel bands, time) containing the spectrogram.

Return type

array-like

microfaune.detection module

Module containing models for bird song detection.

class microfaune.detection.RNNDetector(weights_file='/home/florent/projects/microfaune/microfaune/microfaune_package/microfaune/data/model_weights-20190919_220113.h5')

Bases: object

Class wrapping a rnn model

compute_features(audio_signals)

Compute features on audio signals.

Parameters

audio_signals (list) – Audio signals of possibly various lengths.

Returns

X – Features for each audio signal

Return type

list

create_model()

Create RNN model.

free_mem()

Release GPU memory.

property model

Tensorflow Keras like model

predict(X)

Predict bird presence on spectograms.

Parameters

X (array-like) – List of features on which to run the model.

Returns

  • scores (array-like) – Prediction scores of the classifier on each audio signal

  • local_scores (array-like) – Step-by-step prediction scores for each audio signal

predict_on_wav(wav_file)

Detect bird presence in wav file.

Parameters

wav_file (str) – wav file path.

Returns

  • score (float) – Prediction score of the classifier on the whole sequence

  • local_score (array-like) – Time step prediction score

microfaune.plot module

microfaune.plot.plot_audio(fs, data)

Plot audio data.

Parameters
  • data (array-like) – Audio data.

  • fs (int) – Sampling frequency in Hz.

  • Returns

  • -------

  • None

microfaune.plot.plot_spec(S)

Plot a spectrogram.

Parameters

S (array-like) – Spectrogram.

Module contents

Module for the project microfaune