WebRTC 人声检测与舒适噪音

人声检测 VAD 人声检测(VAD: Voice Activity Detection)是区分语音中是人说话的声音,还是其他例如环境音的一种功能。 除此以外,人声检测还能用于减少网络中语音包传输的数据量,从而极大的降低语音的带宽,极限情况下能降低50%的带宽。 在一个通话中,一般都是只有一个人说话,另一人听。很少可能是两个人都说话的。 例如A在说话的时候,B可能在等待。 虽然B在等待过程中,B的语音流依然再按照原始速度和编码再发给A, 即使这里面是环境噪音或者是无声。 A ----> B # A在说话 A <--- B # B在等待过程中,B的语音流依然再按照原始速度和编码再发给A 如果B具有VAD检测功能,那么B就可以在不说话的时候,发送特殊标记的语音流或者通过减少语音流发送的频率,来减少无意义语音的发送。 从而极大的降低B->A的语音流。 下图是Wireshark抓包的两种RTP包,g711编码的占214字节,但是用舒适噪音编码的只有63字节。将近减少了4倍的带宽。 舒适噪音生成器 CNG 舒适噪音(CN stands for Comfort Noise), 是一种模拟的背景环境音。舒适噪音生成器在接收端根据发送到给的参数,来产生类似接收端的舒适噪音, 用来模拟发送方的噪音环境。 CN也是一种RTP包的格式,定义在RFC 3389 舒适噪音的payload, 也被称作静音插入描述帧(SID: a Silence Insertion Descriptor frame), 包括一个字节的数据,用来描述噪音的级别。也可以包含其他的额外的数据。早期版本的舒适噪音的格式定义在RFC 1890中,这个版本的格式只包含一个字段,就是噪音级别。 噪音级别占用一个字节,其中第一个bit必须是0, 因此噪音级别有127中可能。 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ |0| level | +-+-+-+-+-+-+-+-+ 跟着噪音级别的后续字节都是声音的频谱信息。 Byte 1 2 3 ... M+1 +-----+-----+-----+-----+-----+ |level| N1 | N2 | ... | NM | +-----+-----+-----+-----+-----+ Figure 2: CN Payload Packing Format 在SIP INVITE的SDP中也可以看到编码,如下面的CN ...

2022-06-01 08:27:53 · 2 分钟 · Eddie Wang

安装bcg729模块

g729编码的占用带宽是g711的1/8,使用g729编码,可以极大的降低带宽的费用。fs原生的mod_g927模块是需要按并发数收费的,但是我们可以使用开源的bcg729模块。 这里需要准备两个仓库,为了加快clone速度,我将这两个模块导入到gitee上。 https://gitee.com/wangduanduan/mod_bcg729 https://gitee.com/wangduanduan/bcg729 安装前提 已经安装好了freeswitch, 编译mod_bcg729模块,需要指定freeswitch头文件的位置 step0: 切换到工作目录 cd /usr/local/src/ step1: clone mod_bcg729 git clone https://gitee.com/wangduanduan/mod_bcg729.git step2: clone bcg729 mod_bcg729模块在编辑的时候,会检查当前目录下有没有bcg729的目录。 如果没有这个目录,就会从github上clone bcg729的项目。 所以我们可以在编译之前,先把bcg729 clone到mob_bcg729目录下 cd mod_bcg729 git clone https://gitee.com/wangduanduan/bcg729.git step3: 编辑mod_bcg729 编译mod_bcg729需要指定fs头文件switch.h的位置。 在Makefile项目里有FS_INCLUDES这个变量用来定义fs头文件的位置 FS_INCLUDES=/usr/include/freeswitch FS_MODULES=/usr/lib/freeswitch/mod 如果你的源码头文件路径不是/usr/include/freeswitch, 则需要在执行make命令时通过参数指定, 例如下面编译的时候。 make FS_INCLUDES=/usr/local/freeswitch/include/freeswitch Tip 如何找到头文件的目录? 头文件一般在fs安装目录的include/freeswitch目录下 如果还是找不到,则可以使用 find /usr -name switch.h -type f 搜索对应的头文件 step4: 复制so文件 mod_bcg729编译之后,可以把生成的mod_bcg729.so拷贝到fs安装目录的mod目录下 step5: 加载模块 命令行加载 load mod_bcg729 配置文件加载 命令行加载重启后就失效了,可以将加载的模块写入到配置文件中。 在modules.conf.xml中加入 <load module="mod_bcg729"/> step5: vars.xml修改 <X-PRE-PROCESS cmd="set" data="global_codec_prefs=PCMU,PCMA,G729" /> <X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=PCMU,PCMA,G729"/> <X-PRE-PROCESScmd="set"data="media_mix_inbound_outbound_codecs=true"/> step6: sip profile修改 开启转码 ...

