1、安装 tts_commandline 模块
2、配置文件修改
/usr/local/freeswitch/conf/autoload_configs/tts_commandline.conf.xml
<param name="command"
value="wget -O temp.txt http://localhost:5555/tts/tts?word=${text}MMMM${file} ; lua tts.lua ${file} ;rm -rf temp.txt"/>
或者下面的方式也可以呢
<param name="command" value="/usr/local/freeswitch/scripts/tts.sh ${file} ${text}"/>
脚本优化 怎么优化呢: 根据 用户传入的文字 直接获取 md5值 文件命名为 md5.wav
linux md5
http://blog.chinaunix.net/uid-20613650-id-3269470.html
3、配置文件生效
reload mod_tts_commandline
4、上传jar和lua
/usr/local/freeswitch/scripts/tts.lua
local file = argv[1];
session:sleep(100);
session.streamFile(file);
freeswitch.consoleLog("notice", "tts play file\n");
tts.jar
上传到任意目录
conf.xml 要和tts.jar 放在同一目录
<?xml version="1.0" encoding="UTF-8"?>
<httpServer context="/tts">
<handler>
<handler-class>TTSHander</handler-class>
<url-pattern>/tts</url-pattern>
</handler>
<handler>
<handler-class>IVRHander</handler-class>
<url-pattern>/ivr</url-pattern>
</handler>
</httpServer>
~
配置可执行文件
/usr/local/freeswitch/scripts/tts.sh
#!/bin/bash
basepath=$(cd `dirname $0`; pwd)
#cd /usr/local/freeswitch/scripts/
cd /root/tts/x64/bin/
if [ $# = 2 ];then
./ttsdemo $1 $2
fi
cd $basepath
unset basepath
5、配置TTS 引擎 科大讯飞为例 百度也可以
其中这里的路径是 科大讯飞的TTS路径 后期改的兼容好点
/root/tts/x64/bin/
我们现在用在线版
/root/tts/Linux_voice_1.109
离线版收费 或者改用百度的离线版
6、
添加环境变量
export LD_LIBRARY_PATH=:/intelruntime:.:/root/tts/Linux_voice_1.109/libs/x86:/
这里引用了 科大讯飞的一个类库
source /etc/profile
7、测试
在dialplan 添加这样一个拨号方案
<extension name="tts_testcall">
<condition field="destination_number" expression="^8888$"/>
<action application="answer"/>
<action application="set" data="tts_engine=tts_commandline"/>
<action application="set" data="tts_voice=girl"/>
<action application="speak" data="欢迎您使用光大银行电子银行业务,查询余额请按一,修改密码请按二。"/>
<action application="sleep" data="5000"/>
<action application="speak" data="等这么久都不说话,不和你玩了。拜拜。"/>
<action application="hangup"/>
</condition>
</extension>
<extension name="ivr_testcall">
<condition field="destination_number" expression="^9999$"/>
<action application="answer"/>
<action application="ivr" data="welcome"/>
</condition>
</extension>
or
<extension name="TTS">
<condition field="destination_number" expression="^5555$">
<action application="answer"/>
<action application="set" data="tts_engine=tts_commandline"/>
<action application="set" data="tts_voice=girl"/>
<action application="speak" data="DID语音呼入功能已经支持了,您可以通过DID直接拨号呼叫集团内部任意的号码.并实现低资费的国际语音话务功能"/>
<action application="speak" data="你好我现在在吃饭有问题先留言我看到后就会马上复您"/>
<action application="set" data="skip_greeting=true"/>
<action application="set" data="skip_instructions=true"/>
<action application="export" data="voicemail_alternate_greet_id=2024561000"/>
<action application="voicemail" data="default 101.200.216.xxx lance"/>
<action application="hangup"/>
</condition>
</extension>
然后登录SIP账户 拨打电话 8888 测试 TTS 9999 测试IVR
/usr/local/freeswitch/conf/autoload_configs/xml_curl.conf.xml
<binding name="ivr dialplan">
<param name="gateway-url" value="http://101.200.216.250:5555/tts/ivr?1=1" bindings="ivr"/>
</binding>
reload mod_xml_curl 生效
报错 找不到 so 解决方案
./ttsdemo: error while loading shared libraries: libmsc.so: cannot open shar
在 vim /etc/ld.so.conf
添加下面一行
include /root/tts/Linux_voice_1.109/libs/x64
/sbin/ldconfig -v
然后就可以找到这个动态库了
/vim /etc/ld.so.conf