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

    第四步:打电话测试

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

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

  • 相关阅读:
    任务信息的高级选项(Project)
    延时间隔(Project)
    在【自定义列】中使用M函数(Power Query 之 M 语言)
    在对话框中设置前置任务(Project)
    前置任务(Project)
    拖动条形图设置任务关联(Project)
    2020最新移动,联通,电信号码正则
    2019最新移动,联通,电信号码正则
    原生js判断手机端页面滚动停止
    win10下vue-devtools的安装和使用
  • 原文地址:https://www.cnblogs.com/suiyuemanbu/p/10910518.html
Copyright © 2011-2022 走看看