This is a Java implementation of the Audio feature extraction library Sonopy by MycroftAI.
It is a lightweight library used to calculate the MFCCs of an audio signal. It implements the following audio vectorization functions:
- Power spectrogram
- Mel spectrogram
- Mel frequency cepstrum coefficient spectrogram
- Lightweight
- Tiny, readable source code
- Visualize steps in calculation
Read more about the library on https://github.com/MycroftAI/sonopy.
import me.gommeantilegit.sonopy.Sonopy;
float[] audio = {...};
float[][] powers = Sonopy.powerSpec(audio, audioWindowSize, audioWindowHop, fftSize); // static function
// Functions that depend on filterbanks values, are instance bound to avoid recalculation with same parameters
Sonopy sonopy = new Sonopy(sampleRate, audioWindowSize, audioWindowHop, fttSize, numFilters);
float[][] mels = sonopy.melSpec(audio);
float[][] mfccs = sonopy.mfccSpec(audio, numCoeffs);
float[][] filters = Sonopy.filterbanks(sampleRate, numFilters, fftLen); // Probably not ever useful
// return_parts parameter does not exist in Sonopy.mfccSpec(...) due to Java language limitations
Add the latest release jar to your classpath using your buildsystem or IDE
If there are any problems, try adding the Jetbrains Annotations library.
gradlew build
The jar will be placed in ./build/libs/