2022-05-28 17:34:13 · 1 分钟 · Eddie Wang

会议提示音无法正常播放

呼入到会议,正常来说,当会议室有且只有一人时,应该会报“当前只有一人的提示音”。但是测试的时候,输入了密码,进入了会议,却没有播报正常的提示音。 经过排查发现,dialplan中,会议室的名字中含有@符号。 按照fs的文档,发现@后面应该是profilename, 然而fs的conference.conf.xml却没有这个profile, 进而导致语音无法播报的问题。所以只要加入这个profile, 或者直接用@default, 就可以正确的播报语音了。 Action data Description confname profile is “default”, no flags or pin confname+1234 profile is “default”, pin is 1234 confname@profilename+1234 profile is “profilename”, pin=1234, no flags confname+1234+flags{mute} profile is “default”, pin=1234, one flag confname++flags{endconf|moderator} profile is “default”, no p.i.n., multiple flags bridge:confname:1000@${domain_name} a “bridging” conference, you must provide another endpoint, or ’none'. bridge:uuid:none a “bridging” conference with UUID assigned as conference name 所以,当你遇到问题的时候,应该仔细的再去阅读一下官方的接口文档。 参考文档 ...

2022-05-28 17:17:54 · 1 分钟 · Eddie Wang

FS日志设置

开启sip信令的日志 这样会让fs把收发的sip信令打印到fs_cli里面,但不是日志文件里面 sofia global siptrace on # sofia global siptrace off 关闭 开启sofia模块的日志 sofia 模块的日志即使开启,也是输出到fs_cli里面的,不会输出到日志文件里面 sofia loglevel all 7 # sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9] 将fs_cli的输出,写到日志文件里 sofia tracelevel 会将某些日志重定向到日志文件里 sofia tracelevel debug # sofia tracelevel <console|alert|crit|err|warning|notice|info|debug> 注意,debug级别的日志非常多,仅仅适用于debug 大量的日志写入磁盘 占用太多的io 磁盘空间可能很快占满

2022-05-28 17:14:05 · 1 分钟 · Eddie Wang

Sofia 模块全部配置

About Sofia is a FreeSWITCH™ module (mod_sofia) that provides SIP connectivity to and from FreeSWITCH in the form of a User Agent. A “User Agent” (“UA”) is an application used for handling a certain network protocol; the network protocol in Sofia’s case is SIP. Sofia is the general name of any User Agent in FreeSWITCH using the SIP network protocol. For example, Sofia receives calls sent to FreeSWITCH from other SIP User Agents (UAs), sends calls to other UAs, acts as a client to register FreeSWITCH with other UAs, lets clients register with FreeSWITCH, and connects calls (i.e., to local extensions). To add a SIP Provider (Sofia User Agent) to your FreeSWITCH, please see the Interoperability Examples and add the SIP Provider information in an .xml file stored under conf/sip_profiles/ ...

2022-05-28 14:57:59 · 32 分钟 · Eddie Wang

FS常用运维手册

安装单个模块 make mod_sofia-install make mod_ilbc-install fs-cli事件订阅 /event plain ALL /event plain CHANNEL_ANSWER sofia 帮助文档 sofia help USAGE: -------------------------------------------------------------------------------- sofia global siptrace <on|off> sofia capture <on|off> watchdog <on|off> sofia profile <name> [start | stop | restart | rescan] [wait] flush_inbound_reg [<call_id> | <[user]@domain>] [reboot] check_sync [<call_id> | <[user]@domain>] [register | unregister] [<gateway name> | all] killgw <gateway name> [stun-auto-disable | stun-enabled] [true | false]] siptrace <on|off> capture <on|off> watchdog <on|off> sofia <status|xmlstatus> profile <name> [reg [<contact str>]] | [pres <pres str>] | [user <user@domain>] sofia <status|xmlstatus> gateway <name> sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9] sofia tracelevel <console|alert|crit|err|warning|notice|info|debug> sofia help -------------------------------------------------------------------------------- 开启消息头压缩 <param name="enable-compact-headers" value="true"/> fs需要重启 ...

