FreeSWITCH 支持调用第三方TTS命令,自己已经搭好了框架,只须要配置便可用。session
下面写一下步骤,以避免忘记,也但愿给你带来帮助。app
第一步:编译模块mod_tts_commandline,并加载。框架
编辑源码下 modules.conf 文件,把 asr_tts/mod_tts_commandline 这一行的注释去掉。测试
而后 ./configure, make, makeinstalllua
重启FreeSWITCHspa
在CLI界面看到code
freeswitch@internal> module_exists mod_tts_commandline true
表示模块 mod_tts_commandline 加载成功。xml
第二步:修改配置文件blog
修改 freeswitch/conf/autoload_configs/tts_commandline.conf.xml ip
1 <configuration name="tts_commandline.conf" description="TextToSpeech Commandline configuration"> 2 <settings> 3 <!-- 4 Some variables will be replaced : 5 ${text}: input text (quoted) 6 ${rate}: sample rate (example: 8000) 7 ${voice}: voice_name passed to TTS(quoted) 8 ${file}: output file (quoted, including .wav extension) 9 10 Example commands can be found at: 11 http://wiki.freeswitch.org/wiki/Mod_tts_commandline#Example_commands 12 --> 13 <!--param name="command" value="echo ${text} | text2wave -f ${rate} > ${file}"/--> 14 <param name="command" value="sh /tmp/tts_test.sh ${text} ${file}"/> ----这一行是我加的,/tmp/tts_test.sh是转换的脚本
15 </settings> 16 </configuration>
<param name="command" value="sh /tmp/tts_test.sh ${text} ${file}"/>
----这一行是我加的,/tmp/tts_test.sh是转换的脚本,核心的TTS命令就写在这个脚本里面。具体的命令就不写了,能够支持科大,百度等第三方公司。
2个参数
${text} --- 要转换的文字,在后面的拨号方案中赋值
${file} --- 转换后的wav文件名字,全路径,带wav后缀,在后面的拨号方案中赋值
第三步:修改拨号方案脚本。
假如你的拨号方案会触发到lua脚本,而后在lua脚本中加入下面几行,进行测试:
1 session:answer(); 2 session:setVariable("tts_engine", "tts_commandline"); 3 session:setVariable("tts_voice", "girl"); 4 session:setVariable("file", "/tmp/justtts.wav"); 5 session:execute("speak", "欢迎您使用光大银行电子银行业务,查询余额请按一,修改密码请按二");
上面的app都比较清晰,不作过多解释。
第四步:打电话测试
当你听到声音 "欢迎您使用光大银行电子银行业务,查询余额请按一,修改密码请按二" 时,大功告成!
以上只是我的实现,可能还有其余更好的方法,欢迎在下面留言,谢谢。