短语,是一些宏,即Phrase Macro。
FreeSWITCH默认的配置中有大量示例。XSwitch修改过的中文的大概配置如下:
language name="zh" say-module="zh" sound-prefix="$${sounds_dir}/zh/cn/link" tts-engine="tts_commandline"
< tts-voice="Ting-Ting">
phrases>
<macros>
<<!-- 旧写法,没有命名空间 -->
X-PRE-PROCESS cmd="include" data="demo/*.xml" />
<X-PRE-PROCESS cmd="include" data="vm/sounds.xml" />
<X-PRE-PROCESS cmd="include" data="dir/sounds.xml" />
<X-PRE-PROCESS cmd="include" data="ivr/*.xml" />
<macros>
</<!-- 下面是新写法,有命名空间 -->
X-PRE-PROCESS cmd="include" data="xui/*.xml" />
<X-PRE-PROCESS cmd="include" data="vm/voicemail_ivr.xml" />
<phrases>
</language> </
其中,引用的xui/xui.xml
文件如下:
include>
<macros name="xui">
<
macro name="welcome">
<input pattern="^.*$">
<match>
<action function="play-file" data="ivr/ivr-welcome_to.wav" />
<action function="phrase" phrase="welcome_short@xui" data="" />
<match>
</input>
</macro>
</
macro name="welcome_short">
<input pattern="^.*$">
<match>
<action function="play-file" data="ivr/ivr-sales.wav" />
<action function="play-file" data="ivr/ivr-please.wav" />
<action function="play-file" data="voicemail/vm-press.wav" />
<action function="play-file" data="digits/1.wav" />
<action function="play-file" data="silence_stream://500" />
<action function="play-file" data="ivr/ivr-customer_service.wav" />
<action function="play-file" data="ivr/ivr-please.wav" />
<action function="play-file" data="voicemail/vm-press.wav" />
<action function="play-file" data="digits/2.wav" />
<action function="play-file" data="silence_stream://500" />
<action function="play-file" data="ivr/ivr-technical_support.wav" />
<action function="play-file" data="ivr/ivr-please.wav" />
<action function="play-file" data="voicemail/vm-press.wav" />
<action function="play-file" data="digits/3.wav" />
<match>
</input>
</macro>
</
macros>
</include> </
从上面的配置可以看出<macros name="xui">
定义了一个命名空间,里面的<macro>
标签则定义了一些宏。input
是输入参数,输入参数可以用正则表达式解析和捕获。在正则表达式中用()
捕获的变量内容可以在后面的action
中使用$1
、$2
等引用。
这些宏都可以在以下地方使用:
action applicaiton="playback" data="phrase:welcome@xui"/>
<action applicaiton="phrase" data="welcome@xui"/> <
跟上述Macro中对应的语音文件翻译可以在以下位置找到:
https://git.xswitch.cn/xswitch/xswitch/src/branch/master/docs/phrase/phrase_zh_CN.xml
FreeSWITCH官居方文档: