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

    第四步:打电话测试

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

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

  • 相关阅读:
    spark streaming 入门例子
    ElasticSearch-hadoop saveToEs源码分析
    spark 资源参数调优
    spark 任务运行原理
    spark RDD底层原理
    用实例说明Spark stage划分原理
    Spark任务提交底层原理
    spark shuffle内在原理说明
    iOS 辛格尔顿
    CodeForces 22D Segments 排序水问题
  • 原文地址:https://www.cnblogs.com/suiyuemanbu/p/10910518.html
Copyright © 2011-2022 走看看