Getting Started

C-Library Documentation

Check out the C functions and data structures here.

How to use the library

The following example shows how to use the exposed functions. For more details, please refer to the sample apps.


// Initialize the SDK v6.x
if (krispAudioGlobalInit(workingPath) != 0) {
    std::cerr << "Failed to initialize SDK" << std::endl;
    return -1;
}

// Initialize the SDK v5.x
if (krispAudioGlobalInit(workingPath, 1) != 0) {
    std::cerr << "Failed to initialize SDK" << std::endl;
    return -1;
}

// Set the neural network model path
if (krispAudioSetModel(weightConfFilePath)) {
    std::cout << "Faied to set the weight file: " << weight_str << std::endl;
    return -1;
}


// Create audio session
KrispAudioSessionID noiseCancellerSession = krispAudioNcCreateSession(inputSampleRate, 
                                                                      outputSampleRate, 
                                                                      frameDuration, 
                                                                      modelName);
if (noiseCancellerSession == nullptr) {
    std::cerr << "Failed to create noise cancellation session for channel" << std::endl;
    return -1;
}

// For every audio frame, call this function to remove noise
krispAudioNcCleanAmbientNoiseInt16(noiseCancellerSession, 
                                   pFrameIn, 
                                   frameInSize, 
                                   pFrameOut, frameOutSize);


// Close the session and uninitalize the SDK
krispAudioNcCloseSession(noiseCancellerSession);
// Uninitalize the SDK
krispAudioGlobalDestroy();