freeswitch tts_commandline模块介绍

 

概述

freeswitch是开源、免费的VOIP软交换平台,自带了很多功能各异的模块。

mod_tts_commandline模块,本身没有TTS能力,而是通过调用TTS引擎的命令生成语音文件,tts命令可以配置,最终实现自动TTS语音播放的功能。

今天,我们介绍一下该模块的一般应用方法。

环境

centos:CentOS  release 7.0 (Final)或以上版本

freeswitch:v1.8.7

GCC:4.8.5

模块编译安装

安装text2wave依赖包,TTS引擎,免费,不支持中文,音质很差,仅供测试使用。

yum install festival

编译安装mod_tts_commandline模块。

cd ./freeswitch-1.6.19_master/src/mod/asr_tts

make

make install

生成如下文件

/usr/local/freeswitch/mod/mod_tts_commandline.so

/usr/local/freeswitch/mod/mod_tts_commandline.la

配置

fs的配置修改如下。

/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml

<load module="mod_tts_commandline"/>

/usr/local/freeswitch/conf/autoload_configs/tts_commandline.conf.xml

<param name="command" value="echo ${text} | text2wave -f ${rate} > ${file}"/>

/usr/local/freeswitch/conf/dialplan/as_dialplan.xml

<context name="public">

<extension name="sbc_out" continue="false">

<condition field="destination_number" expression="^119(\d+)$">

<action application="answer" />

<action application="speak" data="tts_commandline|pico|This is an example of using tts commandline"/>

<action application="hangup"/>

</condition>

</extension>

</context>

测试

在192.168.0.110上配置一个sip账号10012。

在192.168.0.110上配置路由,被叫号码前缀为0128的号码,转接到10.9.0.128服务器

使用10012呼叫0128119123。

10012听到语音播报“This is an example of using tts commandline”。

呼叫流程

freeswitch收到呼叫,进入dialplan。

执行speak功能,speak功能是freeswitch内置函数,代码在switch_ivr_play_say.c文件。

speak带的data中,使用tts_commandline接口实现TTS功能。

tts_commandline中调用tts_commandline.conf.xml 配置的command生成语音文件。

command命令中,使用text2wave TTS引擎生成语音文件。

speak播放tts_commandline生成的语音文件。

参考日志:

EXECUTE sofia/external/10012@192.168.0.110 speak(tts_commandline|pico|This is an example of using tts commandline)

2018-07-13 21:04:31.878645 [DEBUG] switch_ivr_play_say.c:3025 OPEN TTS tts_commandline

2018-07-13 21:04:31.878645 [DEBUG] switch_ivr_play_say.c:3035 Raw Codec Activated

2018-07-13 21:04:31.878645 [DEBUG] mod_tts_commandline.c:160 Executing: echo 'This is an example of using tts commandline' | text2wave -f 8000 > '/tmp/a250f2fa-88a7-11e8-b9e3-a16767955d71.tmp.wav'

2018-07-13 21:04:32.659240 [DEBUG] switch_ivr_play_say.c:2729 Speaking text: This is an example of using tts commandline

总结

fs的模块功能很强大,适合根据不同的客户场景来配置出对应的呼叫流程。

我们在实际应用中,可以根据自己的需要,直接修改tts_commandline配置中的“text2wave”命令名就可以实现适合自己环境的TTS呼叫流程。

空空如常

求真得真

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值