2022-05-28 14:54:40 · 2 分钟 · Eddie Wang

FreeSWITCH 媒体相关操作

查看FS支持的编码 show codec 编码设置 vars.xml global_codec_prefs=G722,PCMU,PCMA,GSM outbound_codec_prefs=PCMU,PCMA,GSM 查看FS使用的编码 > sofia status profile internal CODECS IN ILBC,PCMU,PCMA,GSM CODECS OUT ILBC,PCMU,PCMA,GSM > sofia status profile external CODECS IN ILBC,PCMU,PCMA,GSM CODECS OUT ILBC,PCMU,PCMA,GSM 使修改后的profile生效 > sofia profile internal rescan > sofia profile external rescan 重启profile > sofia profile internal restart > sofia profile external restart

2022-05-28 14:50:55 · 1 分钟 · Eddie Wang

FS intercept拦截

FS的 call pickup功能,就是用intercept功能。 一个呼叫一般有两个leg, intercept一般是把自己bridge其中一个leg,另外一个leg会挂断。 intercept默认是bridge legA, 挂断legB。通过参数也可以指定来bridge legB,挂断legA。 从一个简单的场景说起。A拨打B分机。 从FS的角度来说,有以下两条腿。 通过分析日志可以发现:具有replaces这种头的invite,fs没有走路由,而是直接用了intercept拦截。 New Channel sofia/external/8003@wdd.cc [6ca5ed94-a5e5-492d-aaf7-782cecbaf7d1]2021-03-15 10:42:47.380797 [NOTICE] switch_channel.c:1118 New Channel sofia/external/8001@wdd.cc [34dc4095-3bac-4f7d-8be4-1ed5ed2f06b4] 2021-03-15 10:42:51.520800 [NOTICE] switch_channel.c:1118 New Channel sofia/external/8004@wdd.cc [03e78837-1413-4b77-ba4c-e753fed55ebe]2021-03-15 10:42:51.520800 [DEBUG] switch_core_state_machine.c:585 (sofia/external/8004@wdd.cc) Running State Change CS_NEW (Cur 3 Tot 163)2021-03-15 10:42:51.520800 [DEBUG] sofia.c:10279 sofia/external/8004@wdd.cc receiving invite from 192.168.2.109:18627 version: 1.10.3-release 32bit2021-03-15 10:42:51.520800 [DEBUG] sofia.c:11640 call 6ca5ed94-a5e5-492d-aaf7-782cecbaf7d1 intercepted2021-03-15 10:42:51.520800 [DEBUG] sofia.c:7325 Channel sofia/external/8004@wdd.cc entering state [received][100] ...

2021-03-15 18:21:29 · 1 分钟 · Eddie Wang

fs_cli 例子

1. 设置日志级别 每个快捷键对应一个功能,具体配置位于 /conf/autoload_configs/switch.conf.xml F1. help F2. status F3. show channels F4. show calls F5. sofia status F6. reloadxml F7. console loglevel 0 F8. console loglevel 7 F9. sofia status profile internal F10. sofia profile intrenal siptrace on F11. sofia profile internal siptrace off F12. version 2. 发起呼叫相关 下面的命令都是同步的命令,可以在所有命令前加bgapi命令,让originate命令后台异步执行。 ...

2020-04-07 17:40:16 · 1 分钟 · Eddie Wang

通道变量列表

About Channel variables are used to manipulate dialplan execution, to control call progress, and to provide options to applications. They play a pervasive role, as FreeSWITCH™ frequently consults channel variables as a way to customize processing prior to a channel’s creation, during call progress, and after the channel hangs up.  Click here to expand Table of Contents ...

2019-12-10 11:33:24 · 10 分钟 · Eddie Wang