zoukankan      html  css  js  c++  java
  • FreeSWITCH调用第三方TTS 使用tts_commandline

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

    第四步:打电话测试

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

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

  • 相关阅读:
    VS2008 环境中完美搭建 Qt 4.7.4 静态编译的调试与发布 Inchroy's Blog 博客频道 CSDN.NET
    编写可丢弃的代码
    c++ using namespace std; 海明威 博客园
    解决MySQL server has gone away
    nginx upstream 调度策略
    (2006, 'MySQL server has gone away') 错误解决 dba007的空间 51CTO技术博客
    Linux IO模型漫谈(2) 轩脉刃 博客园
    redis源码笔记 initServer 刘浩de技术博客 博客园
    MySQLdb批量插入数据
    词库的扩充百度百科的抓取你知道这些热词吗? rabbit9898 ITeye技术网站
  • 原文地址:https://www.cnblogs.com/suiyuemanbu/p/10910518.html
Copyright © 2011-2022 走看看