下载cepstral声音文件
# 进入/opt目录
cd /opt
# 下载声音文件
wgethttps://www.cepstral.com/downloads/installers/linux64/Cepstral_David-8kHz_x86-64-linux_6.0.1.tar.gz
解压缩
tar -xf Cepstral_David-8kHz_x86-64-linux_6.0.1.tar.gz
安装
cd Cepstral_David-8kHz_x86-64-linux_6.0.1
./install
配置环境变量
#该环境变量我们可以写在profile中使永久生效,注意运行FreeSWITCH必须要有该环境变量,否则会没有声音
export SWIFT_HOME=/opt/swift
配置库
添加 /opt/swift/lib 到 /etc/ld.so.conf文件末尾,然后执行ldconfig命令
ldconfig
编译
编辑模块配置文件
进入FreeSWITCH源码目录,编辑modules.conf文件,将asr_tts/mod_cepstral取消注释。注意该模块不能和mod_flite同时使用,会有冲突。
编译安装
make mode_cepstal-install
使FreeSWITCH启动时加载模块
编辑/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml模块加载配置文件,将mod_cepstral取消注释,这样启动FreeSWITCH时候就可以直接加载模块了。
重启FreeSWITCH
启动FreeSWITCH,查看下模块的运行状态
freeswitch@debianh61> module_exists mod_cepstral
true
测试
在Dialplan中添加一个分机,当拨打8888时候会匹配这个分机,执行tts语音放音。
<extension name="tts-test">
<condition field="destination_number" expression="^8888$">
<action application="speak" data="cepstral|david|Please hold while we connect you to the conference"/>
</condition>
</extension>
拨打8888进行测试
日志如下
freeswitch@debianh61> 2025-04-06 16:21:39.444651 99.83% [NOTICE] switch_channel.c:1142 New Channel sofia/internal/1000@192.168.0.38 [a05ada2c-b38d-4132-9b82-6f41429e39e6]
2025-04-06 16:21:39.444651 99.83% [INFO] sofia.c:10460 sofia/internal/1000@192.168.0.38 receiving invite from 192.168.0.11:48330 version: 1.10.12-release git a88d069 2024-08-02 21:02:27Z 64bit call-id: y6v2EMw-s6
2025-04-06 16:21:39.484616 99.83% [INFO] sofia.c:10460 sofia/internal/1000@192.168.0.38 receiving invite from 192.168.0.11:48330 version: 1.10.12-release git a88d069 2024-08-02 21:02:27Z 64bit call-id: y6v2EMw-s6
2025-04-06 16:21:39.484616 99.83% [INFO] mod_dialplan_xml.c:639 Processing 1000 <1000>->8888 in context default
2025-04-06 16:21:39.484616 99.83% [INFO] switch_core_session.c:2793 Sending early media
2025-04-06 16:21:39.484616 99.83% [WARNING] switch_core_media.c:4155 NO candidate ACL defined, Defaulting to wan.auto
2025-04-06 16:21:39.484616 99.83% [INFO] switch_core_media.c:8841 Activating Audio ICE
2025-04-06 16:21:39.484616 99.83% [NOTICE] switch_rtp.c:5006 Activating RTP audio ICE: f671b4df:o4JLEnbc0csewDqS 27.213.30.131:22917
2025-04-06 16:21:39.484616 99.83% [INFO] switch_core_media.c:8892 Skipping RTCP ICE (Same as RTP)
2025-04-06 16:21:39.484616 99.83% [NOTICE] sofia_media.c:90 Pre-Answer sofia/internal/1000@192.168.0.38!
EXECUTE [depth=0] sofia/internal/1000@192.168.0.38 speak(cepstral|david|Please hold while we connect you to the conference)
2025-04-06 16:21:39.644620 99.83% [NOTICE] switch_rtp.c:1440 Auto Changing audio stun/rtp/dtls port from 1.1.1.1:22917 to 192.168.0.11:33406 idx:-1
2025-04-06 16:21:50.804621 99.27% [NOTICE] switch_core_state_machine.c:382 sofia/internal/1000@192.168.0.38 has executed the last dialplan instruction, hanging up.
2025-04-06 16:21:50.804621 99.27% [NOTICE] switch_core_state_machine.c:384 Hangup sofia/internal/1000@192.168.0.38 [CS_EXECUTE] [NORMAL_CLEARING]
2025-04-06 16:21:50.804621 99.27% [NOTICE] switch_core_session.c:1762 Session 2 (sofia/internal/1000@192.168.0.38) Ended
2025-04-06 16:21:50.804621 99.27% [NOTICE] switch_core_session.c:1766 Close Channel sofia/internal/1000@192.168.0.38 [CS_DESTROY]