Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
4e74ef39
提交
4e74ef39
authored
7月 19, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-5573 --resolve
上级
453cfaaf
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
58 行增加
和
27 行删除
+58
-27
switch_ivr.h
src/include/switch_ivr.h
+12
-0
mod_dptools.c
src/mod/applications/mod_dptools/mod_dptools.c
+2
-0
switch_ivr_async.c
src/switch_ivr_async.c
+44
-27
没有找到文件。
src/include/switch_ivr.h
浏览文件 @
4e74ef39
...
...
@@ -184,6 +184,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_detect_speech(switch_core_se
switch_input_args_t
*
args
);
/*!
\brief Initialize background Speech detection on a session, so that parameters can be set, and grammars loaded.
After calling this function, it is possible to call switch_ivr_set_param_detect_speech() to set recognition parameters.
Calling switch_ivr_detect_speech_load_grammar() starts the speech recognition.
\param session the session to attach
\param mod_name the module name of the ASR library
\param dest the destination address
\param ah an ASR handle to use (NULL to create one)
\return SWITCH_STATUS_SUCCESS if all is well
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_ivr_detect_speech_init
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
const
char
*
dest
,
switch_asr_handle_t
*
ah
);
/*!
\brief Engage background Speech detection on a session
\param session the session to attach
...
...
src/mod/applications/mod_dptools/mod_dptools.c
浏览文件 @
4e74ef39
...
...
@@ -445,6 +445,8 @@ SWITCH_STANDARD_APP(detect_speech_function)
switch_ivr_detect_speech_disable_grammar
(
session
,
argv
[
1
]);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"grammarsalloff"
))
{
switch_ivr_detect_speech_disable_all_grammars
(
session
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"init"
))
{
switch_ivr_detect_speech_init
(
session
,
argv
[
1
],
argv
[
2
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"pause"
))
{
switch_ivr_pause_detect_speech
(
session
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"resume"
))
{
...
...
src/switch_ivr_async.c
浏览文件 @
4e74ef39
...
...
@@ -4198,9 +4198,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_all_grammars(sw
return
SWITCH_STATUS_FALSE
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_ivr_detect_speech
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
const
char
*
grammar
,
const
char
*
name
,
const
char
*
dest
,
switch_asr_handle_t
*
ah
)
SWITCH_DECLARE
(
switch_status_t
)
switch_ivr_detect_speech_init
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
const
char
*
dest
,
switch_asr_handle_t
*
ah
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_status_t
status
;
...
...
@@ -4210,9 +4209,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *
const
char
*
p
;
char
key
[
512
]
=
""
;
switch_core_session_get_read_impl
(
session
,
&
read_impl
);
switch_snprintf
(
key
,
sizeof
(
key
),
"%s/%s/%s/%s"
,
mod_name
,
grammar
,
name
,
dest
);
if
(
sth
)
{
/* Already initialized */
return
SWITCH_STATUS_SUCCESS
;
}
if
(
!
ah
)
{
if
(
!
(
ah
=
switch_core_session_alloc
(
session
,
sizeof
(
*
ah
))))
{
...
...
@@ -4220,32 +4220,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *
}
}
if
(
sth
)
{
if
(
switch_core_asr_load_grammar
(
sth
->
ah
,
grammar
,
name
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Error loading Grammar
\n
"
);
switch_ivr_stop_detect_speech
(
session
);
return
SWITCH_STATUS_FALSE
;
}
if
((
p
=
switch_channel_get_variable
(
channel
,
"fire_asr_events"
))
&&
switch_true
(
p
))
{
switch_set_flag
(
sth
->
ah
,
SWITCH_ASR_FLAG_FIRE_EVENTS
);
}
return
SWITCH_STATUS_SUCCESS
;
}
switch_core_session_get_read_impl
(
session
,
&
read_impl
);
if
((
status
=
switch_core_asr_open
(
ah
,
mod_name
,
"L16"
,
read_impl
.
actual_samples_per_second
,
dest
,
&
flags
,
switch_core_session_get_pool
(
session
)))
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_asr_load_grammar
(
ah
,
grammar
,
name
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Error loading Grammar
\n
"
);
switch_core_asr_close
(
ah
,
&
flags
);
return
SWITCH_STATUS_FALSE
;
}
}
else
{
switch_core_session_get_pool
(
session
)))
!=
SWITCH_STATUS_SUCCESS
)
{
return
status
;
}
...
...
@@ -4258,6 +4239,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *
switch_set_flag
(
ah
,
SWITCH_ASR_FLAG_FIRE_EVENTS
);
}
switch_snprintf
(
key
,
sizeof
(
key
),
"%s/%s/%s/%s"
,
mod_name
,
NULL
,
NULL
,
dest
);
if
((
status
=
switch_core_media_bug_add
(
session
,
"detect_speech"
,
key
,
speech_callback
,
sth
,
0
,
SMBF_READ_STREAM
|
SMBF_NO_PAUSE
,
&
sth
->
bug
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_core_asr_close
(
ah
,
&
flags
);
...
...
@@ -4274,6 +4257,40 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_ivr_detect_speech
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
const
char
*
grammar
,
const
char
*
name
,
const
char
*
dest
,
switch_asr_handle_t
*
ah
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_status_t
status
;
struct
speech_thread_handle
*
sth
=
switch_channel_get_private
(
channel
,
SWITCH_SPEECH_KEY
);
const
char
*
p
;
if
(
!
sth
)
{
/* No speech thread handle available yet, init speech detection first. */
if
((
status
=
switch_ivr_detect_speech_init
(
session
,
mod_name
,
dest
,
ah
))
!=
SWITCH_STATUS_SUCCESS
)
{
return
status
;
}
/* Fetch the new speech thread handle */
if
(
!
(
sth
=
switch_channel_get_private
(
channel
,
SWITCH_SPEECH_KEY
)))
{
return
SWITCH_STATUS_FALSE
;
}
}
if
(
switch_core_asr_load_grammar
(
sth
->
ah
,
grammar
,
name
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Error loading Grammar
\n
"
);
switch_ivr_stop_detect_speech
(
session
);
return
SWITCH_STATUS_FALSE
;
}
if
((
p
=
switch_channel_get_variable
(
channel
,
"fire_asr_events"
))
&&
switch_true
(
p
))
{
switch_set_flag
(
sth
->
ah
,
SWITCH_ASR_FLAG_FIRE_EVENTS
);
}
return
SWITCH_STATUS_SUCCESS
;
}
struct
hangup_helper
{
char
uuid_str
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
switch_bool_t
bleg
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论