Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
671f75b2
提交
671f75b2
authored
4月 03, 2019
作者:
Seven Du
提交者:
Andrey Volk
7月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11753 tweak vad test code and add debug logs
上级
6378bfc6
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
15 行删除
+31
-15
mod_dptools.c
src/mod/applications/mod_dptools/mod_dptools.c
+15
-15
switch_vad.c
src/switch_vad.c
+16
-0
没有找到文件。
src/mod/applications/mod_dptools/mod_dptools.c
浏览文件 @
671f75b2
...
...
@@ -6245,33 +6245,34 @@ SWITCH_STANDARD_APP(vad_test_function)
vad
=
switch_vad_init
(
imp
.
samples_per_second
,
imp
.
number_of_channels
);
switch_assert
(
vad
);
switch_vad_set_mode
(
vad
,
mode
);
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_
hangover_len
"
)))
{
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_
debug
"
)))
{
tmp
=
atoi
(
var
);
if
(
tmp
>
0
)
switch_vad_set_param
(
vad
,
"hangover_len"
,
tmp
);
if
(
tmp
<
0
)
tmp
=
0
;
if
(
tmp
>
1
)
tmp
=
1
;
switch_vad_set_param
(
vad
,
"debug"
,
tmp
);
}
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_thresh"
)))
{
switch_vad_set_mode
(
vad
,
mode
);
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_silence_ms"
)))
{
tmp
=
atoi
(
var
);
if
(
tmp
>
0
)
switch_vad_set_param
(
vad
,
"
thresh
"
,
tmp
);
if
(
tmp
>
0
)
switch_vad_set_param
(
vad
,
"
sicence_ms
"
,
tmp
);
}
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_
listen_hits
"
)))
{
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_
thresh
"
)))
{
tmp
=
atoi
(
var
);
if
(
tmp
>
0
)
switch_vad_set_param
(
vad
,
"
listen_hits
"
,
tmp
);
if
(
tmp
>
0
)
switch_vad_set_param
(
vad
,
"
thresh
"
,
tmp
);
}
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_
debug
"
)))
{
if
((
var
=
switch_channel_get_variable
(
channel
,
"vad_
voice_ms
"
)))
{
tmp
=
atoi
(
var
);
if
(
tmp
<
0
)
tmp
=
0
;
if
(
tmp
>
1
)
tmp
=
1
;
switch_vad_set_param
(
vad
,
"debug"
,
tmp
);
if
(
tmp
>
0
)
switch_vad_set_param
(
vad
,
"voice_ms"
,
tmp
);
}
while
(
switch_channel_ready
(
channel
))
{
...
...
@@ -6288,14 +6289,13 @@ SWITCH_STANDARD_APP(vad_test_function)
vad_state
=
switch_vad_process
(
vad
,
frame
->
data
,
frame
->
datalen
/
2
);
if
(
vad_state
==
SWITCH_VAD_STATE_START_TALKING
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"START TALKING
\n
"
);
switch_core_session_write_frame
(
session
,
frame
,
SWITCH_IO_FLAG_NONE
,
0
);
}
else
if
(
vad_state
==
SWITCH_VAD_STATE_STOP_TALKING
)
{
switch_
log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"STOP TALKING
\n
"
);
switch_
vad_reset
(
vad
);
}
else
if
(
vad_state
==
SWITCH_VAD_STATE_TALKING
)
{
switch_core_session_write_frame
(
session
,
frame
,
SWITCH_IO_FLAG_NONE
,
0
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"vad_state: %s
\n
"
,
switch_vad_state2str
(
vad_state
));
//
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "vad_state: %s\n", switch_vad_state2str(vad_state));
}
}
...
...
src/switch_vad.c
浏览文件 @
671f75b2
...
...
@@ -122,6 +122,8 @@ SWITCH_DECLARE(int) switch_vad_set_mode(switch_vad_t *vad, int mode)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"libfvad started, mode = %d
\n
"
,
mode
);
return
ret
;
#else
if
(
vad
->
debug
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"set vad mode = %d
\n
"
,
mode
);
return
0
;
#endif
}
...
...
@@ -155,6 +157,10 @@ SWITCH_DECLARE(void) switch_vad_set_param(switch_vad_t *vad, const char *key, in
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"listen_hits is deprecated, setting voice_ms to %d
\n
"
,
20
*
val
);
switch_vad_set_param
(
vad
,
"voice_ms"
,
20
*
val
);
}
if
(
vad
->
debug
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"set %s to %d
\n
"
,
key
,
val
);
}
}
SWITCH_DECLARE
(
void
)
switch_vad_reset
(
switch_vad_t
*
vad
)
...
...
@@ -167,6 +173,8 @@ SWITCH_DECLARE(void) switch_vad_reset(switch_vad_t *vad)
vad
->
vad_state
=
SWITCH_VAD_STATE_NONE
;
vad
->
voice_samples
=
0
;
vad
->
silence_samples
=
0
;
if
(
vad
->
debug
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"reset vad state
\n
"
);
}
SWITCH_DECLARE
(
switch_vad_state_t
)
switch_vad_process
(
switch_vad_t
*
vad
,
int16_t
*
data
,
unsigned
int
samples
)
...
...
@@ -199,6 +207,10 @@ SWITCH_DECLARE(switch_vad_state_t) switch_vad_process(switch_vad_t *vad, int16_t
}
#endif
if
(
vad
->
debug
>
9
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"score: %d
\n
"
,
score
);
}
// clear the STOP/START TALKING events
if
(
vad
->
vad_state
==
SWITCH_VAD_STATE_STOP_TALKING
)
{
vad
->
vad_state
=
SWITCH_VAD_STATE_NONE
;
...
...
@@ -218,10 +230,14 @@ SWITCH_DECLARE(switch_vad_state_t) switch_vad_process(switch_vad_t *vad, int16_t
// check for state transitions
if
(
vad
->
vad_state
==
SWITCH_VAD_STATE_TALKING
&&
vad
->
silence_samples
>
vad
->
silence_samples_thresh
)
{
vad
->
vad_state
=
SWITCH_VAD_STATE_STOP_TALKING
;
if
(
vad
->
debug
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"vad state STOP_TALKING
\n
"
);
}
else
if
(
vad
->
vad_state
==
SWITCH_VAD_STATE_NONE
&&
vad
->
voice_samples
>
vad
->
voice_samples_thresh
)
{
vad
->
vad_state
=
SWITCH_VAD_STATE_START_TALKING
;
if
(
vad
->
debug
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"vad state START_TALKING
\n
"
);
}
if
(
vad
->
debug
>
9
)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"vad state %s
\n
"
,
switch_vad_state2str
(
vad
->
vad_state
));
return
vad
->
vad_state
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论