Snowman  0.1.0
Public Member Functions | Friends | List of all members
snowboy::SnowboyTemplateCut Class Reference

Template cut class. More...

#include <snowboy-detect.h>

Inheritance diagram for snowboy::SnowboyTemplateCut:
Inheritance graph
[legend]

Public Member Functions

 SnowboyTemplateCut (const std::string &resource_filename)
 Default constructor. More...
 
std::string CutTemplate (const std::string &data)
 Cuts the provided sample. More...
 
int CutTemplate (const float *const data, const int array_length, float *const data_out, int *array_length_out)
 Runs enrollment on float samples. More...
 
int CutTemplate (const int16_t *const data, const int array_length, int16_t *const data_out, int *array_length_out)
 Runs enrollment on int16_t samples. More...
 
int CutTemplate (const int32_t *const data, const int array_length, int32_t *const data_out, int *array_length_out)
 Runs enrollment on int32_t samples. More...
 
bool Reset ()
 Resets the enrollment. More...
 
int SampleRate () const
 Returns the expected sample rate for audio provided to RunDetection(). More...
 
int NumChannels () const
 Returns the expected number of channels for audio provided to RunDetection(). More...
 
int BitsPerSample () const
 Returns the expected number of bits for audio provided to RunDetection(). More...
 
 ~SnowboyTemplateCut ()
 Destructor.
 

Friends

class testing::Inspector
 

Detailed Description

Template cut class.

Class that uses the voice activity detection to cut a hotword sample to size by removing all leading and trailing silence.

Constructor & Destructor Documentation

◆ SnowboyTemplateCut()

snowboy::SnowboyTemplateCut::SnowboyTemplateCut ( const std::string &  resource_filename)

Default constructor.

Constructor that takes a resource file.

Parameters
[in]resource_filenameFilename of resource file.

Member Function Documentation

◆ BitsPerSample()

int snowboy::SnowboyTemplateCut::BitsPerSample ( ) const

Returns the expected number of bits for audio provided to RunDetection().

Returns
The expected number of bits.

◆ CutTemplate() [1/4]

int snowboy::SnowboyTemplateCut::CutTemplate ( const float *const  data,
const int  array_length,
float *const  data_out,
int *  array_length_out 
)

Runs enrollment on float samples.

If NumChannels() > 1, e.g., NumChannels() == 2, then the array is as follows:

d1c1, d1c2, d2c1, d2c2, d3c1, d3c2, ..., dNc1, dNc2

where d1c1 means data point 1 of channel 1.

Parameters
[in]dataRecording to be cut.
[in]array_lengthSize of data in number of elements.
[out]data_outOutput buffer for the cut template.
[out]array_length_outPointer to variable being filled with the size of the cut template in number of elements.
Returns
0 on success, non zero on error.

◆ CutTemplate() [2/4]

int snowboy::SnowboyTemplateCut::CutTemplate ( const int16_t *const  data,
const int  array_length,
int16_t *const  data_out,
int *  array_length_out 
)

Runs enrollment on int16_t samples.

If NumChannels() > 1, e.g., NumChannels() == 2, then the array is as follows:

d1c1, d1c2, d2c1, d2c2, d3c1, d3c2, ..., dNc1, dNc2

where d1c1 means data point 1 of channel 1.

Parameters
[in]dataRecording to be cut.
[in]array_lengthSize of data in number of elements.
[out]data_outOutput buffer for the cut template.
[out]array_length_outPointer to variable being filled with the size of the cut template in number of elements.
Returns
0 on success, non zero on error.

◆ CutTemplate() [3/4]

int snowboy::SnowboyTemplateCut::CutTemplate ( const int32_t *const  data,
const int  array_length,
int32_t *const  data_out,
int *  array_length_out 
)

Runs enrollment on int32_t samples.

If NumChannels() > 1, e.g., NumChannels() == 2, then the array is as follows:

d1c1, d1c2, d2c1, d2c2, d3c1, d3c2, ..., dNc1, dNc2

where d1c1 means data point 1 of channel 1.

Parameters
[in]dataRecording to be cut.
[in]array_lengthSize of data in number of elements.
[out]data_outOutput buffer for the cut template.
[out]array_length_outPointer to variable being filled with the size of the cut template in number of elements.
Returns
0 on success, non zero on error.

◆ CutTemplate() [4/4]

std::string snowboy::SnowboyTemplateCut::CutTemplate ( const std::string &  data)

Cuts the provided sample.

Supported audio format is WAVE (with linear PCM, 8-bits unsigned integer, 16-bits signed integer or 32-bits signed integer). See SampleRate(), NumChannels() and BitsPerSample() for the required sampling rate, number of channels and bits per sample values. You are supposed to provide a full recording on each call.

Parameters
[in]dataRecording to be cut.
Returns
The provided recording with silence removed.

◆ NumChannels()

int snowboy::SnowboyTemplateCut::NumChannels ( ) const

Returns the expected number of channels for audio provided to RunDetection().

Returns
The expected number of channels.

◆ Reset()

bool snowboy::SnowboyTemplateCut::Reset ( )

Resets the enrollment.

After reset the pipeline will behave identical to a freshly constructed instance.

Returns
true on success
false on error

◆ SampleRate()

int snowboy::SnowboyTemplateCut::SampleRate ( ) const

Returns the expected sample rate for audio provided to RunDetection().

Returns
The expected samplerate.

The documentation for this class was generated from the following files: