freeswitch 放音

本文档介绍了FreeSwitch中如何使用default_language变量切换语言,并详细讲解了say函数进行语音播放以及play_and_get_digits宏获取数字输入的操作。通过示例代码展示了在dialplan中实现自定义计数和数字获取的流程,同时提供了相关参数的详细解释和通道变量的作用。

使用default_language

1: phrase

2:say

===================

default_language

Controls the default language the Say Phrase engine will use when no language is explicitly specified in the API call. This permits you to easily support multiple languages by only changing a single variable at call time.

1: phrase

phrase <macro_name>,<data>
<action application="phrase" data="timespec,12:45:15"/>

Speak a phrase of text using a predefined phrase macro.

http://wiki.freeswitch.org/wiki/Speech_Phrase_Management

<macro name="custom_count">
     <input pattern="^(\d+):(.*)$">
      <match>
        <action function="play-file" data="custom/you_have.wav"/>
        <action function="say" data="$1" method="pronounced" type="items"/>
        <action function="play-file" data="custom/$2.wav"/>
      </match>
    </input>
  </macro>


2.say


3:

streamFile

4:获取数字

 destnum = session:playAndGetDigits(3, 20, 3, 5000, "#*", "phrase:getnum", "phrase:error", "\\d+")
<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> <digit_timeout>

Parameters

  • min = Minimum number of digits to fetch (minimum value of 1)
  • max = Maximum number of digits to fetch (maximum value of 128)
  • tries = numbers of tries for the sound to play
  • timeout = Number of milliseconds to wait for a dialed response after the file playback ends and before PAGD does a retry.
  • terminators = digits used to end input if less than <max> digits have been pressed. (Typically '#')
  • file = Sound file to play while digits are fetched
  • invalid_file = Sound file to play when digits don't match the regexp
  • var_name = Channel variable into which digits should be placed
  • regexp = Regular expression to match digits
  • digit_timeout = Inter-digit timeout; number of milliseconds allowed between digits; once this number is reached, PAGD assumes that the caller has no more digits to dial
    • Note: digit_timeout is optional and defaults to the value of <timeout>

Channel Variables

On exit, there may be some useful values in channel variables

  • read_terminator_used = The digit used to terminate entry (if a digit was used). Note that if termination was due to a timeout or hangup, then this channel variable is not touched (so may be left as nil or whatever it was on entry)

http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_play_and_get_digits



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值