freeswitch_unimrcp_xfyun

所属分类:模式识别(视觉/语音等)
开发工具:C
文件大小:87418KB
下载次数:0
上传日期:2019-10-30 03:35:44
上 传 者sh-1993
说明:  freeswitch_unimrcp_xfyun,使用FreeSWITCH接受用户手机呼叫,通过UniMRCP Server集成讯飞开放平台(xfyun)插件将用户语音进行语音识别(ASR),并根据自定义业务逻辑调用语音合成(TTS),构建简单的端到端语音呼叫中心。
(freeswitch_ unimrcp_ Xfyun uses FreeSWITCH to accept calls from users mobile phones, uses the UniMRCP Server integrated iFLYTEK open platform (xfyun) plug-in to conduct voice recognition (ASR) for users voices, and calls voice synthesis (TTS) according to user-defined business logic to build a simple end-to-end voice call center.)

文件列表:
freeswitch-1.6.5 (0, 2019-10-30)
freeswitch-1.6.5\.clang-format (1919, 2019-10-30)
freeswitch-1.6.5\.mailmap (181, 2019-10-30)
freeswitch-1.6.5\Freeswitch.2015.sln (334163, 2019-10-30)
freeswitch-1.6.5\Freeswitch.2015.sln.bat (2566, 2019-10-30)
freeswitch-1.6.5\INSTALL (9273, 2019-10-30)
freeswitch-1.6.5\Makefile.am (27861, 2019-10-30)
freeswitch-1.6.5\acinclude.m4 (721, 2019-10-30)
freeswitch-1.6.5\build (0, 2019-10-30)
freeswitch-1.6.5\build\Makefile.am (4491, 2019-10-30)
freeswitch-1.6.5\build\Makefile.centos5 (3901, 2019-10-30)
freeswitch-1.6.5\build\Makefile.centos6 (1535, 2019-10-30)
freeswitch-1.6.5\build\Makefile.openbsd (2665, 2019-10-30)
freeswitch-1.6.5\build\Makefile.solaris11 (4537, 2019-10-30)
freeswitch-1.6.5\build\build_patch.sh (971, 2019-10-30)
freeswitch-1.6.5\build\buildlib.sh (1697, 2019-10-30)
freeswitch-1.6.5\build\buildmrcpserver.sh (493, 2019-10-30)
freeswitch-1.6.5\build\buildopal.sh (1563, 2019-10-30)
freeswitch-1.6.5\build\buildzrtp.sh (167, 2019-10-30)
freeswitch-1.6.5\build\cc.sh (126, 2019-10-30)
freeswitch-1.6.5\build\config.layout (2360, 2019-10-30)
freeswitch-1.6.5\build\config (0, 2019-10-30)
freeswitch-1.6.5\build\config\ac_cflags_gcc_option.m4 (4647, 2019-10-30)
freeswitch-1.6.5\build\config\ac_cflags_sun_option.m4 (4697, 2019-10-30)
freeswitch-1.6.5\build\config\ac_gcc_archflag.m4 (6033, 2019-10-30)
freeswitch-1.6.5\build\config\ac_gcc_x86_cpuid.m4 (691, 2019-10-30)
freeswitch-1.6.5\build\config\ac_prog_gzip.m4 (180, 2019-10-30)
freeswitch-1.6.5\build\config\ac_prog_wget.m4 (180, 2019-10-30)
freeswitch-1.6.5\build\config\ax_cc_maxopt.m4 (4725, 2019-10-30)
freeswitch-1.6.5\build\config\ax_cflags_warn_all_ansi.m4 (3912, 2019-10-30)
freeswitch-1.6.5\build\config\ax_check_compiler_flags.m4 (1119, 2019-10-30)
freeswitch-1.6.5\build\config\ax_check_java.m4 (3723, 2019-10-30)
freeswitch-1.6.5\build\config\ax_compiler_vendor.m4 (907, 2019-10-30)
freeswitch-1.6.5\build\config\ax_lib_mysql.m4 (4383, 2019-10-30)
freeswitch-1.6.5\build\config\erlang.m4 (3175, 2019-10-30)
freeswitch-1.6.5\build\config\odbc.m4 (4264, 2019-10-30)
... ...

