[mod_dptools]: wait_for_silence does not allow the listen_hits parameter to be a value of 0
This commit is contained in:
parent
623fecd599
commit
e51bbea7ca
|
@ -4591,7 +4591,7 @@ SWITCH_STANDARD_APP(wait_for_silence_function)
|
||||||
timeout_ms = switch_atoui(argv[3]);
|
timeout_ms = switch_atoui(argv[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thresh > 0 && silence_hits > 0 && listen_hits > 0) {
|
if (thresh > 0 && silence_hits > 0 && listen_hits >= 0) {
|
||||||
switch_ivr_wait_for_silence(session, thresh, silence_hits, listen_hits, timeout_ms, argv[4]);
|
switch_ivr_wait_for_silence(session, thresh, silence_hits, listen_hits, timeout_ms, argv[4]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2063,6 +2063,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_
|
||||||
|
|
||||||
while (switch_channel_ready(channel)) {
|
while (switch_channel_ready(channel)) {
|
||||||
|
|
||||||
|
/* reinitialize energy value per loop */
|
||||||
|
energy = 0;
|
||||||
|
|
||||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||||
|
|
||||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||||
|
@ -2102,6 +2105,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_
|
||||||
if (countdown) {
|
if (countdown) {
|
||||||
if (!--countdown) {
|
if (!--countdown) {
|
||||||
switch_channel_set_variable(channel, "wait_for_silence_timeout", "false");
|
switch_channel_set_variable(channel, "wait_for_silence_timeout", "false");
|
||||||
|
switch_channel_set_variable_printf(channel, "wait_for_silence_listenhits", "%d", listening);
|
||||||
|
switch_channel_set_variable_printf(channel, "wait_for_silence_silence_hits", "%d", silence_hits);
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "switch_ivr_wait_for_silence: SILENCE DETECTED\n");
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "switch_ivr_wait_for_silence: SILENCE DETECTED\n");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2111,9 +2116,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_
|
||||||
|
|
||||||
data = (int16_t *) read_frame->data;
|
data = (int16_t *) read_frame->data;
|
||||||
|
|
||||||
for (energy = 0, j = 0, count = 0; count < read_frame->samples; count++) {
|
/* Need to check if the read_frame is valid before attempting to get "energy" value from it */
|
||||||
energy += abs(data[j++]);
|
if (read_frame->seq) {
|
||||||
j += channels;
|
for (energy = 0, j = 0, count = 0; count < read_frame->samples; count++) {
|
||||||
|
energy += abs(data[j++]);
|
||||||
|
j += channels;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
score = (uint32_t) (energy / (read_frame->samples / divisor));
|
score = (uint32_t) (energy / (read_frame->samples / divisor));
|
||||||
|
@ -2122,7 +2130,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_
|
||||||
listening++;
|
listening++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listening > listen_hits && score < thresh) {
|
if (((listen_hits == 0) || (listening > listen_hits)) && (score < thresh)) {
|
||||||
if (!--silence_hits) {
|
if (!--silence_hits) {
|
||||||
countdown = 25;
|
countdown = 25;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue