A pitch detection algorithm is a way of estimating the pitch or fundamental frequency of an audio signal. This method allows to use a pre-trained machine learning pitch detection model to estimate the pitch of sound file.
Quickstart :
const audioContext = new AudioContext();
// const MicStream = MicStream
const pitch = ml5.pitchDetection(
'./model/',
audioContext,
MicStream,
modelLoaded,
);
// When the model is loaded
function modelLoaded() {
console.log('Model Loaded!');
}
pitch.getPitch((err, frequency) => {
console.log(frequency);
});
Usage :
Initialize :
const detector = ml5.pitchDetection(model, audioContext, stream, callback);
Parameters :
* model : REQUIRED. The path to the trained model. Only CREPE is available for now. Case insensitive.
* audioContext : REQUIRED. The browser audioContext to use.
* stream MediaStream : REQUIRED. The media stream to use.
* callback : Optional. A callback to be called once the model has loaded. If no callback is provided, it will return a promise that will be resolved once the model has loaded.