-
Notifications
You must be signed in to change notification settings - Fork 2
/
feature_extract.h
45 lines (31 loc) · 972 Bytes
/
feature_extract.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef FEATURE_EXTRACT_H
#define FEATURE_EXTRACT_H
#include <cstdint>
#include <vector>
#include "pffft.h"
class FeatureExtractor {
public:
FeatureExtractor(size_t nfft=512,size_t melcount = 40,size_t sample_rate=16000,size_t lowerf=20, size_t upperf=8000,float window_len=0.03,float shift=0.01);
~FeatureExtractor();
int signal_to_mel(const int16_t * const pcm, const size_t len, uint8_t * result, const float gain);
void spectrum(const float*const pcm,float*real,float*imag);
size_t get_melcount();
void print_mel_filter();
private:
uint8_t quantize_float(const float value);
void create_mel_filter();
void create_hanning_window();
PFFFT_Setup *cfg;
float *fft_result;
float *frame;
const size_t nfft;
const size_t melcount;
const size_t sample_rate;
const size_t lowerf;
const size_t upperf;
const float shift;
const float window_len;
std::vector<float> hann;
float mel_filters[512/2+1][40];
};
#endif