FreeSWTICH有2种信号音检测方法一种mod_dptools: tone_detect,还有一个是mod_spandsp Call Progress,我们先介绍第一种。
如果需要可以识别出 彩铃,空号,关机,停机,彩铃,通话中,语音信箱,语音留言,等可以使用顶顶通开发的FreeSWITCH mod_da2模块,详细请看http://www.ddrj.com/asr/mod_da2.html
mod_dptools tone_detect
<action application="tone_detect" data="<key> <freqs> <flags> <timeout> <app> <data> <hits>"> |
Field | Decription | examples |
---|---|---|
key | Name of the tone (user defined) | busy, fax, mytone |
freqs | Frequencies to “listen” for | 425 - 480,620 |
flags | Which direction to sniff the tones in (r = read (default), w = write) | r |
timeout | Window of time to listen for the tones in (0 = forever, + |
+2000 (2 seconds) or 1227132612 (absolute example) |
app | Optional. Application to call when the tone detect conditions are met | transfer, hangup |
appdata | Optional. Argument to the application specified above | ‘1000 XML default’ , ‘normal_clearing’ |
hits | Number of hits needed before calling app/appdata (useful to avoid false positives) |
timeout这里特别解析一下,0:一直检测,+毫秒数:需要检测的时间, epoch:绝对时间,比如要检测60秒,就是now()+60
freqs 中国电话信号音标准
- 拨号音 450±25 -10±3dBm0 <10% 连续信号音
- 回铃音 450±25 -10±3dBm0 <10% 1S(H)/4S(L)
- 忙音 450±25 -10±3dBm0 <10% 0.35S(H)/0.35S(L)
- 拥塞音 450±25 -10±3dBm0 <10% 0.7S(H)/0.7S(L)
如果上面表格中解析看不明白,没事,下面有例子。
<!-- execute_on_tone_detect 检测到信号音执行的操作 --> |
下面是一个检测到3声忙音就挂断的例子。<action application="tone_detect" data="busy 450 r 0 hangup 'normal_clearing' 3"/>
停止信号音检测
<application="stop_tone_detect"/> |
mod_spandsp Call Progress
mod_dptools: tone_detect功能比较弱,现在我们介绍第二种吧
<configuration name="spandsp.conf" description="Tone detector descriptors"> |
通过配置文件可以配置不同信号因频率、持续时间和周期。上面的配置是配置中国忙音,持续3声认为检测成功。
Channels Variables
- execute_on_spandsp_tone_detect_XXX 检测到信号执行APP
- api_on_spandsp_tone_detect_XXX 检测到信号执行API
Dialplan Applications
spandsp_start_tone_detect
Start background tone detection with cadence.
<!-- start detection for North American call progress tones -->
<action application="spandsp_start_tone_detect" data="1"/>
spandsp_stop_tone_detect
Stop background tone detection with cadence<action application="spandsp_stop_tone_detect"/>
APIs
spandsp_start_tone_detect
Start background tone detection with cadencespandsp_start_tone_detect <uuid> <descriptor name>
spandsp_stop_tone_detect
Stop background tone detection with cadencespandsp_stop_tone_detect <uuid>
Events
DETECTED_TONE
This event is fired when the tone detector detects a tone.
The following headers are set:
Detected-Tone
Unique-ID
The Detected-Tone header will contain the name of the tone, as specified in the configuration file.
The Unique-ID will contain the session UUID.