-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvad.h
More file actions
49 lines (37 loc) · 1.36 KB
/
Copy pathvad.h
File metadata and controls
49 lines (37 loc) · 1.36 KB
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
46
47
48
49
#ifndef _VAD_H
#define _VAD_H
#include <stdio.h>
/* TODO: add the needed states */
typedef enum {ST_UNDEF=0, ST_SILENCE, ST_VOICE, ST_INIT} VAD_STATE;
/* Return a string label associated to each state */
const char *state2str(VAD_STATE st);
/* TODO: add the variables needed to control the VAD
(counts, thresholds, etc.) */
typedef struct {
VAD_STATE state;
float sampling_rate;
unsigned int frame_length;
float last_feature; /* for debuggin purposes */
} VAD_DATA;
/* Call this function before using VAD:
It should return allocated and initialized values of vad_data
sampling_rate: ... the sampling rate */
VAD_DATA *vad_open(float sampling_rate);
/* vad works frame by frame.
This function returns the frame size so that the program knows how
many samples have to be provided */
unsigned int vad_frame_size(VAD_DATA *);
/* Main function. For each 'time', compute the new state
It returns:
ST_UNDEF (0) : undefined; it needs more frames to take decission
ST_SILENCE (1) : silence
ST_VOICE (2) : voice
x: input frame
It is assumed the length is frame_length */
VAD_STATE vad(VAD_DATA *vad_data, float *x);
/* Free memory
Returns the state of the last (undecided) states. */
VAD_STATE vad_close(VAD_DATA *vad_data);
/* Print actual state of vad, for debug purposes */
void vad_show_state(const VAD_DATA *, FILE *);
#endif