Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
28738b06
提交
28738b06
authored
4月 20, 2011
作者:
Jeff Lenk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3001 --resolve
上级
835860e7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
66 行增加
和
2 行删除
+66
-2
cepstral.conf.xml
conf/autoload_configs/cepstral.conf.xml
+12
-0
mod_cepstral.c
src/mod/asr_tts/mod_cepstral/mod_cepstral.c
+54
-2
没有找到文件。
conf/autoload_configs/cepstral.conf.xml
0 → 100644
浏览文件 @
28738b06
<configuration
name=
"cepstral.conf"
description=
"Cepstral TTS configuration"
>
<settings>
<!--
Possible encodings:
* utf-8
* us-ascii
* iso8859-1 (default)
* iso8859-15
-->
<param
name=
"encoding"
value=
"utf-8"
/>
</settings>
</configuration>
\ No newline at end of file
src/mod/asr_tts/mod_cepstral/mod_cepstral.c
浏览文件 @
28738b06
...
@@ -65,6 +65,14 @@ typedef struct {
...
@@ -65,6 +65,14 @@ typedef struct {
}
cepstral_t
;
}
cepstral_t
;
static
struct
{
char
*
encoding
;
}
globals
;
SWITCH_DECLARE_GLOBAL_STRING_FUNC
(
set_global_encoding
,
globals
.
encoding
);
/* This callback caches the audio in the buffer */
/* This callback caches the audio in the buffer */
static
swift_result_t
write_audio
(
swift_event
*
event
,
swift_event_t
type
,
void
*
udata
)
static
swift_result_t
write_audio
(
swift_event
*
event
,
swift_event_t
type
,
void
*
udata
)
{
{
...
@@ -223,7 +231,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
...
@@ -223,7 +231,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
if
(
zstr
(
text
))
{
if
(
zstr
(
text
))
{
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
swift_port_speak_file
(
cepstral
->
port
,
text
,
NULL
,
&
cepstral
->
tts_stream
,
NULL
);
swift_port_speak_file
(
cepstral
->
port
,
text
,
globals
.
encoding
,
&
cepstral
->
tts_stream
,
NULL
);
}
else
{
}
else
{
char
*
to_say
;
char
*
to_say
;
if
(
zstr
(
text
))
{
if
(
zstr
(
text
))
{
...
@@ -231,7 +239,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
...
@@ -231,7 +239,7 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
}
}
if
((
to_say
=
switch_mprintf
(
"<break time=
\"
1000ms
\"
/> %s <break time=
\"
1000ms
\"
/>"
,
text
)))
{
if
((
to_say
=
switch_mprintf
(
"<break time=
\"
1000ms
\"
/> %s <break time=
\"
1000ms
\"
/>"
,
text
)))
{
swift_port_speak_text
(
cepstral
->
port
,
to_say
,
0
,
NULL
,
&
cepstral
->
tts_stream
,
NULL
);
swift_port_speak_text
(
cepstral
->
port
,
to_say
,
0
,
globals
.
encoding
,
&
cepstral
->
tts_stream
,
NULL
);
switch_safe_free
(
to_say
);
switch_safe_free
(
to_say
);
}
}
}
}
...
@@ -401,10 +409,54 @@ static void cepstral_float_param_tts(switch_speech_handle_t *sh, char *param, do
...
@@ -401,10 +409,54 @@ static void cepstral_float_param_tts(switch_speech_handle_t *sh, char *param, do
}
}
static
switch_status_t
load_config
(
void
)
{
char
*
cf
=
"cepstral.conf"
;
switch_xml_t
cfg
,
xml
=
NULL
,
param
,
settings
;
/* Init to SWIFT default encoding */
set_global_encoding
(
SWIFT_DEFAULT_ENCODING
);
if
(
xml
=
switch_xml_open_cfg
(
cf
,
&
cfg
,
NULL
))
{
if
((
settings
=
switch_xml_child
(
cfg
,
"settings"
)))
{
for
(
param
=
switch_xml_child
(
settings
,
"param"
);
param
;
param
=
param
->
next
)
{
char
*
var
=
(
char
*
)
switch_xml_attr_soft
(
param
,
"name"
);
char
*
val
=
(
char
*
)
switch_xml_attr_soft
(
param
,
"value"
);
if
(
!
strcasecmp
(
var
,
"encoding"
))
{
if
(
!
strcasecmp
(
val
,
"utf-8"
))
{
set_global_encoding
(
SWIFT_UTF8
);
}
else
if
(
!
strcasecmp
(
val
,
"us-ascii"
))
{
set_global_encoding
(
SWIFT_ASCII
);
}
else
if
(
!
strcasecmp
(
val
,
"iso8859-1"
))
{
set_global_encoding
(
SWIFT_ISO_8859_1
);
}
else
if
(
!
strcasecmp
(
val
,
"iso8859-15"
))
{
set_global_encoding
(
SWIFT_ISO_8859_15
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Unknown value
\"
%s
\"
for param
\"
%s
\"
. Setting to default.
\n
"
,
val
,
var
);
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Param
\"
%s
\"
unknown
\n
"
,
var
);
}
}
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Open of
\"
%s
\"
failed. Using default settings.
\n
"
,
cf
);
}
if
(
xml
)
{
switch_xml_free
(
xml
);
}
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_MODULE_LOAD_FUNCTION
(
mod_cepstral_load
)
SWITCH_MODULE_LOAD_FUNCTION
(
mod_cepstral_load
)
{
{
switch_speech_interface_t
*
speech_interface
;
switch_speech_interface_t
*
speech_interface
;
memset
(
&
globals
,
0
,
sizeof
(
globals
));
load_config
();
/* Open the Swift TTS Engine */
/* Open the Swift TTS Engine */
if
(
!
(
engine
=
swift_engine_open
(
NULL
)))
{
if
(
!
(
engine
=
swift_engine_open
(
NULL
)))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to open Swift Engine."
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to open Swift Engine."
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论