36 #ifdef SWITCH_HAVE_FVAD 54 #ifdef SWITCH_HAVE_FVAD 65 return "start_talking";
69 return "stop_talking";
79 if (!vad)
return NULL;
81 memset(vad, 0,
sizeof(*vad));
98 #ifdef SWITCH_HAVE_FVAD 102 if (vad->fvad) fvad_free(vad->fvad);
106 }
else if (mode > 3) {
111 vad->fvad = fvad_new();
119 ret = fvad_set_mode(vad->fvad, mode);
136 if (!strcmp(key,
"hangover_len")) {
140 }
else if (!strcmp(key,
"silence_ms")) {
146 }
else if (!strcmp(key,
"thresh")) {
148 }
else if (!strcmp(key,
"debug")) {
150 }
else if (!strcmp(key,
"voice_ms")) {
156 }
else if (!strcmp(key,
"listen_hits")) {
169 #ifdef SWITCH_HAVE_FVAD 171 fvad_reset(vad->fvad);
191 #ifdef SWITCH_HAVE_FVAD 197 int ret = fvad_process(vad->fvad, data, samples);
200 score = ret > 0 ? vad->
thresh + 100 : 0;
203 int energy = 0, j = 0,
count = 0;
205 energy += abs(data[j]);
209 score = (uint32_t) (energy / (samples / vad->
divisor));
210 #ifdef SWITCH_HAVE_FVAD 214 if (vad->
debug > 9) {
226 if (score > vad->
thresh) {
258 #ifdef SWITCH_HAVE_FVAD 259 if ((*vad)->fvad) fvad_free ((*vad)->fvad);
#define SWITCH_CHANNEL_LOG
switch_vad_state_t switch_vad_get_state(switch_vad_t *vad)
void switch_vad_reset(switch_vad_t *vad)
void switch_vad_destroy(switch_vad_t **vad)
switch_vad_state_t vad_state
int silence_samples_thresh
switch_byte_t switch_byte_t uint32_t switch_bitpack_mode_t mode
switch_vad_t * switch_vad_init(int sample_rate, int channels)
switch_vad_state_t switch_vad_process(switch_vad_t *vad, int16_t *data, unsigned int samples)
void switch_vad_set_param(switch_vad_t *vad, const char *key, int val)
const char * switch_vad_state2str(switch_vad_state_t state)
int switch_vad_set_mode(switch_vad_t *vad, int mode)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.