码迷,mamicode.com
首页 > 其他好文 > 详细

FreeSWITCH调用第三方TTS 使用tts_commandline

时间:2019-05-23 10:59:48      阅读:450      评论:0      收藏:0      [点我收藏+]

标签:rip   tin   cli   测试   and   int   des   参数   color   

 

FreeSWITCH 支持调用第三方TTS命令,本身已经搭好了框架,只需要配置即可用。

下面写一下步骤,以免忘记,也希望给你带来帮助。

第一步:编译模块mod_tts_commandline,并加载。

             编辑源码下 modules.conf 文件,把 asr_tts/mod_tts_commandline  这一行的注释去掉。

             然后 ./configure,    make,  makeinstall

             重启FreeSWITCH

             在CLI界面看到

freeswitch@internal> module_exists mod_tts_commandline
true

表示模块 mod_tts_commandline 加载成功。

第二步:修改配置文件

             修改 freeswitch/conf/autoload_configs/tts_commandline.conf.xml      

 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都比较清晰,不做过多解释。

第四步:打电话测试

 当你听到声音 "欢迎您使用光大银行电子银行业务,查询余额请按一,修改密码请按二" 时,大功告成!

 以上只是个人实现,可能还有其他更好的方法,欢迎在下面留言,谢谢。

 

FreeSWITCH调用第三方TTS 使用tts_commandline

标签:rip   tin   cli   测试   and   int   des   参数   color   

原文地址:https://www.cnblogs.com/suiyuemanbu/p/10910518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!