mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
MERGE: OpenMethods DTMF recognition via ASR modules
This commit is contained in:
@@ -3208,6 +3208,20 @@ static switch_bool_t speech_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
static switch_status_t speech_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
|
||||
|
||||
if (switch_core_asr_feed_dtmf(sth->ah, dtmf, &flags) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Feeding DTMF\n");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_detect_speech(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
@@ -3423,6 +3437,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *
|
||||
return status;
|
||||
}
|
||||
|
||||
if ((status = switch_core_event_hook_add_recv_dtmf(session, speech_on_dtmf)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_ivr_stop_detect_speech(session);
|
||||
return status;
|
||||
}
|
||||
|
||||
switch_channel_set_private(channel, SWITCH_SPEECH_KEY, sth);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
Reference in New Issue
Block a user