Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
410e523c
提交
410e523c
authored
1月 05, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for configurable timeout and passing of args to play_and_detect_speech
上级
e185ff00
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
45 行增加
和
15 行删除
+45
-15
switch_ivr.h
src/include/switch_ivr.h
+9
-4
mod_dptools.c
src/mod/applications/mod_dptools/mod_dptools.c
+1
-1
switch_ivr_async.c
src/switch_ivr_async.c
+35
-10
没有找到文件。
src/include/switch_ivr.h
浏览文件 @
410e523c
...
...
@@ -162,13 +162,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
\param mod_name the module name of the ASR library
\param grammar the grammar text, URI, or local file name
\param result of speech recognition, allocated from the session pool
\param input_timeout time to wait for input
\param args arguements to pass for callbacks etc
\return SWITCH_STATUS_SUCCESS if all is well
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_ivr_play_and_detect_speech
(
switch_core_session_t
*
session
,
const
char
*
file
,
const
char
*
mod_name
,
const
char
*
grammar
,
char
**
result
);
const
char
*
file
,
const
char
*
mod_name
,
const
char
*
grammar
,
char
**
result
,
uint32_t
input_timeout
,
switch_input_args_t
*
args
);
/*!
\brief Engage background Speech detection on a session
...
...
src/mod/applications/mod_dptools/mod_dptools.c
浏览文件 @
410e523c
...
...
@@ -495,7 +495,7 @@ SWITCH_STANDARD_APP(play_and_detect_speech_function)
char
*
engine
=
argv
[
0
];
char
*
grammar
=
argv
[
1
];
char
*
result
=
NULL
;
switch_ivr_play_and_detect_speech
(
session
,
file
,
engine
,
grammar
,
&
result
);
switch_ivr_play_and_detect_speech
(
session
,
file
,
engine
,
grammar
,
&
result
,
0
,
NULL
);
switch_channel_set_variable
(
channel
,
"detect_speech_result"
,
result
);
}
else
{
/* bad input */
...
...
src/switch_ivr_async.c
浏览文件 @
410e523c
...
...
@@ -3220,11 +3220,17 @@ static switch_status_t play_and_detect_input_callback(switch_core_session_t *ses
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_ivr_play_and_detect_speech
(
switch_core_session_t
*
session
,
const
char
*
file
,
const
char
*
mod_name
,
const
char
*
grammar
,
char
**
result
)
SWITCH_DECLARE
(
switch_status_t
)
switch_ivr_play_and_detect_speech
(
switch_core_session_t
*
session
,
const
char
*
file
,
const
char
*
mod_name
,
const
char
*
grammar
,
char
**
result
,
uint32_t
input_timeout
,
switch_input_args_t
*
args
)
{
switch_status_t
status
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
int
recognizing
=
0
;
switch_input_args_t
args
=
{
0
};
switch_input_args_t
my
args
=
{
0
};
play_and_detect_speech_state_t
state
=
{
0
,
""
};
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
...
...
@@ -3232,6 +3238,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_se
goto
done
;
}
if
(
!
input_timeout
)
input_timeout
=
5000
;
if
(
!
args
)
{
args
=
&
myargs
;
}
/* start speech detection */
if
(
switch_ivr_detect_speech
(
session
,
mod_name
,
grammar
,
grammar
,
NULL
,
NULL
)
!=
SWITCH_STATUS_SUCCESS
)
{
goto
done
;
...
...
@@ -3239,10 +3251,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_se
recognizing
=
1
;
/* play the prompt, looking for detection result */
args
.
input_callback
=
play_and_detect_input_callback
;
args
.
buf
=
&
state
;
args
.
buflen
=
sizeof
(
state
);
status
=
switch_ivr_play_file
(
session
,
NULL
,
file
,
&
args
);
args
->
input_callback
=
play_and_detect_input_callback
;
args
->
buf
=
&
state
;
args
->
buflen
=
sizeof
(
state
);
status
=
switch_ivr_play_file
(
session
,
NULL
,
file
,
args
);
if
(
args
->
dmachine
&&
(
switch_ivr_dmachine_get_match
(
args
->
dmachine
)
||
switch_ivr_dmachine_get_failed_digits
(
args
->
dmachine
)))
{
state
.
done
=
1
;
goto
done
;
}
if
(
status
!=
SWITCH_STATUS_BREAK
&&
status
!=
SWITCH_STATUS_SUCCESS
)
{
goto
done
;
}
...
...
@@ -3252,7 +3270,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_se
switch_ivr_detect_speech_start_input_timers
(
session
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_INFO
,
"(%s) WAITING FOR RESULT
\n
"
,
switch_channel_get_name
(
channel
));
while
(
!
state
.
done
&&
switch_channel_ready
(
channel
))
{
status
=
switch_ivr_sleep
(
session
,
5000
,
SWITCH_FALSE
,
&
args
);
status
=
switch_ivr_sleep
(
session
,
input_timeout
,
SWITCH_FALSE
,
args
);
if
(
args
->
dmachine
&&
(
switch_ivr_dmachine_get_match
(
args
->
dmachine
)
||
switch_ivr_dmachine_get_failed_digits
(
args
->
dmachine
)))
{
state
.
done
=
1
;
goto
done
;
}
if
(
status
!=
SWITCH_STATUS_BREAK
&&
status
!=
SWITCH_STATUS_SUCCESS
)
{
goto
done
;
}
...
...
@@ -3268,9 +3292,10 @@ done:
*
result
=
state
.
result
;
if
(
!
state
.
done
)
{
return
SWITCH_STATUS_FALSE
;
status
=
SWITCH_STATUS_FALSE
;
}
return
SWITCH_STATUS_SUCCESS
;
return
status
;;
}
struct
speech_thread_handle
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论