安装环境 ubuntu 16.04 1.下载 freeswitch-1.6.5 2.安装依赖 apt-get install -y autoconf libtool g++ zlib1g-dev libjpeg-dev libsqlite3-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libldns-dev libedit-dev libssl-dev pkg-config yasm liblua50-dev libopus-dev libsndfile1-dev libpq-dev libreadline-dev lua5.2 lua5.2-doc liblua5.2-dev libtiff5 libtiff5-dev (1)下载libyuv源码并编译 cd freeswitch/libs git clone https://freeswitch.org/stash/scm/sd/libyuv.git cd libyuv make -f linux.mk CXXFLAGS="-fPIC -O2 -fomit-frame-pointer -Iinclude/" make install cp /usr/lib/pkgconfig/libyuv.pc /usr/lib***/pkgconfig/ (2)下载libvpx源码并编译 cd .. git clone https://freeswitch.org/stash/scm/sd/libvpx.git cd libvpx ./configure --enable-pic --disable-static --enable-shared make make install cp /usr/local/lib/pkgconfig/vpx.pc /usr/lib***/pkgconfig/ 3.编译安装 cd freeswitch-1.6.5/ ./configure --prefix=/usr/local/freeswitch make make install make cd-sounds-install make cd-moh-install 4.运行 cd /usr/local/freeswitch/bin ./freeswitch FreeSWITCH默认配置1000-1019(20个)用户,默认密码1234,您可以提前跳转到“第四步 测试与验证” 的验证步骤,登录并拨打5000,可以听到默认IVR的示例语音菜单指引。 第二步 配置编译UniMRCP Server 本次示例的UniMRCP Server在CentOS 7中进行源码编译安装,感谢由Github用户cotinyang提供的已经写好的集成讯飞SDK的UniMRCP Server源码。 1.下载 UniMRCP Server Plugin Demo 源码: cd /opt git clone https://github.com/cotinyang/MRCP-Plugin-Demo.git MRCP-Plugin-Demo 2.编译准备环境 cd MRCP-Plugin-Demo/unimrcp-deps-1.5.0 ## 编译可能出现错误, 注释掉:107 ~ 109, getopt的set,其中存在不识别的option ## 编译生成apr, apr-util, target path: ./libs ./build-dep-libs.sh 注:1.过程中需要输入两次y,并确认;2.另外,我们为该Demo工程Fork了一个自己维护的工程,地址为https://github.com/wangkaisine/MRCP-Plugin-Demo 您也可以使用这个地址的源码。 3.编译安装unimrcp cd unimrcp-1.5.0 ./bootstrap ## 如果不能自动检测apr,apr-util,请在configure中增加 option:--with-apr=/path/apr --with-apr-util=/path/apr-util/ ## apr, apr-util由./build-dep-libs.sh 生成 ./configure make make install 即可在/usr/local/中看到安装好的unimrcp。 4.测试运行 cd /usr/local/unimrcp/bin ./unimrcpserver -o 3 可以使用client进行验证 cd /usr/local/unimrcp/bin ./unimrcpclient >help usage: - run [app_name] [profile_name] (run demo application) app_name is one of 'synth', 'recog', 'bypass', 'discover' profile_name is one of 'uni2', 'uni1', ... examples: run synth run recog run synth uni1 run recog uni1 - loglevel [level] (set loglevel, one of 0,1...7) - quit, exit 输入help回车,给出了使用方法,输入run recog运行语音识别测试,run synth进行语音合成测试。 第三步 集成讯飞开放平台SDK1.讯飞开发平台SDK下载 由于从讯飞开放平台下载的SDK包和用户以及用户创建的应用相关联,因此需要将third-party/xfyun中的文件和文件夹全部删除,重新下载解压属于自己的SDK,目录与源代码基本一致。 您需要注册并登录 讯飞开放平台 ,进入控制台页面,并创建应用; 在“我的应用”界面获得你的APPID,并为该应用“添加新服务”,选择需要的“语音听写”和”在线语音合成“服务(本示例需要); 点击右侧“SDK下载”,在跳转页面中确认“选择应用”已经选中了您创建的应用,“选择您需要的AI能力”选中上述两项服务,并点击“SDK下载”等待SDK生成与完成下载。 将下载的zip包,解压并替换MRCP-Plugin-Demo/unimrcp-1.5.0/plugins/third-party/xfyun/下的所有文件及文件夹。 注:创建应用页面中的应用平台选择“Linux”。 2.plugin编写与编译 本步骤将告诉您如何编写unimrcp的插件代码,即现在MRCP-Plugin-Demo/unimrcp-1.5.0/plugins文件夹下xfyun_recog、xfyun_xynth文件夹下的文件及其相关配置是如何得到的,如果您当前还不关注此细节,可以跳过本步骤至第四步。 实际上,上述MRCP-Plugin-Demo代码是在 Unimrcp官网 下载 Unimrcp 1.5.0 和 Unimrcp Deps 1.5.0 并在此基础上添加的plugin代码。 首先编辑MRCP-Plugin-Demo/unimrcp-1.5.0/configure.ac文件,会在后面的Makefile中使用到的宏定义。XFyun recognizer plugin的添加如下: dnl XFyun recognizer plugin. UNI_PLUGIN_ENABLED(xfyunrecog) AM_CONDITIONAL([XFYUNRECOG_PLUGIN],[test "${enable_xfyunrecog_plugin}" = "yes"]) ... plugins/xfyun-recog/Makefile ... echo XFyun recognizer plugin....... : $enable_xfyunrecog_plugin 注:其中 ··· 是该文件中的其它默认配置,请找到对应位置填写。 新增源码与目录 在 MRCP-Plugin-Demo/unimrcp-1.5.0/plugins 目录下,新建 xfyun-recog 目录,并在该目录下新建 src 目录,可以将 MRCP-Plugin-Demo/unimrcp-1.5.0/plugins/demo-recog/src/demo_recog_engine.cdemo_recog_engine.c 拷贝到MRCP-Plugin-Demo/unimrcp-1.5.0/plugins/xfyun-recog/src目录下改名为 xfyun_recog_engine.c,将xfyun_recog_engine.c文件进行修改(已知一个修改的部分:将appid修改成你自己下载sdk的appid,不然会报错:QISRAudioWrite failed! error code:10407),xfyun-synth目录下对应创建并修改。 在xfyun-recog文件夹下新建Makefile.am文件,内容如下: AM_CPPFLAGS = $(UNIMRCP_PLUGIN_INCLUDES) plugin_LTLIBRARIES = xfyunrecog.la xfyunrecog_la_SOURCES = src/xfyun_recog_engine.c xfyunrecog_la_LDFLAGS = $(UNIMRCP_PLUGIN_OPTS) \ -L$(top_srcdir)/plugins/third-party/xfyun/libs/x*** \ -lmsc -ldl -lpthread -lrt -lstdc++ xfyunrecog_ladir = $(libdir) xfyunrecog_la_DATA = $(top_srcdir)/plugins/third-party/xfyun/libs/x***/libmsc.so include $(top_srcdir)/build/rules/uniplugin.am UNIMRCP_PLUGIN_INCLUDES += -I$(top_srcdir)/plugins/third-party/xfyun/include 对应地,在xfyun-synth文件夹下新建Makefile.am文件夹,内容如下: AM_CPPFLAGS = $(UNIMRCP_PLUGIN_INCLUDES) plugin_LTLIBRARIES = xfyunsynth.la xfyunsynth_la_SOURCES = src/xfyun_synth_engine.c xfyunsynth_la_LDFLAGS = $(UNIMRCP_PLUGIN_OPTS) \ -L$(top_srcdir)/plugins/third-party/xfyun/libs/x*** \ -lmsc -ldl -lpthread -lrt xfyunsynth_ladir = $(libdir) include $(top_srcdir)/build/rules/uniplugin.am UNIMRCP_PLUGIN_INCLUDES += -I$(top_srcdir)/plugins/third-party/xfyun/include 修改plugins文件夹下Makefile.am文件,xfyun-recog添加内容如下: if XFYUNRECOG_PLUGIN SUBDIRS += xfyun-recog endif 对应地,xfyun-synth添加内容如下: if XFYUNRECOG_PLUGIN SUBDIRS += xfyun-synth endif 修改/usr/local/unimrcp/conf/unimrcpserver.xml文件,从默认启用demo engine改为启用我们的两个engine。 xfyun-recog修改如下: 对应地,xfyun-synth修改如下: 同时,如果您已经准备好将UniMRCP Server和FreeSWITCH对接,您应该在conf/unimrcpserver.xml中配置好server的ip地址,即当前unimrcp安装的子网访问地址。 重新编译安装unimrcp(第二步 3)。 当你启动时出现如下问题时: 1. Failed to Load DSO: /usr/local/unimrcp/lib/libmsc.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE fix:-lstdc++ 1. ./unimrcpserver: error while loading shared libraries: libsofia-sip-ua.so.0: cannot open shared object file: No such file or directory fix: 在etc/ld.so.conf 内容增加: /usr/local/lib ldconfig 将ld.so.conf读入cache 第四步 配置与验证配置配置FreeSWITCH 我们需要将处理用户语音呼入的FreeSWITCH与向xfyun engine发请求的unimrcp server两者连接起来。 1.配置unimrcp模块并自动加载; # 编辑freeswitch-1.6.5/modules.conf文件,找到要安装的模块,去掉前面的注释符号# vim modules.conf #asr_tts/mod_unimrcp asr_tts/mod_unimrcp # 执行make mod_xxx-install命令,这样就编译相应模块,并把编译后的动态库安装的/usr/local/freeswitch/mod目录下 make mod_unimrcp-install # 编辑/usr/local/freeswitch/etc/freeswitch/autoload_configs/modules.conf.xml,去掉注释符号,如果没有发现对应模块,则添加 2.设置profile文件与conf文件; 在/usr/local/freeswitch/etc/freeswitch/mrcp_profiles目录新建unimrcpserver-mrcp-v2.xml配置文件: 配置/usr/local/freeswitch/etc/freeswitch/autoload_configs/unimrcp.conf.xml文件: 注:1.unimrcpserver-mrcp-v2.xml中server-ip为unimrcpserver启动的主机ip;2.client-ip和rtp-ip为FreeSWITCH启动的主机,client-port仕FreeSWITCH作为客户端访问unimrcpserver的端口,手机作为客户端访问的FreeSWITCH端口默认为5060,两者不同;3.unimrcpserver-mrcp-v2.xml中的profile name应和unimrcp.conf.xml中的default-tts-profile与default-asr-profile的value一致(有些文档的分析中称mrcp_profiles中的xml文件名也必须和这两者一致,实际上是非必须的)。 Attenion: unimrcpserver 和 freeswitch 部署在同一个网段很重要,最好部署测试的时候在同一台物理机器上进行 3.配置IVR与脚本。 在/usr/local/freeswitch/etc/freeswitch/dialplan里新增如下配置: 在/usr/local/freeswitch/share/freeswitch/scripts目录下新增names.lua脚本: session:answer() --freeswitch.consoleLog("INFO", "Called extension is '".. argv[1]"'\n") welcome = "ivr/ivr-welcome_to_freeswitch.wav" menu = "ivr/ivr-this_ivr_will_let_you_test_features.wav"-- grammar = "hello" no_input_timeout = 80000 recognition_timeout = 80000 confidence_threshold = 0.2-- session:streamFile(welcome) --freeswitch.consoleLog("INFO", "Prompt file is \n") tryagain = 1 while (tryagain == 1) do -- session:execute("play_and_detect_speech",menu .. "detect:unimrcp {start-input-timers=false,no-input-timeout=" .. no_input_timeout .. ",recognition-timeout=" .. recognition_timeout .. "}" .. grammar) xml = session:getVariable('detect_speech_result') -- if (xml == nil) then freeswitch.consoleLog("CRIT","Result is 'nil'\n") tryagain = 0 else freeswitch.consoleLog("CRIT","Result is '" .. xml .. "'\n") tryagain = 0 endend -- -- put logic to forward call here -- session:sleep(250) session:set_tts_params("unimrcp", "xiaofang"); session:speak("今天天气不错啊"); session:hangup() 我们需要在/usr/local/freeswitch/share/freeswitch/grammar目录新增hello.gram语法文件,可以为空语法文件须满足语音识别语法规范1.0标准(简称 SRGS1.0),该语法文件 ASR 引擎在进行识别时可以使用。 北京 上海 飞往 out.date = reles.latest(); out.city = rulels.latest(); out.cross = rulels.latest(); out.city = rulels.latest(); 注:lua脚本中,”play_and_detect_speech” 调用了 ASR 服务,”speak” 调用了 TTS 服务。 通过lua脚本实现话术功能 freeswitch 呼叫用户 进入 /usr/local/freeswitch/bin 目录, ./fs_cli 启动 fs_cli originate user/1004 &echo 呼叫1004用户 originate user/1000 &lua(names.lua) 呼叫1004用户,接通后转到lua脚本,lua脚本默认存放在 /usr/local/freeswitch/share/freeswitch/scripts 目录下

近期下载者

相关文件


收藏者