lib_vnr feature extraction API Functions#

group vnr_features_api

Functions

void vnr_input_state_init(vnr_input_state_t *input_state)#

Initialise previous frame samples buffer that is used when creating an input frame for processing through the VNR estimator.

This function should be called once at device startup.

Parameters:
  • input_state[inout] pointer to the VNR input state structure

void vnr_form_input_frame(vnr_input_state_t *input_state, bfp_complex_s32_t *X, complex_s32_t X_data[VNR_FD_FRAME_LENGTH], const int32_t new_x_frame[VNR_FRAME_ADVANCE])#

Create the input frame for processing through the VNR estimator.

This function takes in VNR_FRAME_ADVANCE new samples, combines them with previous frame’s samples to form a VNR_PROC_FRAME_LENGTH samples input frame of time domain data, and outputs the DFT spectrum of the input frame. The DFT spectrum is output in the BFP structure and data memory provided by the user.

The frequency spectrum output from this function is processed through the VNR feature extraction stage.

If sharing the DFT spectrum calculated in some other module, vnr_form_input_frame() is not needed.

Example

#include "vnr_features_api.h"
complex_s32_t DWORD_ALIGNED input_frame[VNR_FD_FRAME_LENGTH];
bfp_complex_s32_t X;
vnr_form_input_frame(&vnr_input_state, &X, input_frame, new_data);

Parameters:
  • input_state[inout] pointer to the VNR input state structure

  • X[out] pointer to a variable of type bfp_complex_s32_t that the user allocates. The user doesn’t need to initialise this bfp variable. After this function, X is updated to point to the DFT output spectrum and can be passed as input to the feature extraction stage.

  • X_data[out] pointer to VNR_FD_FRAME_LENGTH values of type complex_s32_t that the user allocates. After this function, the DFT spectrum values are written to this array, and X->data points to X_data memory.

  • new_x_frame[in] Pointer to VNR_FRAME_ADVANCE new time domain samples

void vnr_feature_state_init(vnr_feature_state_t *feature_state)#

Initialise the state structure for the VNR feature extraction stage.

This function is called once at device startup.

Parameters:
  • feature_state[inout] pointer to the VNR feature extraction state structure

void vnr_extract_features(vnr_feature_state_t *vnr_feature_state, bfp_s32_t *feature_patch, int32_t feature_patch_data[VNR_PATCH_WIDTH * VNR_MEL_FILTERS], const bfp_complex_s32_t *X)#

Extract features.

This function takes in DFT spectrum of the VNR input frame and does the feature extraction. The features are written to the feature_patch BFP structure and feature_patch_data memory provided by the user. The feature output from this function are passed as input to the VNR inference engine.

Parameters:
  • vnr_feature_state[inout] Pointer to the VNR feature extraction state structure

  • feature_patch[out] Pointer to the bfp_s32_t structure allocated by the user. The user doesn’t need to initialise this BFP structure before passing it to this function. After this function call feature_patch will be updated and will point to the extracted features. It can then be passed to the inference stage.

  • feature_patch_data[out] Pointer to the VNR_PATCH_WIDTH * VNR_MEL_FILTERS int32_t values allocated by the user. The extracted features will be written to the feature_patch_data array and the BFP structure’s feature_patch->data will point to this array.

lib_vnr inference engine API Functions#

group vnr_inference_api

Functions

int32_t vnr_inference_init()#

Initialise the inference_engine object and load the VNR model into the inference engine.

This function calls lib_tflite_micro functions to initialise the inference engine and load the VNR model into it. It is called once at startup. The memory required for the inference engine object as well as the tensor arena size required for inference is statically allocated as global buffers in the VNR module. The VNR model is compiled as part of the VNR module.

void vnr_inference(float_s32_t *vnr_output, bfp_s32_t *features)#

Run model prediction on a feature patch.

This function invokes the inference engine. It takes in a set of features corresponding to an input frame of data and outputs the VNR prediction value. The VNR output is a single value ranging between 0 and 1 returned in float_s32_t format, with 0 being the lowest SNR and 1 being the strongest possible SNR in speech compared to noise.

Parameters:
  • vnr_output[out] VNR prediction value.

  • features[in] Input feature vector. Note that this is not passed as a const pointer and the feature memory is overwritten as part of the inference computation.